Where does ID get set? According to your code, your avalue is getting
the value from the MyBean's ID property. Without knowing how that ID
is getting its value from, it is impossible to say what is going on.

Only the component tree is serialized into the state. The session
managed beans live on the server in the HttpSession and are never part
of the component tree (unless you use something like t:saveState).
Therefore, you have to realize that when the user clicks back, your
session state bean is still at the same state as it was, only when
they submit the form is the bean updated.

So for example:
public class MyBean
{
 private int count = 0;
 public void hit(ActionEvent evt) { count++; }
 public int getCount() { return count; }
}

Navigation: page A goes to page B which goes to Page C
Pages A-C all look the same:
<t:commandLink
 value="next"
 actionListener="#{myBean.hit}"
 action="next" />
<t:outputText value="#{myBean.count}" />

Use case: user clicks on next 2 times (A->B->C). Then user clicks back
2x (A). Then user clicks next again.

Here is the output of the output text in:
A -> 0
B -> 1
C -> 2
(back)
(back)
A -> 0
B -> 3

I didn't test it, the only differnece is that the 2nd "A" may show 2
instead (depends on how the component and browser caching loads the
page. If the page expires, I think 2 will show, if the browser brings
back the cached page, 0 will show).

The point is that B should be 3 though, not 1. This is because the
bean is the same across all pages, it is divorced from the component
tree.

Hope that helps (please someone correct me if I am wrong)
-Andrew






On 8/2/06, Michael Heinen <[EMAIL PROTECTED]> wrote:
Yes, I forgot to mention.
MyBean has session scope.


The updateActionListener calls just a simple setter:
public void setAvalue(String bla) {
        this.avalue = bla;
}

The action (simplified, I just don't want to post not relevant
information)
public String doIt() {
        String mystring = this.getAvalue();  //just simple getter
        ...
}

The problem is that getAvalue returns 1 instead of 2 after clicking back
button.

getId() and setId() are also simple getters and setters without any
additional logic.

Michael

-----Original Message-----
From: Andrew Robinson [mailto:[EMAIL PROTECTED]
Sent: Mittwoch, 2. August 2006 17:20
To: MyFaces Discussion
Subject: Re: Browser Back Button

What is the code in the Java? What scope is MyBean?

On 8/2/06, Michael Heinen <[EMAIL PROTECTED]> wrote:
>
>
>
>
> I have sometimes a problem with the Browser Back button.
>
> My app runs with server side state saving and
NUMBER_OF_VIEWS_IN_SESSION is
> set to 20.
>
>
>
> I use an immediate command link with an updateActionListener that
updates an
> iframe.
>
> <h:commandLink action="#{MyBean.doIt}" immediate="true"
target="iframe1">
>
>             <t:updateActionListener property="#{MyBean.avalue}"
> value="#{MyBean.id"/>
>
> </h:commandLink>
>
>
>
> ClickFlow:
>
> Start                 Page1:   MyBean.avalue=1
>
> Navigate to        Page2:   MyBean.avalue=2
>
> Click doIt on Page2: MyBean.avalue=2
>
> Click BackButton --> goes one page back in the iframe
>
> Click BackButton --> Page1 is redisplayed (so far so good)
>
> Click doIt on page1: MyBean.avalue=2
>
>
>
> But MyBean.avalue should be 1 in this case!!!
>
>
>
> I thought that the BackButton is supported with server side state
saving and
> NUMBER_OF_VIEWS_IN_SESSION.
>
> What can I do in this szenario?
>
> Is this always working this way or is this caused by the immediate
command
> link?
>
> I cannot change to client side state saving!
>
>
>
> I tried also to replace the iframe with an ajax update but the back
button
> effect is the same.
>
> Any help is appreciated
>
>
>
> Michael





Reply via email to