Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF a4j:commandLink isn't working after redirect

 
Gregory Androsov
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
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE 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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic