| |
PDF
|
ICEfaces Online Reference |
Putting the TimeZoneBean in Charge
First we change timezone.xhtml, to use Facelets mechanisms, to be more dynamic.
1. Add namespace declarations for Facelets components, and Facelet's implementation of JSTL components and functions:
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ice="http://www.icesoft.com/icefaces/component" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jstl/core" xmlns:fn="http://java.sun.com/jsp/jstl/functions">2. Pull out the headerDiv section, and put it into header.xhtml to demonstrate parameterized inclusion:
<ui:include src="/header.xhtml"> <ui:param name="sectionName" value="header"/> </ui:include>3. Replace the six commandButtons and selectBooleanCheckboxes with JSTL forEach sections, that are populated by bean properties using JSF expression language bindings.
Notice how even the IDs for the commandButtons and selectBooleanCheckboxes components come from the bean so there are no duplicate definitions to keep in sync. One important thing to remember is that JSTL forEach sections are evaluated at component build time once, and not for every render. So, with this example, one cannot change the map or number of check boxes with every clock tick, as one can with the table below it.
<h:panelGrid columns="#{fn:length(timeZoneBean.allTimeZoneList)}" width="100%" cellpadding="0" cellspacing="0"> <c:forEach var="allTimeZone" items="#{timeZoneBean.allTimeZoneList}"> <h:commandButton id="#{allTimeZone.mapCommandButtonId}" image="#{allTimeZone.imagePath}" actionListener="#{timeZoneBean.listen}" style="border: 0px;"/> </c:forEach> <c:forEach var="allTimeZone" items="#{timeZoneBean.allTimeZoneList}"> <ice:selectBooleanCheckbox id="#{allTimeZone.checkboxId}" required="false" immediate="true" value="#{allTimeZone.currentlyShowing}" valueChangeListener="#{timeZoneBean.timeZoneChanged}"/> </c:forEach> </h:panelGrid>
|
Copyright 2005-2006. ICEsoft Technologies, Inc. http://www.icesoft.com |