Constraint on custom xbl component

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Constraint on custom xbl component

Binesh Gummadi
I have a custom control to which I want to add a required constraint. Custom control has two elements; a div and a button control. When button is clicked I create a span with some value and add it to the div. End result will look like a table with multiple rows. Field(list) which is bound to this component is a required field is required and I need to display the red required icon and when user adds at least one item I need to display the green check mark.

Approach that I took is, when button is clicked I trigger an event and add values to the list in the modal. Custom component has a repeat which displays the values from modal.

I can't seem to make the required icon to show up. I would appreciate if you can point me to an example or documentation.

Thanks
Binesh Gummadi
Reply | Threaded
Open this post in threaded view
|

Re: Constraint on custom xbl component

Alessandro  Vernet
Administrator
Binesh,

Since you need to have both a required icon and a green check mark
icon, I think I would just display then with two <xforms:group
ref=".[condition]">icon</xforms:group>, where condition is that the
number of fields is 0 for required icon, and that there is 1 or more
fields for the green checkmark icon. Does this make sense?

Alex

On Fri, Jul 2, 2010 at 5:42 AM, Binesh Gummadi <[hidden email]> wrote:

>
> I have a custom control to which I want to add a required constraint. Custom
> control has two elements; a div and a button control. When button is clicked
> I create a span with some value and add it to the div. End result will look
> like a table with multiple rows. Field(list) which is bound to this
> component is a required field is required and I need to display the red
> required icon and when user adds at least one item I need to display the
> green check mark.
>
> Approach that I took is, when button is clicked I trigger an event and add
> values to the list in the modal. Custom component has a repeat which
> displays the values from modal.
>
> I can't seem to make the required icon to show up. I would appreciate if you
> can point me to an example or documentation.
>
> Thanks
> Binesh Gummadi
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Constraint-on-custom-xbl-component-tp2276379p2276379.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Constraint on custom xbl component

Binesh Gummadi
--binding
<xforms:bind nodeset="instance('instance')/mylist" required="true()">

--xform def
<fr:my-custom-component
             ref="instance('instance')/mylist"
             attr1=""
             attr2="">
      <xforms:alert>This is a required field</xforms:alert>
</fr:my-custom-component>

--xbl component
        <xbl:binding id="fr-node-selector" element="fr|node-selector">
                <xbl:template xxbl:transform="oxf:unsafe-xslt">
                        <xsl:transform version="2.0">
                                <xsl:import href="oxf:/oxf/xslt/utils/xbl.xsl" />
                                <xsl:template match="/*">
                                        <xforms:group xbl:attr="model context ref bind" xxbl:scope="outer">

                                                <xsl:variable name="alert">
                                                         <xsl:choose>
       <xsl:when test="./xforms:alert">
        <xsl:value-of select="./xforms:alert"/>
       </xsl:when>
       <xsl:otherwise></xsl:otherwise> 
     </xsl:choose>
                                                </xsl:variable>
                                                                                               
                                                <xforms:alert class="citrix-xforms-label">
                                                      <xsl:copy-of select="$alert" />
                                                </xforms:alert>

                                        </xforms:group>
                                </xsl:template>
                        </xsl:transform>
                </xbl:template>
        </xbl:binding>

This is working for me. I understand that I can use two groups with condition too but this might be a better way of doing it. what do you think?

Thank you
Binesh
Reply | Threaded
Open this post in threaded view
|

Re: Constraint on custom xbl component

Binesh Gummadi
MY BAD. I reported wrong solution. This is what worked for me.

--binding
<xforms:bind nodeset="instance('instance')/mylist" required="true()">

--xform def
<fr:my-custom-component
             ref="instance('instance')/mylist"
             attr1=""
             attr2="">
      <xforms:alert>This is a required field</xforms:alert>
</fr:my-custom-component>

--xbl component
        <xbl:binding id="fr-node-selector" element="fr|node-selector">
                <xbl:template xxbl:transform="oxf:unsafe-xslt">
                        <xsl:transform version="2.0">
                                <xsl:import href="oxf:/oxf/xslt/utils/xbl.xsl" />
                                <xsl:template match="/*">
                                        <xforms:group xbl:attr="model context ref bind" xxbl:scope="outer">

                                                <xbl:content includes="xforms|alert" />

                                        </xforms:group>
                                </xsl:template>
                        </xsl:transform>
                </xbl:template>
        </xbl:binding>