user2301515
user2301515

Reputation: 5117

Orbeon, xforms subission on page load event

I have question about and xforms submission on page load event: There is an input xform

<xforms:instance id="mypagedata.input">
    <SOAP-ENV:Envelope>
        <SOAP-ENV:Header>
            <myheader />
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <mybody>give me content</mybody>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
</xforms:instance>

There is an output xform from a server

<xforms:instance id="mypagedata.output">
    <SOAP-ENV:Envelope />
</xforms:instance>

And there is a subission-function that uses input and output xml

<xforms:submission
    id="mypagedata.submission"
    action="http://localhost/orbeon/xml/mypagedata"
    mediatype="action=;application/soap+xml; charset=UTF-8"
    encoding="UTF-8"
    ref="instance('mypagedata.input')"
    method="post"
    replace="instance"
    instance="mypagedata.output">
    <xforms:send submission="mypagedata.submission" />
    <xforms:toggle case="case_busy" events:event="xforms-submit" />
    <xforms:toggle case="case_error" events:event="xforms-submit-error" />
    <xforms:toggle case="case_mypagedata" events:event="xforms-submit-done" />
</xforms:submission>
</xforms:model>

There is a my switch-tag

<xforms:switch>
    <xforms:case id="mypagedata.default">
        <xforms:trigger>
            <xforms:label>Mydata</xforms:label>
            <xforms:action events:event="DOMActivate">
                <xforms:setvalue ref="instance('mypagedata.input')//myheader" value="'this is a my header...'" />
                <xforms:send submission="mypagedata.submission" />
            </xforms:action>
        </xforms:trigger>
    </xforms:case>  
    <xforms:case id="case_busy">Loading</xforms:case>
    <xforms:case id="case_error">Error</xforms:case>
    <xforms:case id="mypagedata.output">
        </xforms:group ref="instance('mypagedata.output')">
            ... therre output-xml data
        </xforms:group>
    </xforms:case>  
</xforms:switch>

Question is that how to use two lines (setting a value and submission)

<xforms:setvalue ref="instance('mypagedata.input')//myheader" value="'this is a my header...'" />
<xforms:send submission="mypagedata.submission" />

that it not need to press a Mydata-button, it use the two lines automatically on page load? Thank you

Upvotes: 0

Views: 624

Answers (1)

ebruchez
ebruchez

Reputation: 7857

There are two events you can use upon XForms initialization:

  • xforms-model-construct-done: called when the model is ready, but the UI might not be
  • xforms-ready: when all models are ready and the UI is ready as well

The response to your submission requires access to the UI, so you need xforms-ready. Try the following within your <xforms:model> element:

<xforms:action ev:event="xforms-ready">
    <xforms:setvalue ref="instance('mypagedata.input')//myheader" value="'this is a my header...'" />
    <xforms:send submission="mypagedata.submission" />
</xforms:action>

Upvotes: 1

Related Questions