You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stéphane Poirier <st...@gmail.com> on 2007/07/12 16:59:12 UTC
[Trinidad] State saving between applications
Hi,
I have 2 different Trinidad applications interacting. Beeing different
applications, I'm using ExternalContext.sendRedirect() to go from an
application to another. It works well (tho it's not very clean) and the
state of components is the same when the page is revisited (beans are in
session scope). My problem is when I'm using AJAX with partialTrigers. If
I'm using a redirect in an action after AJAX, the state will not be saved (I
understand that it's the normal behavior). Still, I want to solve this
problem. Any ideas?
I read that ViewHandler could possibly help... is that right? If so, an
implementation hint would be greatly appreciated! :-)
Thanks in advance!
Re: [Trinidad] State saving between applications
Posted by Stéphane Poirier <st...@gmail.com>.
Great! Works perfectly!
Thank a lot for your help!
On 7/14/07, Adam Winer <aw...@gmail.com> wrote:
>
> Ah, yes. Well, Trinidad offers a ChangeManager feature
> that can be used to persist component state. What you'd
> do is add a rangeChangeListener to the table like so:
>
> public void persistRangeChange(RangeChangeEvent event)
> {
> // Create the change
> AttributeComponentChange change =
> new AttributeComponentChange("first", event.getNewStart());
>
> // Get some contexts
> FacesContext fc = FacesContext.getCurrentInstance();
> RequestContext rc = RequestContext.getCurrentInstance();
>
> // Register it for the table
> rc.getChangeManager().addComponentChange(
> fc, event.getComponent(), change);
> }
>
> Make sure you have:
> <context-param>
> <param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE
> </param-name>
> <param-value>session</param-value>
> </context-param>
>
> in your web.xml to enable the feature.
>
> -- Adam
>
> On 7/12/07, Stéphane Poirier <st...@gmail.com> wrote:
> > Sorry, my description wasn't completely right as I re-read it. I'll take
> it
> > over correctly with an example :
> >
> > I'm in "JSP 1" which contains a <tr:table> (with it's default navigation
> > menu) and a <tr:selectOneChoise>. Changing the selectOnChoise changes
> the
> > table data using partialTriggers and an action in the backing bean. At
> that
> > point, if I redirect to another application and come back, JSP 1 will
> > restore to the state it was.
> >
> > However, if I use the table navigation to see the third page of data
> (for
> > example) then redirect to another application and come back, the JSP 1
> will
> > show the first page of data instead of the third. That is my problem.
> >
> >
> >
> >
> > On 7/12/07, Adam Winer <aw...@gmail.com> wrote:
> > > There shouldn't be any difference between redirecting
> > > after AJAX or redirecting after a standard request.
> > > The state should be the same. I'm not sure
> > > what you're describing.
> > >
> > > -- Adam
> > >
> > >
> > > On 7/12/07, Stéphane Poirier <st...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I have 2 different Trinidad applications interacting. Beeing
> different
> > > > applications, I'm using ExternalContext.sendRedirect() to go from an
> > > > application to another. It works well (tho it's not very clean) and
> the
> > > > state of components is the same when the page is revisited (beans
> are in
> > > > session scope). My problem is when I'm using AJAX with
> partialTrigers.
> > If
> > > > I'm using a redirect in an action after AJAX, the state will not be
> > saved (I
> > > > understand that it's the normal behavior). Still, I want to solve
> this
> > > > problem. Any ideas?
> > > >
> > > > I read that ViewHandler could possibly help... is that right? If so,
> an
> > > > implementation hint would be greatly appreciated! :-)
> > > >
> > > > Thanks in advance!
> > > >
> > >
> >
> >
>
Re: [Trinidad] State saving between applications
Posted by Adam Winer <aw...@gmail.com>.
Ah, yes. Well, Trinidad offers a ChangeManager feature
that can be used to persist component state. What you'd
do is add a rangeChangeListener to the table like so:
public void persistRangeChange(RangeChangeEvent event)
{
// Create the change
AttributeComponentChange change =
new AttributeComponentChange("first", event.getNewStart());
// Get some contexts
FacesContext fc = FacesContext.getCurrentInstance();
RequestContext rc = RequestContext.getCurrentInstance();
// Register it for the table
rc.getChangeManager().addComponentChange(
fc, event.getComponent(), change);
}
Make sure you have:
<context-param>
<param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name>
<param-value>session</param-value>
</context-param>
in your web.xml to enable the feature.
-- Adam
On 7/12/07, Stéphane Poirier <st...@gmail.com> wrote:
> Sorry, my description wasn't completely right as I re-read it. I'll take it
> over correctly with an example :
>
> I'm in "JSP 1" which contains a <tr:table> (with it's default navigation
> menu) and a <tr:selectOneChoise>. Changing the selectOnChoise changes the
> table data using partialTriggers and an action in the backing bean. At that
> point, if I redirect to another application and come back, JSP 1 will
> restore to the state it was.
>
> However, if I use the table navigation to see the third page of data (for
> example) then redirect to another application and come back, the JSP 1 will
> show the first page of data instead of the third. That is my problem.
>
>
>
>
> On 7/12/07, Adam Winer <aw...@gmail.com> wrote:
> > There shouldn't be any difference between redirecting
> > after AJAX or redirecting after a standard request.
> > The state should be the same. I'm not sure
> > what you're describing.
> >
> > -- Adam
> >
> >
> > On 7/12/07, Stéphane Poirier <st...@gmail.com> wrote:
> > > Hi,
> > >
> > > I have 2 different Trinidad applications interacting. Beeing different
> > > applications, I'm using ExternalContext.sendRedirect() to go from an
> > > application to another. It works well (tho it's not very clean) and the
> > > state of components is the same when the page is revisited (beans are in
> > > session scope). My problem is when I'm using AJAX with partialTrigers.
> If
> > > I'm using a redirect in an action after AJAX, the state will not be
> saved (I
> > > understand that it's the normal behavior). Still, I want to solve this
> > > problem. Any ideas?
> > >
> > > I read that ViewHandler could possibly help... is that right? If so, an
> > > implementation hint would be greatly appreciated! :-)
> > >
> > > Thanks in advance!
> > >
> >
>
>
Re: [Trinidad] State saving between applications
Posted by Stéphane Poirier <st...@gmail.com>.
Sorry, my description wasn't completely right as I re-read it. I'll take it
over correctly with an example :
I'm in "JSP 1" which contains a <tr:table> (with it's default navigation
menu) and a <tr:selectOneChoise>. Changing the selectOnChoise changes the
table data using partialTriggers and an action in the backing bean. At that
point, if I redirect to another application and come back, JSP 1 will
restore to the state it was.
However, if I use the table navigation to see the third page of data (for
example) then redirect to another application and come back, the JSP 1 will
show the first page of data instead of the third. That is my problem.
On 7/12/07, Adam Winer <aw...@gmail.com> wrote:
>
> There shouldn't be any difference between redirecting
> after AJAX or redirecting after a standard request.
> The state should be the same. I'm not sure
> what you're describing.
>
> -- Adam
>
>
> On 7/12/07, Stéphane Poirier <st...@gmail.com> wrote:
> > Hi,
> >
> > I have 2 different Trinidad applications interacting. Beeing different
> > applications, I'm using ExternalContext.sendRedirect() to go from an
> > application to another. It works well (tho it's not very clean) and the
> > state of components is the same when the page is revisited (beans are in
> > session scope). My problem is when I'm using AJAX with partialTrigers.
> If
> > I'm using a redirect in an action after AJAX, the state will not be
> saved (I
> > understand that it's the normal behavior). Still, I want to solve this
> > problem. Any ideas?
> >
> > I read that ViewHandler could possibly help... is that right? If so, an
> > implementation hint would be greatly appreciated! :-)
> >
> > Thanks in advance!
> >
>
Re: [Trinidad] State saving between applications
Posted by Adam Winer <aw...@gmail.com>.
There shouldn't be any difference between redirecting
after AJAX or redirecting after a standard request.
The state should be the same. I'm not sure
what you're describing.
-- Adam
On 7/12/07, Stéphane Poirier <st...@gmail.com> wrote:
> Hi,
>
> I have 2 different Trinidad applications interacting. Beeing different
> applications, I'm using ExternalContext.sendRedirect() to go from an
> application to another. It works well (tho it's not very clean) and the
> state of components is the same when the page is revisited (beans are in
> session scope). My problem is when I'm using AJAX with partialTrigers. If
> I'm using a redirect in an action after AJAX, the state will not be saved (I
> understand that it's the normal behavior). Still, I want to solve this
> problem. Any ideas?
>
> I read that ViewHandler could possibly help... is that right? If so, an
> implementation hint would be greatly appreciated! :-)
>
> Thanks in advance!
>