You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Andreas Niemeyer <an...@gutzmann.com> on 2008/12/10 11:39:25 UTC

h:messages and redirect in action method: how to reload page?

Hi,

I there a way to force a view reload after a process action was called?

In the view there is a commandButton with an action method. In that 
method a redirect with following context.responseComplete() is called.
The redirect to a servlet works fine, a content type of application/pdf 
   as the content type of the response brings up a "save as" dialog.

The problem I have is a previous custom generated FacesMessage which 
still stays displayed if the validation fails in that method. When the 
next time the validation is successful, the redirect will be done.

The reason is that the action is completed after the response and no 
page reload/refresh is triggered.

How can I do that?

My context is a portal with MyFacesGenericPortlet implementation. Maybe 
is this the place to refresh that page in some way?

I can't change the validation in that backing bean action method,  since 
  the view has 2 t:inputCalendar components and the validation covers 
the correctness of the dates in relation and if the fields are not null. 
Maybe a special validator could help as another solution?

Thank for help in advance.

Kind regards,
Andreas



Re: h:messages and redirect in action method: how to reload page?

Posted by Scott O'Bryan <da...@gmail.com>.
Andraes,

This would go against the faces spec.  Messages should be available for 
all phases of the lifecycle.  Portals have a special case in that they 
have a dual-phased lifecycle where, generally, one expects these 
messages to be present for subsequent renders.

The only thing I could suggest is to maybe come up with other then a 
custom validator would be to write a custom FacesContext decorator that 
overrides either the getFacesMessages object or the AddMessage under 
certain conditions.

Additionally, I think if you set immediate="true" on the command button, 
the even should process before the validations do.

Scott

Andreas Niemeyer wrote:
> Hi,
>
> I there a way to force a view reload after a process action was called?
>
> In the view there is a commandButton with an action method. In that 
> method a redirect with following context.responseComplete() is called.
> The redirect to a servlet works fine, a content type of 
> application/pdf   as the content type of the response brings up a 
> "save as" dialog.
>
> The problem I have is a previous custom generated FacesMessage which 
> still stays displayed if the validation fails in that method. When the 
> next time the validation is successful, the redirect will be done.
>
> The reason is that the action is completed after the response and no 
> page reload/refresh is triggered.
>
> How can I do that?
>
> My context is a portal with MyFacesGenericPortlet implementation. 
> Maybe is this the place to refresh that page in some way?
>
> I can't change the validation in that backing bean action method,  
> since  the view has 2 t:inputCalendar components and the validation 
> covers the correctness of the dates in relation and if the fields are 
> not null. Maybe a special validator could help as another solution?
>
> Thank for help in advance.
>
> Kind regards,
> Andreas
>
>