<h:outputText value="#{msg['label_contact_last_name']}: "/>
<h:outputText value="#{contactBean.contact.lastName}"/>
<br/>
<h:outputText value="#{msg['label_contact_birth_date']}: "/>
<h:outputText value="#{contactBean.contact.birthDate}">
<f:converter converterId="jodaDataTimeConverter" />
</h:outputText>
</h3>
<p:pickList value="#{contactBean.hobbies}"
var="hobby"
itemLabel="#{hobby.hobbyId}"
itemValue="#{hobby.hobbyId}"
converter="hobby"/>
<p:toolbar>
<p:toolbarGroup align="left">
<p:commandButton value="Next" action="next"/>
<p:commandButton value="Back" action="back"/>
<p:commandButton value="Exit" action="exit" immediate="true"/>
</p:toolbarGroup>
</p:toolbar>
</h:form>
</ui:define>
</ui:composition>
In Listing 18-18, note the use of the PrimeFaces' PickList component for selecting hobbies. The
PickList is bound to the hobbies property of the ContactBean class, which is of the DualListModel class.
The available hobbies are stored in the source property, while the selected hobbies are stored in the
target property. For the hobby property, we also need to implement a custom converter for
transformation between the String and Hobby classes. Listing 18-19 shows the converter class.
Listing 18-19. The Hobby Converter Class
package com.apress.prospring3.ch18.web.converter;
import
javax.faces.component.UIComponent;
import
javax.faces.context.FacesContext;
import
javax.faces.convert.Converter;
import
javax.faces.convert.FacesConverter;
import com.apress.prospring3.ch18.domain.Hobby;
@FacesConverter("hobby")
public class HobbyConverter implements Converter {
@Override
public Object getAsObject(FacesContext ctx, UIComponent component, String value) {
return new Hobby(value);
}
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home