English 中文(简体)
Re-initialize XBL component on xxforms-iteration-moved
原标题:

I have a XBL component which creates a checkbox control in javascript. Value is set in javascript during the component initialization. Component works well when not used inside repeat but inside repeat when I try to move rows up or down XBL control doesn t change the state.

xxforms-iteration-moved event is fired on the row which is moved but doesn t fire on the row which changes position during this move. For instance, if I move row 3 to row 2 then xxforms-iteration-moved is fired on row 3 but I want to reinitialize components in row 2 as well as my state is saved in javascript.

I think xxforms-iteration-moved should be fired on both rows which changed position? This is really a swap which involves both rows. Please comment.

Edit: I am using Orbeon Form Runner

最佳回答

To what components the xxforms-iteration-moved is dispatched is a matter of how xxforms-iteration-moved is defined. Right now, it is dispatched to controls inside iterations that moved. What you might need is to handle the xforms-enabled event, in addition to xxforms-iteration-moved. Consider the following example: you start with a list with "a, c, d". If you insert "b" after "a", then the new "b" gets an xforms-enabled and "c, d" each get a xxforms-iteration-moved. So by reacting to both events, you should be able to (re)initialize your component as necessary.

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xhtml:title>Iteration moved</xhtml:title>
        <xforms:model>
            <xforms:instance>
                <instance>
                    <letter>a</letter>
                    <letter>c</letter>
                    <letter>d</letter>
                    <letter>e</letter>
                </instance>
            </xforms:instance>
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <fr:button>
            <xforms:label>Insert b</xforms:label>
            <xforms:insert ev:event="DOMActivate" nodeset="letter" at="1" position="after" origin="xxforms:element( letter ,  b )"/>
        </fr:button>
        <fr:button>
            <xforms:label>Delete c</xforms:label>
            <xforms:delete ev:event="DOMActivate" nodeset="letter[. =  c ]"/>
        </fr:button>
        <xforms:repeat id="letter-repeat" nodeset="letter">
            <xforms:output id="letter" value=".">
                <xforms:message ev:event="xxforms-iteration-moved" level="modal" value="concat( xxforms-iteration-moved :  , .)"/>
                <xforms:message ev:event="xforms-enabled" level="modal" value="concat( xforms-enabled :  , .)"/>
            </xforms:output>
        </xforms:repeat>
    </xhtml:body>
</xhtml:html>

I should add that if you expect your component to be used in a repeat (and sooner or later every component is), right now, because of how repeats work on the client side, if you are doing some work to initialize the component on xforms-enabled, you most likely need to do that as well on xxforms-iteration-moved. For instance, see how this is done in the fr:button component.

问题回答

暂无回答




相关问题
xform data grid

I am using orbeon to process my xforms. I am attempting to create a data grid that I can use to copy and paste rows/columns of data from my clipboard (excel). Do you have any clue how I can implement ...

Connect Chiba xForm to a restful web service (exist db)

I need to read an xml instance from an exist db. I am attempting to connect chiba to a restful web service via the following command: <xf:model> <xf:instance id="data-instance" ...

ISML PAC to XForm Conversion

Are there any tools or write-ups that can help in converting ISML PACs to XForms? Does anyone have experience in such a conversion?

XForms: how to deal with instance data that changes?

At the moment I am working on an XForms application to mutate XML data. This data comes from a local XML file. The file is exported from another application in a static way and read into the ...

Client side XForms processing tools [closed]

What would be the best client side javascript based XForms processor? I m trying to migrate plugin (activeX) based Xforms processing solution to a javascript based client side processor. But the ...

Default Values in XForms Input

I have an XForm that has certain fields that may often be left blank (optional street address). Is there is technique to set a default value for that field, preferably a space (I am running into weird ...

热门标签