<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Configure input validation of components by the caller</title><link>https://answers.axonivy.com/questions/23/configure-input-validation-of-components-by-the-caller</link><description>&lt;p&gt;I need to validate composite components in Ivy and JSF a little bit different depending on the caller of the composite. How can I do this?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/23/configure-input-validation-of-components-by-the-caller" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 09 Oct 2013 09:25:21 -0400</lastBuildDate><item><title>Answer by SupportIvyTeam</title><link>https://answers.axonivy.com/questions/23/configure-input-validation-of-components-by-the-caller/24</link><description>&lt;p&gt;JSF offers the possibility to use so called value holders in the interface of a composite. You can then configure the validation in the usage of the component. &lt;/p&gt;
&lt;p&gt;More precisely, you can use &lt;code&gt;cc:valueHolder&lt;/code&gt; in a &lt;code&gt;cc:interface&lt;/code&gt; of a composite component. Define the &lt;code&gt;name&lt;/code&gt; attribute which will be used to reference the value holder later. With the &lt;code&gt;targets&lt;/code&gt; attribute you define which of the input fields should use the validation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;cc:interface componentType="IvyComponent"&amp;gt;
    &amp;lt;cc:valueHolder name="fullname" targets="form:firstname form:lastname"&amp;gt;&amp;lt;/cc:valueHolder&amp;gt;  
    &amp;lt;cc:valueHolder name="comment" targets="form:comment"&amp;gt;&amp;lt;/cc:valueHolder&amp;gt;
&amp;lt;/cc:interface&amp;gt;

&amp;lt;cc:implementation&amp;gt;
    &amp;lt;h:form id="form"&amp;gt;
        &amp;lt;p:messages&amp;gt;&amp;lt;/p:messages&amp;gt;
        &amp;lt;p:panelGrid columns="2"&amp;gt;
            &amp;lt;p:outputLabel for="firstname" value="Firstname"&amp;gt;&amp;lt;/p:outputLabel&amp;gt;
            &amp;lt;p:inputText id="firstname" value="#{data.firstname}"&amp;gt;&amp;lt;/p:inputText&amp;gt;
            &amp;lt;p:outputLabel for="lastname" value="Lastname"&amp;gt;&amp;lt;/p:outputLabel&amp;gt;
            &amp;lt;p:inputText id="lastname" value="#{data.lastname}"&amp;gt;&amp;lt;/p:inputText&amp;gt;
            &amp;lt;p:outputLabel for="comment" value="Comment"&amp;gt;&amp;lt;/p:outputLabel&amp;gt;
            &amp;lt;p:inputText id="comment" value="#{data.comment}"&amp;gt;&amp;lt;/p:inputText&amp;gt;
            ...
        &amp;lt;/p:panelGrid&amp;gt;
    &amp;lt;/h:form&amp;gt;
&amp;lt;/cc:implementation&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the Html User Dialog that embeds the component you can now use &lt;code&gt;f:validateRequired&lt;/code&gt; and its &lt;code&gt;for&lt;/code&gt; attribute to reference to the value holder in the interface.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;ic:forms.ConfigureValidationComponent&amp;gt;
        &amp;lt;f:validateRequired for="fullname"&amp;gt;&amp;lt;/f:validateRequired&amp;gt;
        &amp;lt;f:validateLength for="comment" minimum="0" maximum="10"&amp;gt;&amp;lt;/f:validateLength&amp;gt;
&amp;lt;/ic:forms.ConfigureValidationComponent&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;
&lt;br&gt;
Note: This question and answer was &lt;a href="http://blog.xpertivyhacker.ch/2013/03/eingabefelder-und-composite-components-mit-f-validate-validieren.html"&gt;originally posted&lt;/a&gt; by Heinrich Spreiter on his &lt;a href="http://blog.xpertivyhacker.ch/"&gt;Xpert.ivy Hacker blog&lt;/a&gt;. Henry, many thanks to you for your enthusiastic work. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SupportIvyTeam</dc:creator><pubDate>Wed, 09 Oct 2013 09:25:21 -0400</pubDate><guid>https://answers.axonivy.com/questions/23/configure-input-validation-of-components-by-the-caller/24</guid></item></channel></rss>