• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Trying to navigate from one page to another in JSF and it won't work

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am a beginner, I am trying to navigate from one page to another when pressing a button but it doesn`t do anything.
This is what I`ve tried:

this is the managed bean class ->


This is the xhtml code from index ->


The page that I am trying to navigate is response.xhtml
 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not to familiar with jsf, but shouldn't you have a controller managing your methods?
Alternatively you could use javascript onclick:"window.open('yourPage', '_self')"
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your action isn't coded properly. It should be a method reference, and not a method call. In other words:


Notice I removed the "()" from the action value.

Your actual action method returns a string value of "response". In JSF version 2, that will cause the JSF navigator to look for the file "/response.xhtml" in your WAR and display it.
 
Tim Holloway
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:I'm not to familiar with jsf, but shouldn't you have a controller managing your methods?
Alternatively you could use javascript onclick:"window.open('yourPage', '_self')"





JSF is the Controller, Daniel! In fact, you never code controller logic in a JSF application, because the top-level Controller is the FacesServlet and the secondary Controllers are part of the various JSF tag implementations.

And, no, you don't navigate in JSF using JavaScript Or, for that matter, by page-based hyperlinks. The page navigation is done by JSF as well. It's directed by the result string returned by the action method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!