Orbeon可重复区域移除按钮自定义标签及本地化实现问询
Orbeon可重复实例移除按钮自定义标签实现方案与需求
问题背景
我们需要在Orbeon Builder中为可重复实例的「添加」「移除」按钮设置自定义标签,比如将默认的「Remove line」替换为「Remove person」这类贴合上下文的文本。目前Orbeon 2022.1版本已支持「添加」按钮的自定义标签配置,但「移除」按钮没有官方提供的配置选项,想了解:
- 是否可以实现移除按钮的自定义标签(包含无需自定义开发和需要自定义开发的方案)
- 这些自定义标签是否支持本地化
已完成的自定义开发实现
参考「添加重复标签」的官方实现逻辑,我通过修改section.xbl控件,实现了在表单源码中定义移除按钮自定义标签的功能(仅适用于appearance="minimal"的section变体),具体步骤如下:
1. 在section.xbl中添加标签变量
添加参考repeater.xbl的变量逻辑,用于渲染自定义移除标签:
<xsl:variable name="remove-iteration-label-content" as="element()*"> <xsl:choose> <xsl:when test="exists(fr:remove-iteration-label)"> <xsl:for-each select="fr:remove-iteration-label[1]"> <xh:i class="fa fa-fw fa-minus-circle fr-fixed-density"/> <xf:output value="{@ref}" xxbl:scope="outer" appearance="minimal"> <xsl:copy-of select="@mediatype"/> </xf:output> </xsl:for-each> </xsl:when> <xsl:otherwise> <xh:i class="fa fa-fw fa-minus-circle fr-fixed-density"/> </xsl:otherwise> </xsl:choose> </xsl:variable>
2. 修改section.xbl中的按钮渲染代码
将原移除按钮的图标代码替换为上述变量,让自定义标签生效:
<xsl:if test="$right-column"> <xh:div xxf:control="true" ref=".[not($view-mode)]" class="fr-section-right-column"> <xf:group ref=".[$fr-repeater-can-remove]"> <xh:button class="btn btn-link fr-repeater-remove-button" title="{{xxf:r('components.section.remove.hint', '|fr-fr-resources|')}}"> <xsl:copy-of select="$remove-iteration-label-content"/> </xh:button> </xf:group> <xf:group ref=".[not($fr-repeater-can-remove)]"> <xh:i class="fa fa-fw fa-minus-circle fr-fixed-density disabled"/> </xf:group> </xh:div> </xsl:if>
3. 在表单源码中配置自定义标签
在可重复section节点下添加fr:remove-iteration-label元素,关联资源文件中的标签内容:
<fr:section apply-defaults="true" bind="section-1-bind" fb:initial-iterations="first" id="section-1-section" min="1" repeat="content" template="instance('section-1-template')" appearance="minimal"> <xf:label ref="$form-resources/section-1/label"/> <fr:remove-iteration-label ref="$form-resources/section-1/remove-iteration-label"/> [...]
待解决的需求
目前通过源码修改已实现移除按钮自定义标签的基础功能,但还缺少以下能力,寻求相关指导:
- 通过Orbeon Builder GUI可视化配置移除按钮的自定义标签
- 完善自定义标签的多语言本地化支持
内容的提问来源于stack exchange,提问作者Marek Kamiński
相关产品推荐
相关产品推荐

