2 But my real Problem is using the Wizard with Glassfish v3. Its not working with Glassfish v3. I only see the first dialog of the wizard. When i click on the green "next" button nothing happens. There are no error messages. When the same Wizard works in Tomcat with the same Managed Bean so what could be the Problem that the Wizard is not working in a Glassfish Container? I'm very new to JavaEE and JSF and things like that so maybe i've done something wrong ...
Here is the Wizard i'm using:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
template="/templates/masterlayout.xhtml"
xmlns:f="http://java.sun.com/jsf/core" >
<ui:define name="content">
<h:form style="margin-top: 31px;">
<p:wizard effect="toggle" id="wizard" widgetVar="wizard" height="400" width="600" speed="550">
<p:tab title="Registration Wizard">
<p:panel header="#{msgs.Registration}">
<!-- Output Message -->
<h:messages errorClass="error" styleClass="error"
style="color: red; font-style: italic;" />
<h:outputText id="validationError"
value="#{UserWizard.validateError}"
style="color: red; font-style: italic;"/>
<h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">
<h:outputText value="#{msgs.FirstName}: *" />
<h:inputText value="#{UserWizard.user.name.firstName}"
required="true" label="Firstname" requiredMessage="#{vmsgs.RequireMoreInput}"
valueChangeListener="#{UserWizard.validateName}" immediate="true">
<f:ajax event="blur" render="validationError"/>
</h:inputText>
<h:outputText value="#{msgs.LastName}: *" />
<h:inputText value="#{UserWizard.user.name.lastName}"
required="true" label="Lastname" requiredMessage="#{vmsgs.RequireMoreInput}"
valueChangeListener="#{UserWizard.validateName}" immediate="true">
<f:ajax event="blur" render="validationError" />
</h:inputText>
<h:outputText value="#{msgs.Title}: " />
<h:inputText value="#{UserWizard.user.name.title}">
</h:inputText>
<h:outputText value="#{msgs.Birthday}: *" />
<h:inputText value="#{UserWizard.user.birthday}" required="true" id="wmInput1"
requiredMessage="#{vmsgs.RequireMoreInput}">
<f:convertDateTime pattern="#{fmsgs.DateFormat}" type="date"/>
<p:watermark value="#{fmsgs.DateFormat}" />
</h:inputText>
<h:outputText value="#{msgs.Username}: *" />
<h:inputText value="#{UserWizard.user.username}" required="true"
requiredMessage="#{vmsgs.RequireMoreInput}" immediate="true"
valueChangeListener="#{UserWizard.validateUsername}">
<f:ajax event="blur" render="validationError"/>
</h:inputText>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab title="Registration Wizard">
<p:panel header="#{msgs.AddressDetails}" >
<!-- Output Message -->
<h:messages errorClass="error" style="color: red; font-style: italic;"/>
<h:panelGrid columns="2" columnClasses="label, value">
<h:outputText value="#{msgs.Street}: *" />
<h:inputText value="#{UserWizard.street}" required="true"/>
<h:outputText value="#{msgs.PostalCode}: *" />
<h:inputText value="#{UserWizard.zip}" required="true"/>
<h:outputText value="#{msgs.Country}: *" />
<h:inputText value="#{UserWizard.country}" required="true"/>
<h:outputText value="#{msgs.City}: *" />
<h:inputText value="#{UserWizard.city}" required="true"/>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab title="Registration Wizard">
<p:panel header="#{msgs.ContactInfo}">
<!-- Output Message -->
<h:messages errorClass="error" style="color: red; font-style: italic;"/>
<h:panelGrid columns="2" columnClasses="label, value">
<h:outputText value="#{msgs.Email}: *" />
<h:inputText value="#{UserWizard.email}" required="true" label="Email"
requiredMessage="#{vmsgs.RequireMoreInput}" immediate="true">
<f:validateRegex pattern="^\w+@[a-zA-Z_]+\.([a-zA-Z]{2,3})$"/>
</h:inputText>
<h:outputText value="#{msgs.PhoneNumber}: *" />
<h:inputText value="#{UserWizard.phone}" id="wmInput2" >
<f:validateRegex pattern="^[+]?\d{2,3}\D\d{3,5}\D\d{3,5}(\D\d{1,5})?"/>
<p:watermark value="z.B.: +49-123-12345" />
</h:inputText>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab title="Registration Wizard">
<p:panel header="#{msgs.Password}">
<!-- Output Message -->
<h:messages errorClass="error" style="color: red; font-style: italic;"/>
<h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">
<h:outputText value="#{msgs.Password}: *" />
<p:password value="#{UserWizard.user.password}" minLength="5" goodLabel="#{msgs.GoodPW}"
maxlength="20" required="true" weakLabel="#{msgs.WeakPW}" >
<f:validateLength maximum="20" minimum="5"/>
</p:password>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab title="Registration Wizard">
<p:panel header="#{msgs.Confirmation}">
<p:growl id="growl" sticky="true" showDetail="true"/>
<!-- Output Message -->
<h:messages errorClass="error" style="color: red; font-style: italic;"/>
<h:panelGrid id="confirmation" columns="2">
<h:outputText value="#{msgs.FirstName}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.user.name.firstName}" styleClass="outputLabel"/>
<h:outputText value="#{msgs.LastName}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.user.name.lastName}" styleClass="outputLabel"/>
<h:outputText value="#{msgs.Username}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.user.username}" styleClass="outputLabel"/>
<h:outputText value="#{msgs.Email}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.email}" styleClass="outputLabel"/>
<h:outputText value="#{msgs.PhoneNumber}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.phone}" styleClass="outputLabel"/>
<h:outputText value="#{msgs.Birthday}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.user.birthday}" styleClass="outputLabel">
<f:convertDateTime pattern="#{fmsgs.DateFormat}" type="date"/>
</h:outputText>
<h:outputText value="#{msgs.Title}: " styleClass="outputLabel"/>
<h:outputText value="#{UserWizard.user.name.title}" styleClass="outputLabel"/>
</h:panelGrid>
<p:commandButton style="margin-top: 8px;" value="#{msgs.Submit}" actionListener="#{UserWizard.save}" update="messagepanel"/>
</p:panel>
</p:tab>
</p:wizard>
<p:ajaxStatus>
<f:facet name="start">
<h:graphicImage style="position: absolute; left: 0; top: 0px;" library="images" name="ajax_loading.gif" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
</h:form>
</ui:define>
</ui:composition>
Code: Select all
...
import javax.faces.bean.ManagedBean;
import javax.faces.event.ActionEvent;
import de.nextjack.utils.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIInput;
import javax.faces.event.ValueChangeEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ManagedBean(name = "UserWizard", eager = true)
@ViewScoped
public class UserWizard implements Serializable {
private static Log logger = LogFactory.getLog(UserWizard.class);
private UserEntity user = new UserEntity();
private String street;
private String zip;
private String country;
private String city;
private String email;
private String phone;
private String validateError = "";
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getValidateError() {
return validateError;
}
public void setValidateError(String validateError) {
this.validateError = validateError;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public void save(ActionEvent actionEvent) {
logger.debug("UserWizard.save()");
AddressEntity userAddress = new AddressEntity();
EmailEntity userEmail = new EmailEntity();
PhoneEntity userPhone = new PhoneEntity();
userEmail.setEmail(this.email);
userEmail.setType(0); //TODO
userAddress.setCity(this.city);
userAddress.setCountry(this.country);
userAddress.setStreet(this.street);
userAddress.setZip(this.zip);
userAddress.setType(0); //TODO
// Set Phone Address
this.phone.trim();
if (this.phone.startsWith("+")) {
this.phone = this.phone.substring(1);
}
List<String> phoneParts = new ArrayList<String>();
for (Matcher m = Pattern.compile("[0-9]+").matcher(this.phone); m.find();) {
phoneParts.add(m.group());
}
for (int i = 0; i < phoneParts.size(); i++) {
logger.debug(phoneParts.get(i));
}
if (phoneParts.size() == 4) {
userPhone.setCountryCode(phoneParts.get(0));
userPhone.setAreaCode(phoneParts.get(1));
userPhone.setPhoneNumber(phoneParts.get(2));
userPhone.setPhoneExtension(phoneParts.get(3));
} else if (phoneParts.size() == 3) {
userPhone.setCountryCode(phoneParts.get(0));
userPhone.setAreaCode(phoneParts.get(1));
userPhone.setPhoneNumber(phoneParts.get(2));
userPhone.setPhoneExtension("");
} else {
FacesMessageUtil.createErrorException("Phonenumber invalid!");
}
userPhone.setType(0); //TODO
this.user.getEmailAddresses().add(userEmail);
this.user.getAddresses().add(userAddress);
this.user.getPhoneNumbers().add(userPhone);
this.user.setSince(new Date());
// Persist TODO
// Show Info Message
FacesMessageUtil.addInfoMessage("Welcome: " + this.user.getName().getFirstName());
}
public void validateName(ValueChangeEvent e) {
UIInput nameInput = (UIInput) e.getComponent();
String name = (String) nameInput.getValue();
if (!name.trim().matches("[a-zA-Z]{2,20}")) {
this.validateError = "Notation of the Name is wrong!";
} else {
this.validateError = "";
}
}
public void validateUsername(ValueChangeEvent e) {
UIInput nameInput = (UIInput) e.getComponent();
String name = (String) nameInput.getValue();
if (!name.trim().matches("\\D{5,20}")) {
this.validateError = "Notation of the Username is wrong! (Minimal 5 Chars)";
} else {
this.validateError = "";
}
}
}