I am implementing a multi-step registration wizard which functions as follows:
1. Uses one backing bean per wizard page
2. Uses Tomahawk saveState to save model data between pages
3. "Next" button performs full-validation on all required and critical input
fields for each page
4. "Previous" button navigates back to the previous wizard page, without
performing any validation. However, if the user has entered any values on the
page, it pushes those values into the model/backing bean before navigating to
the previous page
I am using the "immediate" attribute on the input components, along with the
"immediate" attribute on the "Previous" commandButton component, as well as an
actionListener which invokes a method to processUpdates() on the UIViewRoot
when the button is clicked. All this works fine, the user's entries are saved
to the model and restored when the come back to the page (even though they have
not been validated yet), and validation occurs when they hit the "Next" button
on every page.
Here's my problem though:
When the user navigates to a new page and does not enter ANY data for the
"immediate" input fields, then clicks the "Previous" button a Null Pointer
exception is thrown during the applyRequestValues() phase (see stack trace
below). However, if they actually enter data into each of the "immediate"
input fields everything works just fine. Any ideas? I have set breakpoints in
many places, but cannot figure out exactly why this exception is being thrown
or how to get around it.
javax.servlet.ServletException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:156)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
root cause
java.lang.NullPointerException
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:112)
javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:136)
org.apache.myfaces.lifecycle.LifecycleImpl.applyRequestValues(LifecycleImpl.java:219)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:71)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)