0

I have a JSF 2.1, Primefaces 4.0 web app where I want to pass some values with GET to the managed bean. For this I have used:

<f:metadata>
  <f:viewParam name="id" value="#{myMB.queueId}" required="true" requiredMessage="This field is required" converter="javax.faces.Integer" converterMessage="Cannot Convert"/>
  <f:event type="preRenderView" listener="#{myMB.init}" />
 </f:metadata>

and the managed bean :

public MyMB{

    private Integer queueId;
    // setters and getters....

public void init(){

  FacesContext fc = FacesContext.getCurrentInstance();
  if(!fc.isPostback()){

   if(fc.isValidationFailed()){
    //if validation fails i want to add here a message - Ideally to keep the validation/convertion errors declared in f:viewParam....

    FacesMessage fm = new FacesMessage(..put validation error message here...)
    fc.add(null,fm);

    try {
     fc.getExternalContext().redirect("viewQueues.xhtml?faces-redirect=true");
    } catch (IOException e) {
     e.printStackTrace();
    }
   }             
  }

 }
}

So i want to send the validation error on the redirected page.
I also tried with :

context.getExternalContext().getFlash().setKeepMessages(true);

but on the redirected page i do not get any message.I have to mention here that on my viewQueues.xhtml i have an tag that should display the errors.
Is there a way to accomplish that ?

Videanu Adrian
  • 972
  • 3
  • 16
  • 41
  • possible duplicate of [Adding faces message to redirected page using ExternalContext.redirect()](http://stackoverflow.com/questions/10595760/adding-faces-message-to-redirected-page-using-externalcontext-redirect) – BalusC Jan 30 '14 at 15:25
  • yap, indeed that is a duplicate of the link specified by you BalusC. – Videanu Adrian Jan 31 '14 at 05:05

0 Answers0