Hi,
I'm having a problem resetting values in a repeat (suppcode). Its probably something simple but I can't spot it! can anyone help? Instance data: <Document> <Body> <DPurchaseOrder> <LineItem> <custcode>custcode</custcode> <quantity/> <suppcode/> <units/> <description/> <unitprice/> <nettprice/> </LineItem> </DPurchaseOrder> </Body> </Document> <xforms:group> <xforms:repeat id="repeat_lineitem" model="model_Document" nodeset="/Document/Body/DPurchaseOrder/LineItem"> <xhtml:tr> <xhtml:td><xforms:input ref="custcode" class="Product-Code" /></xhtml:td> <xhtml:td><xforms:input ref="suppcode" class="Product-Code" /></xhtml:td> <xhtml:td><xforms:input ref="quantity" class="Product-Quantity" /></xhtml:td> <xhtml:td><xforms:input ref="units" class="Product-Units" /></xhtml:td> <xhtml:td><xforms:input ref="unitprice" class="Product-Units" /></xhtml:td> </xhtml:tr> <xhtml:tr> <xhtml:td colspan="3"><xforms:input ref="description" class="Product-Description" /></xhtml:td> <xhtml:td class="table-label-small right">Net Cost</xhtml:td> <xhtml:td><xforms:input ref="nettprice" class="Product-NetCost" /></xhtml:td> </xhtml:tr> </xforms:repeat> </xhtml:table> </xforms:group> <xforms:group> <xforms:trigger> <xforms:label>Add Line Item</xforms:label> <xforms:insert at="index('repeat_lineitem')" ev:event="DOMActivate" nodeset="/Document/Body/DPurchaseOrder/LineItem" position="after" /> <xforms:setvalue ref="suppcode"></xforms:setvalue> </xforms:trigger> </xforms:group> -- Colin Seaman Senior Developer Tradocs Ltd, Tower Point, 44 North Road, Brighton, BN1 1YR email: [hidden email] skype: colin,seaman telephone: 0870-1417031 website: http://www.tradocs.net This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please contact Tradocs. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. This content of this email is without prejudice. -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Colin,
> I'm having a problem resetting values in a repeat (suppcode). Its > probably something simple but I can't spot it! can anyone help? I assume you want to set a value in the newly inserted row? I think the issue you are encountering is that the repeat index will change upon insertion. Your code asks the XForms engine to insert an element after the current element in the repetition. But the context for the execution of the xforms:setvalue action is: /Document/Body/DPurchaseOrder/LineItem" This means that: <xforms:setvalue ref="suppcode"></xforms:setvalue> actually always refers to the "suppcode" element of the *first* LineItem element, as per the XForms first-node rule. What about writing, instead: <xforms:setvalue ref="../LineItem[index('repeat_lineitem')]/suppcode"/> Alternatively, you can create an insertion template that always contain the default values: <xforms:instance id="LineItem-template"> <LineItem> <custcode>custcode</custcode> <quantity/> <suppcode/> <units/> <description/> <unitprice/> <nettprice/> </LineItem> </xforms:instance> And then use the @origin attribute on xforms:insert: <xforms:insert at="index('repeat_lineitem')" ev:event="DOMActivate" nodeset="/Document/Body/DPurchaseOrder/LineItem" position="after" origin="instance('LineItem-template')"/> -Erik > Instance data: > <Document> > <Body> > <DPurchaseOrder> > <LineItem> > <custcode>custcode</custcode> > <quantity/> > <suppcode/> > <units/> > <description/> > <unitprice/> > <nettprice/> > </LineItem> > </DPurchaseOrder> > </Body> > </Document> > > <xforms:group> > <xforms:repeat id="repeat_lineitem" model="model_Document" > nodeset="/Document/Body/DPurchaseOrder/LineItem"> > <xhtml:tr> > <xhtml:td><xforms:input ref="custcode" class="Product-Code" > /></xhtml:td> > <xhtml:td><xforms:input ref="suppcode" class="Product-Code" > /></xhtml:td> > <xhtml:td><xforms:input ref="quantity" class="Product-Quantity" > /></xhtml:td> > <xhtml:td><xforms:input ref="units" class="Product-Units" > /></xhtml:td> > <xhtml:td><xforms:input ref="unitprice" class="Product-Units" > /></xhtml:td> > </xhtml:tr> > <xhtml:tr> > <xhtml:td colspan="3"><xforms:input ref="description" > class="Product-Description" /></xhtml:td> > <xhtml:td class="table-label-small right">Net Cost</xhtml:td> > <xhtml:td><xforms:input ref="nettprice" class="Product-NetCost" > /></xhtml:td> > </xhtml:tr> > </xforms:repeat> > </xhtml:table> > </xforms:group> <xforms:group> > <xforms:trigger> > <xforms:label>Add Line Item</xforms:label> > <xforms:insert at="index('repeat_lineitem')" > ev:event="DOMActivate" nodeset="/Document/Body/DPurchaseOrder/LineItem" > position="after" /> > <xforms:setvalue ref="suppcode"></xforms:setvalue> > </xforms:trigger> > </xforms:group> -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by Colin Seaman
try this:
<xforms: instance id="document"> <Document> <Body> <DPurchaseOrder> <LineItem> <custcode>custcode</custcode> <quantity/> <suppcode/> <units/> <description/> <unitprice/> <nettprice/> </LineItem> </DPurchaseOrder> </Body> </Document> .... <xforms:group> <xhtml:table> <xforms:repeat id="repeat_lineitem" nodeset="instance('document')/Body/DPurchaseOrder/LineItem"> <xhtml:tr> <xhtml:td><xforms:input ref="custcode"/></xhtml:td> <xhtml:td><xforms:input ref="suppcode"/></xhtml:td> <xhtml:td><xforms:input ref="quantity"/></xhtml:td> <xhtml:td><xforms:input ref="units"/></xhtml:td> <xhtml:td><xforms:input ref="unitprice"/></xhtml:td> </xhtml:tr> <xhtml:tr> <xhtml:td colspan="3"><xforms:input ref="description" /></xhtml:td> <xhtml:td>Net Cost</xhtml:td> <xhtml:td><xforms:input ref="nettprice"/></xhtml:td> </xhtml:tr> </xforms:repeat> </xhtml:table> </xforms:group> <xforms:group> <xforms:trigger> <xforms:label>Add Line Item</xforms:label> <xforms:insert at="index('repeat_lineitem')" ev:event="DOMActivate" nodeset="instance('document')/Body/DPurchaseOrder/LineItem" position="after" /> <!-- This is most likely not what you want here... --> <!-- what's the evaluating context of 'suppcode'? Where does this value go? --> <xforms:setvalue ref="suppcode"></xforms:setvalue> <!-- to set the value of the last lineitem, try something like this instead --> <!-- (not sure if this will work, or this is what you want, though) --> <xforms:setvalue ref="index('repeat_lineitem')/suppcode"></xforms:setvalue> </xforms:trigger> </xforms:group> Hope that helps. Henrik PS! Next time, attach an xforms source file that will run / won't run in the XForms sandbox on orbeon.com. It's much easier to help. On 10/9/06, Colin Seaman <[hidden email]> wrote:
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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |