Thank you!
This <h:commandLink works:
...
<h:form>
<h:outputText value="Test2 stateBean = #{stateBean}, #{stateBean.logonName}"/>
<h:commandButton action="#{testTestBean.submit}" value="Submit"/>
<h:commandLink action="#{testTestBean.submit}" value="Test3"/>
</h:form>
Dick
-----Original Message-----
From: Craig McClanahan [mailto:[EMAIL PROTECTED]
Sent: Tue 1/30/2007 12:58 PM
To: [email protected]
Cc:
Subject: Re: saveState works great ... except when I use <h:outputLink
On 1/30/07, Dick Starr <[EMAIL PROTECTED]> wrote:
>
> I need to save separate state information for each open Firefox tab. Since
> Firefox shares the same session between all tabs I need to dream up another
> way besides using session. I am using Firefox 2.0.
>
> I have been experimenting with "<t:saveState" and find it works great when
> I submit a form and go to another form via a rule, but I lose my state when
> I execute an "<h:outputLink". I am using Shale 1.1.0 (yesterday's
> snapshot) with the included Tiles. I have created a simple example,
> described below.
>
> The neat part of this method is that I have a single StateBean for all my
> "tab state" data and a single reference to saveState in my Tiles header. I
> can merrily go through my three test jsp forms for each tab with different
> "tab state" forever without losing my "tab state" (as test3 branches back to
> test1). But in my test2 I also have a "<h:outputLink" that goes to test3,
> and if I click this link I lose my state.
>
> It would be great if this could work. Any help would be greatly
> appreciated.
The <h:outputLink> component does an HTTP GET to the new URL, instead of the
usual POST, so *all* JSF state is lost when you do that. Have you tried it
with <h:commandLink> instead?
Craig
Here are my test details.
>
> For my test I am using the logonName in my StateBean. I added this logic
> to my logon Class:
>
> stateBean = new StateBean();
> stateBean.setLogonName(this.getLogonName());
> setStateBean(stateBean);
> String ab = "#{requestScope.stateBean}";
> getApplication().createValueBinding(ab).setValue(facesContext, stateBean);
>
> My Tiles header.jsp has the saveState:
> ...
> <t:saveState id="stateBeanSS" value="#{stateBean}"/>
> ...
>
> Here are the rules:
>
> <navigation-rule>
> <from-view-id>/systemLogon.jsp</from-view-id>
> <navigation-case>
> <from-outcome>success</from-outcome>
> <to-view-id>/testTest1.jsp</to-view-id>
> </navigation-case>
> </navigation-rule>
>
> <navigation-rule>
> <from-view-id>/testTest1.jsp</from-view-id>
> <navigation-case>
> <from-outcome>success</from-outcome>
> <to-view-id>/testTest2.jsp</to-view-id>
> </navigation-case>
> </navigation-rule>
>
> <navigation-rule>
> <from-view-id>/testTest2.jsp</from-view-id>
> <navigation-case>
> <from-outcome>success</from-outcome>
> <to-view-id>/testTest3.jsp</to-view-id>
> </navigation-case>
> </navigation-rule>
>
> <navigation-rule>
> <from-view-id>/testTest3.jsp</from-view-id>
> <navigation-case>
> <from-outcome>success</from-outcome>
> <to-view-id>/testTest1.jsp</to-view-id>
> </navigation-case>
> </navigation-rule>
>
> And here are my jsps:
>
> testTest1.jsp
> ...
> <h:form>
> <h:outputText value="Test1 stateBean = #{stateBean}, #{
> stateBean.logonName}"/>
> <h:commandButton action="#{testTestBean.submit}" value="Submit"/>
> </h:form>
>
> testTest2.jsp
> ...
> <h:form>
> <h:outputText value="Test2 stateBean = #{stateBean}, #{
> stateBean.logonName}"/>
> <h:commandButton action="#{testTestBean.submit}" value="Submit"/>
> </h:form>
>
> <h:outputLink value="#{facesContext.externalContext.requestContextPath
> }/testTest3.faces">
> <h:outputText value="Test3"/>
> </h:outputLink>
>
> testTest3.jsp
> ...
> <h:form>
> <h:outputText value="Test3 stateBean = #{stateBean}, #{
> stateBean.logonName}"/>
> <h:commandButton action="#{testTestBean.submit}" value="Submit"/>
> </h:form>
>
> Dick
>
>
>
>
>
>
>
>
>