HTML and CSS Reference
In-Depth Information
Listing 10-14.
final.xhtml Page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml
"
xmlns:ui="
http://java.sun.com/jsf/facelets
"
xmlns:h="
http://java.sun.com/jsf/html
"
>
<ui:composition template="/WEB-INF/templates/main.xhtml">
<ui:define name="title">
#{bundle['application.register.title']}
</ui:define>
<ui:define name="content">
<h:form prependId="false">
<h:panelGrid columns="3">
<h:outputText value="#{bundle['user.zipCode']}"></h:outputText>
<h:inputText id="woeid"
value="#{flowScope.zipCode}"
required="true"
requiredMessage="#{bundle['user.zipCode.validation']}">
</h:inputText>
<h:message for="woeid" styleClass="errorMessage"/>
</h:panelGrid>
<h:commandButton value="#{bundle['application.cancel']}"
immediate="true" action="flowReturn" />
<h:commandButton value="#{bundle['application.back']}"
immediate="true" action="extraInfo"/>
<h:commandButton value="#{bundle['application.finish']}"
action="#{registrationBacking.register}"/> <br/>
<h:messages styleClass="errorMessage"/>
</h:form>
</ui:define>
</ui:composition>
</html>
Finally,
#{flowScope.zipCode}
is binded with the user ZIP code input text. When the user clicks the
"Finish"
CommandButton
, the
register()
method of the
RegistrationBacking
bean is called to register the user in the
application. Listing 10-15 shows the
RegistrationBacking
bean.
Listing 10-15.
RegistrationBacking Bean Class
package com.jsfprohtml5.weather.backing;
import com.jsfprohtml5.weather.model.AppUser;
import com.jsfprohtml5.weather.model.UserExistsException;
import com.jsfprohtml5.weather.model.UserManagerLocal;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;