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?

asked 09.10.2013 at 09:05

SupportIvyTeam's gravatar image

SupportIvyTeam ♦♦
accept rate: 77%

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.

More precisely, you can use cc:valueHolder in a cc:interface of a composite component. Define the name attribute which will be used to reference the value holder later. With the targets attribute you define which of the input fields should use the validation.

<cc:interface componentType="IvyComponent">
    <cc:valueHolder name="fullname" targets="form:firstname form:lastname"></cc:valueHolder>  
    <cc:valueHolder name="comment" targets="form:comment"></cc:valueHolder>

    <h:form id="form">
        <p:panelGrid columns="2">
            <p:outputLabel for="firstname" value="Firstname"></p:outputLabel>
            <p:inputText id="firstname" value="#{data.firstname}"></p:inputText>
            <p:outputLabel for="lastname" value="Lastname"></p:outputLabel>
            <p:inputText id="lastname" value="#{data.lastname}"></p:inputText>
            <p:outputLabel for="comment" value="Comment"></p:outputLabel>
            <p:inputText id="comment" value="#{data.comment}"></p:inputText>

In the Html User Dialog that embeds the component you can now use f:validateRequired and its for attribute to reference to the value holder in the interface.

        <f:validateRequired for="fullname"></f:validateRequired>
        <f:validateLength for="comment" minimum="0" maximum="10"></f:validateLength>

Note: This question and answer was originally posted by Heinrich Spreiter on his Xpert.ivy Hacker blog. Henry, many thanks to you for your enthusiastic work.


answered 09.10.2013 at 09:25

SupportIvyTeam's gravatar image

SupportIvyTeam ♦♦
accept rate: 77%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 09.10.2013 at 09:05

Seen: 2,198 times

Last updated: 09.10.2013 at 09:25