Krishna
Krishna

Reputation: 7294

Creating new context in JSF

HI,

We are navigating, for example from page A to C. When we are in page C, user clicks the back button of the browser and goes back to the previous application which is used for invoking the page A. Again, when user trying to invoke the page A, he directly navigating to the page C, not page A.

Here what I felt the problem was, may the JSF context is taking to the current page. How we can solve this problem. When every user clicks to enter page A, he should be able to see the page A.

Anyone has the solution for my problem.

Upvotes: 0

Views: 834

Answers (2)

BalusC
BalusC

Reputation: 1108982

Do not use HTTP POST requests for navigation, but use HTTP GET requests.

In JSF terms, don't use <h:commandLink> for navigation, but use <h:outputLink>, <h:link> or even plain vanilla <a>.

Upvotes: 1

Renan
Renan

Reputation: 741

Just check the nav. rules

Examples

JSF 2

<h:commandButton action="/PageA.xhtml" or action="/PageA.xhtml?faces-redirect=true" ... />

JSF 1 you need to configure faces-config.xml

faces-config.xml:

<navigation-rule>
   <from-view-id>Page.xhtml</from-view-id>

   <navigation-case>
      <from-outcome>goToA</from-outcome>
      <to-view-id>/PageA.xhtml</to-view-id>
   </navigation-case>

   <navigation-case>
      <from-outcome>goToC</from-outcome>
      <to-view-id>/PageC.xhtml</to-view-id>
   </navigation-case>
</navigation-rule>

<from-view-id> = the page whos "firing" the nav. rule. Use * to make it global (<from-view-id>*</from-view-id>)

<from-outcome> = navigation string

<to-view-id> = target page

Page.xhtml:

<h:commandButton action="goToA" or action="goToC" ... /> <!-- Navigation string -->

Action should be the nav string (from-outcome) or a method wich returns a valid nav. string, example:

Bean

//Returns the nav. string
public String navA() { return "goToA"; }
public String navC() { return "goToC"; }

Page

<h:commandButton action="#{bean.navA}" or action="#{bean.navC}" ... />

Upvotes: 1

Related Questions