Can I use a property to configure a URL in Explanatory Text?

ぃ、小莉子 提交于 2020-01-05 06:27:47

问题


In Form Builder I have a form that includes an Explanatory Text field. The text includes a link. I want the URL for that link to be different in each environment. For my HTTP Services in forms I am using a property that I have defined as described in this blog post.

Is it possible to use a property to configure the URL in the Explanatory Text?


回答1:


Once RFE 2427 is implemented, you'll have a real solution to your problem. Right now, the text shown by fr:explanation is entirely static.

You could work around this though, by creating your own custom model logic that, on form load, replaces a certain string from the text by the value of the property you defined:

  1. In Form Builder, create an Explanatory Text field, and for the URL enter SITEURL.
  2. Still in Form Builder, edit the source of the form to remove the xxf:readonly="true" on the fr-form-resources instance. This is the resulting form.
  3. In your properties-local.xml add a custom model logic: <property as="xs:anyURI" name="oxf.fr.detail.model.custom.*.*" value="oxf:/forms/resources/model.xml"/>.
  4. Still in the properties-local.xml, define the value of the placeholder with a property: <property as="xs:string" name="com.example.siteurl" value="http://www.orbeon.com/"/>.
  5. In the model.xml, on form load, replace SITEURL by the value of the property.

And here is the content of the model.xml:

<xf:model xmlns:xf="http://www.w3.org/2002/xforms"
          xmlns:xxf="http://orbeon.org/oxf/xml/xforms">
    <xf:action event="xforms-model-construct-done">
        <xf:action iterate="instance('fr-form-resources')/resource/text-with-link/text">
            <xf:setvalue ref="."
                         value="
                            replace(
                                .,
                                'SITEURL',
                                xxf:property('com.example.siteurl')
                            )"/>
        </xf:action>
    </xf:action>
</xf:model>


来源:https://stackoverflow.com/questions/43689388/can-i-use-a-property-to-configure-a-url-in-explanatory-text

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