Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSF a4j:commandLink isn't working after redirect

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I write my View presentor using JSF and have some troubles.
I have 2 commandLinks which must change view (it will be realized later). They call redirect-method. Adress bar is chaged from "http://localhost:8080/frontoffice-jsf/main.jsf"; "to http://localhost:8080/frontoffice-jsf/main.jsf#1".
After that all two links are inactive (they actions are not called). What can I do? I need to use them more than 1 time.





Please don't watch on String add - it isn't right. Just I tryed to debug it. Problem only in redirection
 
Saloon Keeper
Posts: 22276
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any time you resort to a class in the javax.faces package set that isn't a Model class, there's a good chance you're not doing things right, since JSF is not designed to require much JSF-specific code.

The primary purposes of a JSF action method are to allow action to be taken on the data held in the updated backing bean and connected objects, and to decide where to go next. Originally, the actual "next" was defined abstractly in a faces-config navigation rule that bound a symbolic navigation rule name to an actual target URL. JSF2 allows bypassing the symbolic connection and specifying the target URL directly, which is a mixed blessing.

Navigation target URLs are not the same thing as general URLs. They never include the protocol specifier (http:, https:), hostname, port, or web application context name. They are relative to the root of the application context. Likewise, they cannot include URL parameters "?name=value&name=value", because, as I have said many times before, JSF doesn't expect/want you passing parameters back and forth between Model and View, it expects the Model to retain the parameters. They cannot include page-relative anchor links. The URL extension (for example, ".jsf") is optional. About the only decoration that is allowable is the "#redirect" option that corresponds to the <redirect/> element on the faces-config.xml navigation rule.

I can do something more or less equivalent to what you have illustrated with POJO code, as I will illustrate. Details may vary, since I probably don't have full understanding of what you want, but at least I hope it will serve as a guideline.

First, I'm going to postulate that you have your navigation map as a Session or Application scope Managed Bean named navMap and that the key in the map is the display name and that the value is the View target navigation URL. The map is a custom of Map and presents a "rows" property which presents model name/value row class objects, because although I could probably do this against a generic Map, I'd have to RTFM and I want to keep this simple/easy.

Here goes:


Now the model essentials:

 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic