本文介绍了事件xforms-model-construct-done行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表单中,我想在发布后加载表单后调用web服务。我已经为它创建了自定义的XBL控件,我有:

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

但它无法按预期工作:我每次在FormBuilder中添加新元素时发送提交或更改其他控件的名称。一般来说,提交是在我的表单以某种方式更改时发送的。



现在我希望提交内容仅在我发布表单时发送,而有人会打开它填充(当然,当我在FormBuilder中按下Test时,但我想它和发布后的填充表单一样)。



我正在尝试这样的操作:

 < xf:group id =component-group> 
< / xf:action>
< / xf:group>

不幸的是,它不起作用,这种提交方式根本没有发送。任何想法?

解决方案

这是因为XBL组件在设计时也是 live 。因此,您需要一种方法来测试组件是否在Form Builder中运行。



实际上应该有一个函数,但没有(I将其添加到我们应该添加到API 的函数列表中)。您可以这样做:


event =xforms-enabled
target =component-group
if =not($ fr-params / app ='orbeon'和$ fr-params / form ='builder')>
< xf:send submission =my-submission/>
< / xf:action>
< / xf:group>



一些小小的评论:


  • 你不需要(事实上不应该)在嵌套操作上放置事件属性

  • 你不需要甚至需要 ev 前缀


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 ?

解决方案

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

这篇关于事件xforms-model-construct-done行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 04:55