You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by bg...@comcast.net on 2007/01/29 16:47:04 UTC

Help with Multi-step Wizard "Previous" Button...

(I posted this to the "dev" email list by accident, so I am reposting here with a bit more information...) 

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 "required" 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 "required"/"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 "required"/"immediate" input fields everything works just fine.  Also, if I remove the "required" attribute, then the exception disappears but of course there is no validation which runs when the user subsequently clicks the "Next" button either so that is not really an option.  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)

Re: Help with Multi-step Wizard "Previous" Button...

Posted by Jay Balunas <ba...@gmail.com>.
Hello,

I'm taking a look at the code, but I need to know what version of myfaces
you are using?

My initial thought is that by having the immediate set to true on the
previous button you are bypassing some of the life cycle events (validation
of non-immediate components).  But you have immediate & required input
components so they are validated prior to the previous button.

The validation would fail because they are required.  This is what I'm
suspecting is the issue.  Because with the validation failing - future
events may be nulling out.  But because the command button is also immediate
it may still try to process.  This may be a bug that the immediate input
components fail validation - and the command still tries to execute - but
I'm not sure.

Try to take out the immediate setting on the inputs - it should keep them
from being validated, but still be set in the "update model".

The wiki page on this discusses some other items too.
You have probably already seen this but it contains alot of this
information.
http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works

-Jay

On 1/29/07, bgsdev@comcast.net <bg...@comcast.net> wrote:
>
> (I posted this to the "dev" email list by accident, so I am reposting here
> with a bit more information...)
>
> 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 "required" 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
> "required"/"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
> "required"/"immediate" input fields everything works just fine.  Also, if I
> remove the "required" attribute, then the exception disappears but of course
> there is no validation which runs when the user subsequently clicks the
> "Next" button either so that is not really an option.  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)
>
>