I have a problem with using primeface's wizard component and the core selectOneRadio. My signup page looks like this
<ui:define name="content">
<f:view>
<h:form id="signUpForm">
<p:wizard widgetVar="wiz" flowListener="#{SignUpBean.onFlowProcess}">
<p:tab id="personalTab" title="">
<p:panel header="Personal">
<h:messages/>
<h:panelGrid id="panel1" columns="2">
<h:outputLabel for="firstName" value="First Name"/>
<h:inputText id="firstName" value="#{SignUpBean.firstName}" required="true"/>
<h:outputLabel for="lastName" value="Last Name"/>
<h:inputText id="lastName" value="#{SignUpBean.lastName}" required="true"/>
<h:outputLabel for="email" value="Email"/>
<h:inputText id="email" value="#{SignUpBean.email}" required="true">
<f:validator validatorId="emailValidator"/>
</h:inputText>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="passwordTab" title="">
<p:panel header="Password">
<h:messages/>
<h:panelGrid id="panel2" columns="2">
<h:outputLabel for="password" value="Password"/>
<h:inputSecret id="password" value="#{SignUpBean.password}" required="true"/>
<h:outputLabel for="retypePass" value="Retype Password"/>
<h:inputSecret id="retypePass" value="#{SignUpBean.retypePassword}" required="true"/>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="groupTab" title="">
<p:panel header="Group">
<h:messages/>
<h:panelGrid id="panel3" columns="2">
<h:outputLabel for="radioGroup" value=""/>
<h:selectOneRadio id="radioGroup" value="#{SignUpBean.join}">
<f:selectItem itemValue="true" itemLabel="Join existing group"/>
<f:selectItem itemValue="false" itemLabel="Create new group"/>
</h:selectOneRadio>
Group Name
<h:inputText id="group" value="#{SignUpBean.group}" required="true"/>
Group Password
<h:inputSecret id="groupPass" value="#{SignUpBean.groupPass}" required="true"/>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="confirmTab" title="">
<p:panel header="Confirm">
<h:messages/>
<p:growl id="signUpGrowl" sticky="false" life="1000" showDetail="true" />
<h:panelGrid id="panel4" columns="4" cellpadding="5">
Firstname:
<h:outputText value="#{SignUpBean.firstName}"/>
Lastname:
<h:outputText value="#{SignUpBean.lastName}"/>
Email:
<h:outputText value="#{SignUpBean.email}"/>
Groupname:
<h:outputText value="#{SignUpBean.group}"/>
<h:panelGroup style="display:block; text-align:center">
<p:commandButton value="Submit" action="#{SignUpBean.signUp}" update="signUpGrowl"/>
</h:panelGroup>
</h:panelGrid>
</p:panel>
</p:tab>
</p:wizard>
</h:form>
</f:view>
</ui:define>
And the signUpBean like this:
@ManagedBean(name="SignUpBean")
@SessionScoped
public class SignUpBean {
private String groupName, groupPass, firstName, lastName,
email, password, retypePassword;
private boolean join;
private boolean skip;
@EJB
private MessageBeanRemote messageBean2;
/** Creates a new instance of SignUpBean */
public SignUpBean() {
this.skip = false;
this.join = true;
}
/**
* Signs up a user with all the data given on the signUp.jsf page.
* If everything is ok then a confirmation email is generated and send
* to the new user.
* @return Either signUpSucces or signUpFailure
*/
public void signUp() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
// Boolean to decide if the data should be commited or not.
boolean commitOK = true;
UserHelper uh = new UserHelper();
BasicUser user = uh.getByEmail(this.email);
GroupHelper gh = new GroupHelper();
Group group = gh.getByName(this.groupName);
// If email does not already exist
if(user == null) {
user = new BasicUser();
user.setEmail(this.email);
user.setFirstName(this.firstName);
user.setLastName(this.lastName);
if(this.password.equals(this.retypePassword)) {
user.setPassword(password);
}
else {
commitOK = false;
FacesMessage fm = new FacesMessage("Passwords does not match");
FacesContext.getCurrentInstance().addMessage(null, fm);
}
}
else {
commitOK = false;
FacesMessage fm = new FacesMessage("Email does already exist");
FacesContext.getCurrentInstance().addMessage(null, fm);
}
// If it's a joiner to a group
if(this.join) {
// Is it the right groupPassword and groupName
if(group != null && group.getGroupPassword().equals(this.groupPass)) {
user.setGroup(group);
}
else {
commitOK = false;
FacesMessage fm = new FacesMessage("Wrong group name or password");
FacesContext.getCurrentInstance().addMessage(null, fm);
}
}
else {
if(group == null) {
group = new Group();
group.setGroupName(this.groupName);
group.setGroupPassword(this.groupPass);
user.setGroup(group);
}
else {
commitOK = false;
FacesMessage fm = new FacesMessage("Group does already exist");
FacesContext.getCurrentInstance().addMessage(null, fm);
}
}
//--- IF EVERYTHING OK THEN UPDATE THE DB ---//
if(commitOK) {
session.save(group);
session.save(user);
tx.commit();
session = HibernateUtil.getSessionFactory().getCurrentSession();
tx = session.beginTransaction();
BasicUser newUser = uh.getByEmail(email);
int id = newUser.getId();
MobileUser mobile = new MobileUser();
mobile.setId(id);
mobile.setUseWhen("Lost");
StatUser stats = new StatUser();
stats.setId(id);
stats.setRating("");
DateUser dates = new DateUser();
dates.setId(id);
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
dates.setMemberSince(date);
dates.setLastLogin(date);
session.save(stats);
session.save(mobile);
session.save(dates);
tx.commit();
//----- SEND CONFIRMATION EMAIL ----------//
BasicUser emailUser = uh.getByEmail(email);
MailGenerator mailGenerator = new ConfirmationMailGenerator(emailUser);
try {
StringWriter plain = mailGenerator.generatePlain();
StringWriter html = mailGenerator.generateHTML();
messageBean2.sendMixedMail(email, "WMC: Account Info", plain.toString(),
html.toString());
}
catch (Exception ex) {
Logger.getLogger(SignUpBean.class.getName()).log(Level.SEVERE, null, ex);
}
FacesMessage msg = new FacesMessage("Successful", "Welcome :" + this.getFirstName());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
//---- DO NOTHING ----//
}
public String onFlowProcess(FlowEvent event) {
if (skip) {
skip = false; //reset in case user goes back
return "confirm";
} else {
return event.getNewStep();
}
}
... getters and setters
}
I know it is a bad signup method and it will be changed later. When i reach the last tab and submit I get this error:
When I debug I see that the join variable is either true or false not null. What is it complaining about?