Here is my goal :
I would like to have an "add" button and when user clicks on it, under it, an xforms appears to let user add a news. My model : <xforms:instance id="news-template"> <news xmlns=""> <item> <subject/> <date/> <contributors/> <content/> <comment/> </item> </news> </xforms:instance> The idea would be that the element item would be set to relevant="false" so that it doesn't appear, and when the user clicks on the add buton, relevant would be set to true and the the xform would appear. <xforms:bind nodeset="instance('news-template')/item" relevant="false" /> [...] <xforms:group ref="instance('news-template')/item"> <xforms:input ref="subject"> <xforms:label>Subject: </xforms:label> </xforms:input> [...] <xforms:submit submission="save-submission"> <xforms:label>Save</xforms:label> </xforms:submit> </xforms:group> <xforms:group ref="instance('news-template')/item"> <xforms:trigger id="add" ref="."> <xforms:label>Add</xforms:label> </xforms:trigger> <xforms:action ev:event="DOMActivate"> <xforms:setvalue ref="item/@mode" value="'view'" /> </xforms:action> </xforms:group> For tests reasons, I many change the value of relevant. How come does my bind doesn't work ? Is my way to implement my idea the proper way ? Thanks |
Hi,
StephR schrieb: > I would like to have an "add" button and when user clicks on it, under it, > an xforms appears to let user add a news. > > My model : > > <xforms:instance id="news-template"> > <news xmlns=""> > <item> If you're referencing an attribute "mode", IMHO you should add it at this point already: <item mode=""> > <subject/> > <date/> > <contributors/> > <content/> > <comment/> > </item> > </news> > </xforms:instance> > > The idea would be that the element item would be set to relevant="false" so > that it doesn't appear, and when the user clicks on the add buton, relevant > would be set to true and the the xform would appear. > <xforms:bind nodeset="instance('news-template')/item" relevant="false" /> Here you set the nodeset as not relevant _unconditionally_ . You're triggering the content of the mode attribute, so you could set the relevance according to the content of that attribute: <xforms:bind nodeset="instance('news-template')/item" relevant="@mode eq 'view'" /> So the node is marked as relevant if mode="view". > [...] > <xforms:group ref="instance('news-template')/item"> > <xforms:trigger id="add" ref="."> > <xforms:label>Add</xforms:label> > </xforms:trigger> > <xforms:action ev:event="DOMActivate"> > <xforms:setvalue ref="item/@mode" value="'view'" /> > </xforms:action> > </xforms:group> Some remarks: - The trigger is inside a group referencing a node that's not relevant by default. So the trigger wouldn't be visible as long as the item isn't relevant. But i should be visible exactly that time. So i would change the group reference checking the item/@mode attribute. If it's set to "view" (and the item is relevant - visible), the trigger can disappear: - The xforms:action can be placed inside the trigger. Because there's only one action to execute, you could place the xforms:setvalue inside the trigger and the ev:event attribute inside the xforms:setvalue. So you don't need the xforms:action element. I've attached a xhtml+xforms with the xforms chunks and my changes so you can test it in the xforms sandbox florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws test4.xhtml (2K) Download Attachment |
Wow.. thanks for your explanations
& examples. Much clearer now...
In your file, you have the following : <xforms:trigger id="add" ref=".[item/@mode != 'view']"> So if mode is set to view, ref will be set to false... and then that means that the trigger is not visible ? Florian Schmitt a écrit : Hi, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Stephane Ruchet schrieb:
> In your file, you have the following : > > <xforms:trigger id="add" ref=".[item/@mode != 'view']"> > > So if mode is set to view, ref will be set to false... and then that > means that the trigger is not visible ? yes - using ref=".[<condition>]" hides or shows the attributed element depending on <condition>. This can be used also to show or hide groups of xforms controls using <xforms:group ref=".[<condition>]">. Here the condition is the content of the mode attribute, so if that attribute is set to "view", the condition evaluates to false and the trigger is hidden. So the mode attribute can toggle whether the trigger should be displayed. florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |