What is the proper syntax to databind a class attribute in the OpenLaszlo language? - openlaszlo

I am developing a class where I wish to databind the attributes of a class to a dataset.
I have managed to get the following to work in the following simplified version of my class:
<class name="myclass">
<dataset name="attSettings"><settings>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</settings></dataset>
<attribute name="default_applyshadow" type="boolean" value="$once{(this.attSettings.getPointer()).xpathQuery('settings/property[#name="applyshadow"]/#defaultvalue')}" />
</class>
However, this syntax is very cumbersome and does not feel right so I am wondering if there is a better way to do this.

This doesn't answer your question but explains why you cannot use a local dataset in your situation. When you have a local dataset in a class, the dataset can only be addressed in children of the class, e.g.:
<canvas debug="true">
<class name="myclass">
<dataset name="myds">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot.myds:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
<myclass />
</canvas>
The <text> element can access the dataset of the parent class by prepending local: to the datapath value. If you don't select a name for your dataset, OpenLaszlo will automatically use the name localdata for the dataset. Datasets using that name can be addressed by omitting the dataset name in the datapath/xpath value, e.g.
<class name="myclass">
<dataset>
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
Note that the datapath does not have a name and that the datapath used for the <text> component is now local:classroot:/root/..., while local:classroot.localdata:/root/... would work as well.
I don't understand the design decision which makes it impossible to allow the use a local dataset in the datapath of a class containing that dataset, but maybe there were some technical reasons (initialization order, etc.) for it.

I figured out the proper syntax to do what I wanted:
<dataset name="myclass_settings">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<class name="myclass" datapath="myclass_settings:/root">
<attribute name="default_applyshadow" type="boolean" value=$path{'property[#name="applyshadow"]/#defaultvalue'}" />
</class>
The $path{} constraint is used on the class attribute to link the value to the dataset via a relative xpath query. I also had to move the dataset outside of the class to get it to work.

Related

Adding Custom Content Items in Orchard Site Recipe

I have added a content type in my custom orchard recipe but when I try to create an instance of that content type within the recipe nothing happens.
Declaration:
<Metadata>
<Types>
<Speedbump ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Indexes="Search">
<TitlePart />
<BodyPart />
<CommonPart />
</Speedbump>
</Types>
<Parts>
<BodyPart BodyPartSettings.FlavorDefault="html" />
</Parts>
</Metadata>
Creation:
<Command>
Speedbump create /Slug:"valid-url" /Title:"Valid URL" /Path:"valid-url" /Homepage:false /Publish:true /UseWelcomeText:false
</Command>
Any ideas as to why this isn't working? I can go into the site after it is created and my speedbump type is defined and creatable but the instance that should have been created by the recipe doesn't exist. Thank you.
This isn't how you create content items in recipes. You add xml in the <Data> tag like so:
<Data>
<Speedbump Id="" Status="Published">
<BodyPart Text="Hello this needs to be encoded" />
<CommonPart Owner="/User.UserName=admin" CreatedUtc="2014-09-05T16:09:13Z" PublishedUtc="2014-09-05T16:15:43Z" ModifiedUtc="2014-09-05T16:15:43Z" />
<TitlePart Title="My Page" />
</Speedbump>
</Data>
For any custom parts, you will need to implement Import and Export functions in your driver method. Check core modules for good examples

Embed a video object in html

I have this assignement where I have to used export for web in quicktime pro 7. Then copy/paste the read me.html file into the body (exactly as it is), which I did.
However, I keep getting 3 errors when I run my .html through W3C and cannot figure out how to correct it.
I realized there are probably better way to embed object but this is how they want us to do it for this assignment. Can anyone help me correct these 3 errors please.
Many thanks in advance.
<object width="350" height="278">
<param name="src" value="swiss/swiss-poster.jpg" />
<param name="href" value="swiss/swiss.mov" />
<param name="target" value="myself" />
<param name="controller" value="false" />
<param name="autoplay" value="false" />
<param name="scale" value="aspect" />
<embed width="350" height="278" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"
src="swiss/swiss-poster.jpg"
href="swiss/swiss.mov"
target="myself"
controller="false"
autoplay="false"
scale="aspect">
</embed>
</object>
Line 1 : Element object is missing one or more of the following attributes: data, type.
Line 14: Attribute href not allowed on element embed at this point.
scale="aspect">
Line 15: Stray end tag embed.
I just needed to embed a quicktime movie myself, and I looked to the Mozilla Developer Network for the syntax: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object
I believe that the data attribute would take the place of href in your params:
param name="href" value="swiss/swiss.mov" />
would be:
<param name="data" value="swiss/swiss.mov" />
and the type in this case would be "video/quicktime":
<param name="type" value="video/quicktime" />
There is also an <embed> reference at MDN (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed), but it covers only the HTML5 version of the element, which doesn't require a closing </embed> tag.
The reference at sitepoint (http://reference.sitepoint.com/html/embed) addresses the earlier syntax, and also says:
"embed isn’t part of any currently recognized standard (it is included in HTML5 which is not yet finalized), so if you use it, your page can’t possibly validate".
That suggests that with <embed> you should probably focus more on actual behavior in the browser than the W3C's validation tool.

Fetch XML vs SQL CRM2011

I am having a bizarre problem, and was hoping that someone could shed some light on why it is occurring. If I Query dynamics using FetchXML using the following:
<fetch mapping="logical" count="10" distinct="true" version="1.0">
<entity name="activitypointer">
<attribute name="activityid" />
<attribute name="activitytypecode" />
<attribute name="createdon" />
<attribute name="ownerid" />
<attribute name="statecode" />
<attribute name="statuscode" />
<attribute name="subject" />
<attribute name="actualend" />
<order attribute="actualend" descending="true" />
<filter type="or">
<condition attribute="regardingobjectid" operator="eq" value="66431c2f-fab6-dd11-94f2-0014221f6f5c" />
</filter>
</entity>
Then I get the following set of results:
However if I do the same query in SQL:
SELECT TOP 100 activityid, activitytypecodename, createdon, owneridname, statecodename, statuscodename, subject, actualend FROM [CRM2011_MSCRM].[dbo].[FilteredActivityPointer] WHERE regardingobjectid = '66431C2F-FAB6-DD11-94F2-0014221F6F5C' ORDER BY actualend DESC
Then I get the following results:
You can see that the results are pretty much the same, however if you look at the status code column then you can see that the results differ in the fact that one states that it has been sent while the other has been completed.
Therefore how can I filter based upon the status of the item when the two different methods seem to bring back different results for the state code?
(I am currently trying to do a report in SSRS using FetchXML I have previously tried doing it in SQL but had problems, therefore used FetchXML to solve this)
-- Edit
When I use the appointment entity then I do get the correct results:
<fetch mapping="logical" count="50" version="1.0">
<entity name="appointment">
<attribute name="activityid" />
<attribute name="activitytypecode" />
<attribute name="actualend" />
<attribute name="createdon" />
<attribute name="ownerid" />
<attribute name="statecode" />
<attribute name="statuscode" />
<attribute name="subject" />
<filter>
<condition attribute="regardingobjectid" operator="eq" value="66431c2f-fab6-dd11-94f2-0014221f6f5c" />
</filter>
</entity>
Which returns this:
The only problem with this though is I need to know the status for a whole list of different activities - thus I thought you needed to use the activity pointer (as it is the base class plus you can't join results together in SSRS.)
Well, this isn't an answer on how to solve this, perhaps, but I think I can shed some light on why it may be happening.
For the statuscode of an activitypointer, fetchXML is taking the integer value and mapping it to the activitypointer lookup table, while SQL maps it to the actual child entity's table.
For example, take your very first record, which happens to be an email. FetchXML says the status is "cancelled". Checking the activitypointer metadata (http://msdn.microsoft.com/en-us/library/gg328148.aspx) we see that "cancelled" is value "3". Now, going to the email entity metadata (http://msdn.microsoft.com/en-us/library/hh155312.aspx) we see that value "3" is actually "sent", which is what SQL says.
This goes for all the entities you have in the table. The lonely Task with no fetchXML status, for example, is actually completed according to sql. That's value "5" (http://msdn.microsoft.com/en-us/library/gg594424.aspx), which doesn't map to anything for activitypointers; their values are limited to a range of 1-4. As a result, fetchXML shows nothing.
Try getting the statuscodeValue rather than name. I expect the integer values will be identical for both fetchXML and SQL. Why they map the names differently I can't answer.

How to add Listview to publishing page through CAML provisioning

it is a big question since long time and now I am facing it....
I have to add list view web part through CAML to publish page.
I have used the code:
<View List="0GeneralInformationandReports" RowLimit="5" FreeForm="TRUE"
BaseViewID="0"
RecurrenceRowset="TRUE"
WebPartZoneID="bottomLeft_LeftZone"
WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title">0 - General Information and Reports</property>
<property name="AllowConnect" type="bool">True</property>
<property name="AllowClose" type="bool">False</property>
<property name="Height" type="unit">215px</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
and it is rendering fine with the list view on the page. But i have to add more control to the web part like show only limited columns and top 5 modified by date ascending. This is not working using the tag as there are no other ways I can add sorting, view fields etc...
please help.
I have tried that and still it is not working. This is my list view in schema.xml.
<View DisplayName="" BaseViewID="0" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" Hidden="TRUE" XslLink="main.xsl"
WebPartZoneID="bottomLeft_LeftZone" WebPartOrder="0">
<XslLink>main.xsl</XslLink>
<Query />
<ViewFields>
<FieldRef Name="DocIcon" />
<FieldRef Name="LinkFilenameNoMenu" />
</ViewFields>
<RowLimit>5</RowLimit>
<Aggregations Value="Off" />
</View>
</Views>
Still it is showing the same fields... No ideas how to get to it... I have referenced BaseView="0" in the of my elements.xml. Still no luck.
To do that, you'll probably have to define a new View in your List Definition, and then use BaseViewID to specify the new view by that ID.

How I can make unique and following id in xsd schema?

I don't know if XSD permits that but i'd like make my unique id (I already know how to make them) to be a sequence of number.
example :
<object id="0" />
<object id="2" />
<object id="1" />
would be correct but
<object id="0" />
<object id="2" />
<object id="3" />
would be not.
the ids must start from 0 and all number must be here (no missing number) (but with a quantity of "object" not fixed.
I don't know if this is really clear. Thanks.

Resources