问题
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:
- In Form Builder, create an Explanatory Text field, and for the URL enter
SITEURL
. - Still in Form Builder, edit the source of the form to remove the
xxf:readonly="true"
on thefr-form-resources
instance. This is the resulting form. - 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"/>
. - 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/"/>
. - In the
model.xml
, on form load, replaceSITEURL
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