Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to bind a complex object to a composite component

cmathrusseDec 16 2010
I'm using JSF2 and having an issue binding an object (EL Expression) as a parameter to my composite component.
I have written a composite component (not very complex) that will display a drop-down list of countries and should bind the selection to a provided target bean.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">


<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="label" required="true" />
<composite:attribute name="requiredMessage" required="true"/>
<composite:attribute name="target" required="true" type="com.mycompany.entity.Country"/>
</composite:interface>

<!-- IMPLEMENATION -->
<composite:implementation>
<h:panelGrid columns="2">

<h:outputLabel for="country-list" value="#{cc.attrs.label}"/>
<h:panelGrid id="country" columns="1" styleClass="select-one-menu-panel" >

<h:selectOneMenu id="country-list"
enabledClass="select-one-menu-enabled" disabledClass="select-one-menu-disabled"
layout="pageDirection"
value="#{cc.attrs.target}"
required="true" requiredMessage="#{cc.attrs.requiredMessage}"
>

<f:selectItem itemLabel="#{msgs['label.pleaseSelect']}" itemValue="" />
<f:selectItems value="#{countryController.countries}" />
<a4j:ajax />
</h:selectOneMenu>

<a4j:outputPanel id="country-list-error-panel" ajaxRendered="true">
<h:message id="country-list-error" for="country-list" style="color:red"/>
</a4j:outputPanel>
</h:panelGrid>

</h:panelGrid>
</composite:implementation>
</html>


I want to be able to use the composite component in the following way:

<util:country-select
label="#{msgs['label.countryOfBirth']}"
requiredMessge="#{msgs['error.birthCountryRequired']}"
target="#{participant.countryOfBirth}"/>


When I load the page everything renders correctly, but when I select an item from the drop-down I get a validation error.

apply-form:j_idt77:country-list: Validation Error: Value is not valid

I know that it must be something with the way that I have the parameters defined but I simply can't find any information to help me figure this out.
Any light that you might be able to she on this would be greatly appreciated.

Thank you for the help...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2011
Added on Dec 16 2010
0 comments
252 views