JSF Navigation issue Facelets and Beans
Posted
by ortho
on Stack Overflow
See other posts from Stack Overflow
or by ortho
Published on 2010-03-14T12:22:10Z
Indexed on
2010/03/14
12:25 UTC
Read the original article
Hit count: 502
Hi,
I have an issue with navigation in my simple jsf system.
I have MainBean that has two methods: public String register() and public String login().
I have played with faces-config.xml for several hours and I feel like I miss something very important because I think like I have tried all simple solutions so far :).
I have added the mysql connector (jdbc) to Tomcat's lib folder and I am able to register the table to mySQL databse. It even allows my users to log in to the page. The only problem is that I can't use navigation in any other page than login.xhtml. Seems like navigation is only active on this one. I tried to use * but is no joy. I am sure that there is a simple fix for that and someone will come up with correct solution soon. Let's skip all the mysql part and try to fix the navigation issue please.
faces-config.xml:
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
com.sun.facelets.FaceletViewHandler
mainBean
dk.itu.beans.MainBean
session
registerBean
dk.itu.beans.RegisterBean
session
/login.xhtml
success
/welcome.xhtml
failure
/login_failed.xhtml
sign
/register.xhtml
/login_failed.xhtml
back
/login.xhtml
Here the last navigation-rule from login_failed.xhtml does not work at all.
login.xhtml (which is the main - starting view):
login_failed.xhtml:
Here I tried many options. I used action="#{mainBean.register})" method that returns "sign" string and none of these worked. There is one more file (not specified in faces-config.xml file, because did not work either - but going from login.xhtml by button works fine. I tried to manage navigation from login_failed.xhtml first, then I will apply the same rool for registration to come back to login page when customer registers his nick name).
register.xhtml:
Basicaly mainBean.register now calls the database and returns string, but obviously it doesn't navigate to any view (but gives an entry to database).
I believe it is simple fix for most of the experienced web developers and any help will be greately appreciated.
I use eclipse, tomcat 6 and Widows Vista if that helps :)
Thank you in advance.
Kindest regards.
© Stack Overflow or respective owner