Event xforms-model-construct-done behaviour

↘锁芯ラ 提交于 2019-12-11 16:14:50

问题


In my form I would like to call web service after to form is loaded after publishing. I've created custom XBL control for it, where I have :

<xf:group id="component-group">
    <xf:action ev:event="xforms-enabled" ev:target="component-group">
        <xf:send ev:event="xforms-enabled" submission="my-submission"/> 
    </xf:action>
</xf:group>

But it doesn't work as expected : my submission is sent everytime when I add new element in FormBuilder or change a name of some other controls. Generally speaking submission is sent when my form is changing in some way.

Now I want submission to be sent ONLY when I publish my form and someone would open it to fill (and of course when I press "Test" in FormBuilder, but I guess it's the same as filling form after publishing).

I was trying something like this :

<xf:group id="component-group">
    <xf:action ev:event="xforms-model-construct-done" ev:target="component-group">
        <xf:send ev:event="xforms-model-construct-done" submission="my-submission"/> 
    </xf:action> 
</xf:group>

Unfortunately it's not working, this way submission is not sent at all. Any thoughts ?


回答1:


This is due to the fact that XBL components are live at design time too. So you need a way to test whether the component is running within Form Builder or not.

There should be a function for this, really, but there isn't (I added this to the list of functions we should add to the API here). You can do:

<xf:group id="component-group"> <xf:var name="fr-params" value="xxf:instance('fr-parameters-instance')"/> <xf:action event="xforms-enabled" target="component-group" if="not($fr-params/app = 'orbeon' and $fr-params/form = 'builder')"> <xf:send submission="my-submission"/> </xf:action> </xf:group>

A few minor comments:

  • you don't need to (in fact shouldn't) place event attributes on nested actions
  • you don't even need the ev prefix


来源:https://stackoverflow.com/questions/27621087/event-xforms-model-construct-done-behaviour

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!