Hi all,
I'm stuck on getting xforms:switch/xforms:case working the way I want it to. I have a very simple for that will either post an instance to a Solr document or delete the Solr document. I could do with with two forms, but I'd rather condense it into one. I'm passing through 3 parameters, id, title of the document, and mode, which is either "create" for posting to Solr or "delete" for deleting from Solr. Here's a bit of code: In the model: <xforms:instance id="to-publish"> <verification xmlns="">Click OK to publish <title/>.</verification> </xforms:instance> <xforms:instance id="unpublish"> <verification xmlns="">Click OK to unpublish <title/>.</verification> </xforms:instance> <!-- get id parameter and set that to be the file to delete --> <xforms:action ev:event="xforms-model-construct-done"> <xforms:setvalue ref="instance('id')" value="xxforms:get-request-parameter('id')"/> <xxforms:variable name="mode" select="xxforms:get-request-parameter('mode')"/> <xforms:action if="$mode = 'create'"> <xforms:setvalue ref="instance('to-publish')/title" value="xxforms:get-request-parameter('title')"/> </xforms:action> <xforms:action if="$mode = 'delete'"> <xforms:setvalue ref="instance('unpublish')/title" value="xxforms:get-request-parameter('title')"/> <xforms:toggle case="remove-publication-verification"/> </xforms:action> </xforms:action> In the view: <xforms:switch> <xforms:case id="publication-verification"> <p><xforms:output ref="instance('to-publish')"/></p> <p><xforms:submit submission="ead-to-solr"> <xforms:label>OK</xforms:label> </xforms:submit></p> </xforms:case> <xforms:case id="remove-publication-verification"> <p><xforms:output ref="instance('unpublish')"/></p> <p><xforms:submit submission="delete-from-solr"> <xforms:label>OK</xforms:label> </xforms:submit></p> </xforms:case> <xforms:case id="status-update"> <xforms:group ref="instance('status')/text()"> <div class="success"> <xforms:output ref="instance('status')"/> </div> </xforms:group> </xforms:case> </xforms:switch> If the mode is create, I want it to show the "publication-verification" case. If the mode is delete, I want it to show the "remove-publication-verification" case. It isn't doing that. <xforms:toggle case="remove-publication-verification"/> isn't working. I added the ev:event attribute with tried a few events, but didn't get it working. What am I missing to get <xforms:toggle case="remove-publication-verification" ev:event="???"/> working correctly? I assume it is possible to do what I want to, but I don't have the syntax correct. Thanks, Ethan -- 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 |
Administrator
|
Ethan,
You can't run xforms:toggle on xforms-model-construct-done, because at that point the controls don't exist yet. Or rather, you can, but it will have no effect ;). If you do, you'll see something like this in the log: 2010-03-22 17:44:47,982 DEBUG XFormsServer - interpreter - start executing {action name: "toggle"} 2010-03-22 17:44:47,982 DEBUG XFormsServer - xforms:toggle - case does not refer to an existing xforms:case element, ignoring action {case id: "remove-publication-verification"} 2010-03-22 17:44:47,982 DEBUG XFormsServer - interpreter - end executing {time (ms): "0", action name: "toggle"} So instead, you need to run this on xforms-ready. Alex On Fri, Mar 19, 2010 at 1:52 PM, Ethan Gruber <[hidden email]> wrote: > Hi all, > > I'm stuck on getting xforms:switch/xforms:case working the way I want it > to. I have a very simple for that will either post an instance to a Solr > document or delete the Solr document. I could do with with two forms, but > I'd rather condense it into one. I'm passing through 3 parameters, id, > title of the document, and mode, which is either "create" for posting to > Solr or "delete" for deleting from Solr. Here's a bit of code: > > In the model: > > <xforms:instance id="to-publish"> > <verification xmlns="">Click OK to publish > <title/>.</verification> > </xforms:instance> > > <xforms:instance id="unpublish"> > <verification xmlns="">Click OK to unpublish > <title/>.</verification> > </xforms:instance> > > <!-- get id parameter and set that to be the file to delete --> > <xforms:action ev:event="xforms-model-construct-done"> > <xforms:setvalue ref="instance('id')" > value="xxforms:get-request-parameter('id')"/> > <xxforms:variable name="mode" > select="xxforms:get-request-parameter('mode')"/> > > <xforms:action if="$mode = 'create'"> > <xforms:setvalue ref="instance('to-publish')/title" > value="xxforms:get-request-parameter('title')"/> > </xforms:action> > <xforms:action if="$mode = 'delete'"> > <xforms:setvalue ref="instance('unpublish')/title" > value="xxforms:get-request-parameter('title')"/> > <xforms:toggle case="remove-publication-verification"/> > </xforms:action> > > </xforms:action> > > > In the view: > > <xforms:switch> > <xforms:case id="publication-verification"> > <p><xforms:output ref="instance('to-publish')"/></p> > > <p><xforms:submit submission="ead-to-solr"> > <xforms:label>OK</xforms:label> > </xforms:submit></p> > </xforms:case> > <xforms:case id="remove-publication-verification"> > <p><xforms:output ref="instance('unpublish')"/></p> > > <p><xforms:submit submission="delete-from-solr"> > <xforms:label>OK</xforms:label> > </xforms:submit></p> > </xforms:case> > <xforms:case id="status-update"> > <xforms:group ref="instance('status')/text()"> > <div class="success"> > <xforms:output ref="instance('status')"/> > </div> > </xforms:group> > </xforms:case> > </xforms:switch> > > If the mode is create, I want it to show the "publication-verification" > case. If the mode is delete, I want it to show the > "remove-publication-verification" case. It isn't doing that. > <xforms:toggle case="remove-publication-verification"/> isn't working. I > added the ev:event attribute with tried a few events, but didn't get it > working. What am I missing to get <xforms:toggle > case="remove-publication-verification" ev:event="???"/> working correctly? > I assume it is possible to do what I want to, but I don't have the syntax > correct. > > Thanks, > Ethan > > > -- > 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 > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Thanks! That was as easy as I figured it would be.
Ethan On Mon, Mar 22, 2010 at 8:46 PM, Alessandro Vernet <[hidden email]> wrote: Ethan, -- 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 |