Navigate after submitting form

UI Components for JSF
Post Reply
laurens
Posts: 14
Joined: 21 Jul 2011, 16:19

24 Jul 2011, 16:44

Hi,

I am trying to submit a form and redirect the user upon successful validation. Here is the relevant part of my XHTML:

Code: Select all

<p:commandButton value="Continue" actionListener="#{registrationController.register()}" update="registrationForm"/>
I have error messages defined for the input fields and when I do not properly enter data, they are properly displayed. When the form does validate however, it is entered in the database and I wish to redirect the user to another page. I have tried setting "action" to not avail. The control should feature an "outcome" property but my IDE insists that property is not defined. Another thread I read here suggests that the property does exist and will properly evaluate but this doesn't work either.

How can I get the command button to redirect the user upon succesful validation?

Thanks!
Java EE 6, JSF 2.0, PrimeFaces 3.0.M2, GlassFish Server 3.1 (Mojarra 2.1)

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

24 Jul 2011, 18:41

I usually do these :

In the button :

Code: Select all

action="#{myBean.doSomething}"

In the bean :

Code: Select all

public String doSomething() {
    // do all the stuffs
    // return "myDestination"; // will jump to myDestination.xhtml in my case
}


laurens
Posts: 14
Joined: 21 Jul 2011, 16:19

24 Jul 2011, 18:59

Thanks, that did it!

What is the difference between the actionListener and an action though?
Java EE 6, JSF 2.0, PrimeFaces 3.0.M2, GlassFish Server 3.1 (Mojarra 2.1)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 54 guests