jsf 2 - Navigating to another page JSF -


i wrote jsf application, app inserts data mysql database , shows of inserted details in page.

i successful in inserting values database, unable redirect other page after writing navigation rule.

my action code

<div align="center"><p:commandbutton label="submit"  action="#{userdata.add}"   align="center" ajax="false" /></div> 

navigation rule

<managed-bean>         <managed-bean-name>userdata</managed-bean-name>         <managed-bean-class>userdata.userdata</managed-bean-class>         <managed-bean-scope>session</managed-bean-scope>     </managed-bean>     <navigation-rule>         <display-name>home.xhtml</display-name>         <from-view-id>/home.xhtml</from-view-id>         <navigation-case>             <to-view-id>/badge.xhtml</to-view-id>         </navigation-case>     </navigation-rule> 

if write face-redirect true showning error, or if write action other page not inserting values database.

stop reading jsf 1.x resources , rid of jsf 1.x-style <managed-bean> , <navigation-rule> entries in faces-config.xml.

the proper jsf 2.x approach action="#{userdata.add}" below:

@managedbean @viewscoped public class userdata {      public string add() {         // ...          return "/badge.xhtml?faces-redirect=true";     }  } 

no additional xml mess needed. no action listeners.

links jsf 2.x tutorials/books can found in our jsf wiki page.

see also:


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -