Java EE 7 JSF Facelet h:commandButton action redirect to page -


hi have java ee 7 application in netbeans 8.0.2 running on glassfish 4.01

i use @managedbean @sessionscoped controller usercontroller.java

i have index.xhtml facelet , signup.xhtml facelet

in index.xhtml facelet have

<h:commandbutton value="sign up" action="#{usercontroller.signup()}"></h:commandbutton> 

which calls function public string signup() { in usercontroller.java

in function return return pages.sign_up_page; renders face let signup.xhtml there have form fill in user data such user name email , password.

the first thing when return pages.sign_up_page; page signup.xhtml gets rendered in url still stands .../faces/index.xhtml

in signup.xhtml have the

<h:commandbutton value="create user" action="#{usercontroller.createnewuser()}"></h:commandbutton> 

then in public string createnewuser() function return return pages.user_action_overview; renders page overview.xhtml url .../faces/signup.xhtml

which leads bigger problem when refresh page ( overview page shows me data of new signedup user ) send post request again signup() same user same post parameters.

what need if render page, right url displayed ( on of page rendered ) , if refresh page not again old post request gets send.

the jsf perforns post based request, why url not change. solution add faces-redirect parameter query sttring this

public string signup () {       //some processing here       return pages.signup_page + "?faces-redirect=true";  } 

this force redirect sign page after post request completed. result, browser's address bar show address of current page, i. e. sign page


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -