如何创建具有预定义的可见性,控件名称,默认值的Orbeon自定义控件XBL? [英] How to create Orbeon custom control XBL with predefined visibility, control name, default value?

查看:133
本文介绍了如何创建具有预定义的可见性,控件名称,默认值的Orbeon自定义控件XBL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义控件(带有一些预定义值的隐藏文本框),我想在其中设置XBL文件中的visibility=false()controlName="Mycustom"default value="This is my custom control".这样,每当我们使用Orbeon Form Builder中的自定义控件时,它将带有所有默认值,而无需进行任何设置.

I have created a custom control (hidden text box with some predefined value), where I want to set visibility=false(), controlName="Mycustom", default value="This is my custom control" in XBL file. So that whenever we use that custom control from Orbeon Form Builder, it will come with all default values with no need to set anything.

XBL:

<xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml"
         xmlns:xf="http://www.w3.org/2002/xforms"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
         xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:saxon="http://saxon.sf.net/"
         xmlns:xbl="http://www.w3.org/ns/xbl"
         xmlns:exf="http://www.exforms.org/exf/1-0"
         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl">

     <metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
        <display-name lang="en">Epson Custom Controls</display-name>
    </metadata>

    <xbl:binding id="fr-custom" element="fr|custom" >
        <metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
            <display-name lang="en">My Custom Control</display-name>
            <icon lang="en">
                <small-icon>/forms/orbeon/builder/images/input.png</small-icon>
                <large-icon>/forms/orbeon/builder/images/input.png</large-icon>
            </icon>
            <templates>
                <bind xxf:whitespace="trim"/>
                <view>
                    <xf:input id="myCustom" ref="" xmlns="">
                       <xf:label>My Custom lable</xf:label>
                        <xf:hint ref=""/>
                        <xf:help ref=""/>
                        <xf:alert ref=""/>
                    </xf:input>
                </view>
            </templates>
        </metadata>
    </xbl:binding>
</xbl:xbl>

使用上述控件,我想使用value='This is my custom control'的隐藏文本框,其控件名称应为Mycustom.

Using above control I want hidden text box with value='This is my custom control' and its control name should be Mycustom.

更新

我尝试了以下更改,但不起作用

I have tried with below changes, but it is not working

        <templates>
            <bind xxf:whitespace="trim" relevant="false()" xxf:default="'This is my custom control'"/>
            <view>
                <xf:input id="myCustom" ref="" xmlns="">
                   <xf:label>Success Message</xf:label>
                    <xf:hint ref=""/>
                    <xf:help ref=""/>
                    <xf:alert ref=""/>
                </xf:input>
            </view>
        </templates>

通过上述更改,现在可以正常工作了(控件已隐藏了一些默认值).

With above changes now its working (control is hidden with some default value).

如果有条件,请让我知道如何放置 properties-local.xml:

Can you please let me know how to put if condition properties-local.xml:

 <property as="xs:string"  name="oxf.fr.detail.process.save-final-custom.*.*">
            require-uploads
            then validate-all
            then save
            if({xxf:instance('fr-form-instance')//customMessage} != null)
              {
                then success-message(message = "{xxf:instance('fr-form-instance')//customMessage}")
              }
            recover error-message("database-error") 
     </property>

如果成功地从后台配置了此成功消息,我想在这里覆盖它.如果其值为null,则要显示OOTB消息(请勿覆盖).

Here I want to override this success-message if it properly configured from backed. If it's value is null then want to show OOTB message(don't override).

Update2

Update2

Hybris的集成更改.以下是我在Hybris中所做的更改

Integrated changes in Hybris. below are the changes I have made in Hybris

  • 创建XBL > orbeon > custom > custom.xbl

<bind xxf:whitespace="trim" relevant="false()" xxf:default="'This is my custom control'"/>

问题:-当我们选择自定义控件时,它将绑定而没有任何标签/消息/可见性等.但是,如果我刷新左控制面板,则标签开始出现在表单上.但仍未设置默认消息.

Issue :- When we select custom control, it will bind without any lable/message/visibility etc. But if I refresh left control panel then label start appearing on the form. but still default message is not set.

推荐答案

让我们一一介绍您提到的内容:

Let's take the items you mentioned one by one:

  1. visibility="false()" –我想您是在XForms中引用的是relevant属性,而不是visibility属性. (Form Builder称其为可见性",因为它就是这个可见性",但是在XForms中,属性为relevant.)这可以通过在<templates><bind relevant="false()"/>内使用来实现.
  2. controlName="Mycustom" –您无法在XBL中设置控件的ID. (顺便说一句,使用Form Builder时,XForms ID是从Form Builder中的表单作者定义的控件名称中推断出来的.)该ID由使用控件的人(而不是定义控件的人)设置,否则,对于一个控件,这将阻止您可以从表单中获得该控件的多个实例.
  3. default value="This is my custom control" –与上面的#1一样,您可以使用<bind xxf:default="'This is my custom control'">执行此操作.请注意添加的单引号,因为xxf:default的值是XPath表达式.
  1. visibility="false()" – I imagine you're referring to the relevant attribute in XForms, instead of the visibility attribute. (Form Builder calls this "visibility", because this is what it is, but in XForms, the attribute is relevant.) This can be done by having inside the <templates> a <bind relevant="false()"/>.
  2. controlName="Mycustom" – You can't set the id of the control in XBL. (BTW, when using Form Builder, the XForms id is inferred from the control name defined by the form author in Form Builder.) The id is set by whoever uses the control, not whoever defines it, otherwise, for one, this would prevent you from having multiple instances of that control in the form.
  3. default value="This is my custom control" – As in #1 above, you can do this with <bind xxf:default="'This is my custom control'">. Note the added single quotes, as the value of xxf:default is an XPath expression.

这篇关于如何创建具有预定义的可见性,控件名称,默认值的Orbeon自定义控件XBL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆