You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Ludwig <ge...@gmail.com> on 2012/08/02 01:46:44 UTC

Creating a linked list of pages for easy backward navigation?

I'm building a page that iteratively refines a data set. After selecting
filter criteria, they can either click Continue or Back.

The Continue part is no problem, it's working. But I want them to be able
to click Back and return to the page with the state it had when they
clicked Continue. Essentially, I want a backwards-facing linked list of
pages.

My current implementation doesn't work, as it appears that each
previousPage is the same object. What's the best way to do this?

Current implementation:

Before the next iteration of the page is loaded, I set it up:

@Persist

private Object previousPage;
void setup(Object previousPage) {
   this.previousPage=previousPage;
}

Then when the user clicks back:

  Object onBack() {

   return previousPage;

}

Re: Creating a linked list of pages for easy backward navigation?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 16 Aug 2012 18:00:34 -0300, George Ludwig <ge...@gmail.com>  
wrote:

> Thiago,

Hello!

> It turned out that I didn't need bi-directional traversal of the page
> history, just backtracking. So I went with a stack of objects that
> encapsulated all the page data I needed to persist. Works great!

Nice! :)

> Question: To clear the persisted stack, do I need to do anything other  
> than set it to null when I'm done with it?

Just set the @Persist'ed or @SessionState persisted object to null.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Creating a linked list of pages for easy backward navigation?

Posted by George Ludwig <ge...@gmail.com>.
Thiago,

It turned out that I didn't need bi-directional traversal of the page
history, just backtracking. So I went with a stack of objects that
encapsulated all the page data I needed to persist. Works great!

Question: To clear the persisted stack, do I need to do anything other than
set it to null when I'm done with it?

Best,

George

On Fri, Aug 3, 2012 at 8:01 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 03 Aug 2012 19:32:13 -0300, George Ludwig <ge...@gmail.com>
> wrote:
>
>  Thiago,
>>
>
> Hi, George!
>
>
>  Thanks, that's what I thought was going on. Off the top of my head, my
>> thought is to create an aggregating data structure that holds all the
>> fields I really need (including a page id, and a previous page id), and
>> persist a list of them. Then, in my "onback" method, pass the index of
>> the previous page to the setup method.
>>
>
> Sounds good to me.
>
>
>   Is there a "best practice" for doing this?
>>
>
> As far as I know, no, so go ahead. :) The only related best practice I can
> think of is to only use session persistence when really needed and to
> remove stuff from the session when it's not needed anymore.
>
>
>> -George
>>
>>
>> On Thu, Aug 2, 2012 at 6:38 PM, Thiago H de Paula Figueiredo <
>> thiagohp@gmail.com> wrote:
>>
>>  On Thu, 02 Aug 2012 22:11:47 -0300, George Ludwig <
>>> georgeludwig@gmail.com>
>>> wrote:
>>>
>>>  Thiago,
>>>
>>>>
>>>>
>>> Hi!
>>>
>>>
>>>
>>>  The previouspage object is referenced when we execute the continue
>>>> method,
>>>> which is what advances to the next iteration:
>>>>
>>>> @InjectPage
>>>> private Refine refine;
>>>>
>>>> Object onContinue() throws Exception {
>>>>
>>>>    // do a bunch of business logic
>>>>
>>>>    refine.setup(this);
>>>>
>>>>    return refine;
>>>>
>>>> }
>>>>
>>>>
>>> Yep, what you're seeing is expected. The object is always the same
>>> because
>>> since Tapestry 5.2 there's a single instance of each page class. Instead
>>> of
>>> persisting the page instance, persist the data with one or more @Persist
>>> fields.
>>>
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**a**pache.org<http://apache.org>
>>> <us...@tapestry.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Creating a linked list of pages for easy backward navigation?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 03 Aug 2012 19:32:13 -0300, George Ludwig <ge...@gmail.com>  
wrote:

> Thiago,

Hi, George!

> Thanks, that's what I thought was going on. Off the top of my head, my
> thought is to create an aggregating data structure that holds all the
> fields I really need (including a page id, and a previous page id), and
> persist a list of them. Then, in my "onback" method, pass the index of  
> the previous page to the setup method.

Sounds good to me.

>  Is there a "best practice" for doing this?

As far as I know, no, so go ahead. :) The only related best practice I can  
think of is to only use session persistence when really needed and to  
remove stuff from the session when it's not needed anymore.

>
> -George
>
>
> On Thu, Aug 2, 2012 at 6:38 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> On Thu, 02 Aug 2012 22:11:47 -0300, George Ludwig  
>> <ge...@gmail.com>
>> wrote:
>>
>>  Thiago,
>>>
>>
>> Hi!
>>
>>
>>
>>> The previouspage object is referenced when we execute the continue  
>>> method,
>>> which is what advances to the next iteration:
>>>
>>> @InjectPage
>>> private Refine refine;
>>>
>>> Object onContinue() throws Exception {
>>>
>>>    // do a bunch of business logic
>>>
>>>    refine.setup(this);
>>>
>>>    return refine;
>>>
>>> }
>>>
>>
>> Yep, what you're seeing is expected. The object is always the same  
>> because
>> since Tapestry 5.2 there's a single instance of each page class.  
>> Instead of
>> persisting the page instance, persist the data with one or more @Persist
>> fields.
>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail:  
>> users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Creating a linked list of pages for easy backward navigation?

Posted by George Ludwig <ge...@gmail.com>.
Thiago,

Thanks, that's what I thought was going on. Off the top of my head, my
thought is to create an aggregating data structure that holds all the
fields I really need (including a page id, and a previous page id), and
persist a list of them. Then, in my "onback" method, pass the index of the
previous page to the setup method.

 Is there a "best practice" for doing this?

-George


On Thu, Aug 2, 2012 at 6:38 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Thu, 02 Aug 2012 22:11:47 -0300, George Ludwig <ge...@gmail.com>
> wrote:
>
>  Thiago,
>>
>
> Hi!
>
>
>
>> The previouspage object is referenced when we execute the continue method,
>> which is what advances to the next iteration:
>>
>> @InjectPage
>> private Refine refine;
>>
>> Object onContinue() throws Exception {
>>
>>    // do a bunch of business logic
>>
>>    refine.setup(this);
>>
>>    return refine;
>>
>> }
>>
>
> Yep, what you're seeing is expected. The object is always the same because
> since Tapestry 5.2 there's a single instance of each page class. Instead of
> persisting the page instance, persist the data with one or more @Persist
> fields.
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Creating a linked list of pages for easy backward navigation?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 02 Aug 2012 22:11:47 -0300, George Ludwig <ge...@gmail.com>  
wrote:

> Thiago,

Hi!

>
> The previouspage object is referenced when we execute the continue  
> method,
> which is what advances to the next iteration:
>
> @InjectPage
> private Refine refine;
>
> Object onContinue() throws Exception {
>
>    // do a bunch of business logic
>
>    refine.setup(this);
>
>    return refine;
>
> }

Yep, what you're seeing is expected. The object is always the same because  
since Tapestry 5.2 there's a single instance of each page class. Instead  
of persisting the page instance, persist the data with one or more  
@Persist fields.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Creating a linked list of pages for easy backward navigation?

Posted by George Ludwig <ge...@gmail.com>.
Thiago,

The previouspage object is referenced when we execute the continue method,
which is what advances to the next iteration:

@InjectPage
private Refine refine;

Object onContinue() throws Exception {

   // do a bunch of business logic

   refine.setup(this);

   return refine;

}

Jens:

Yes, I am using the same page class to iteratively refine the data set. It
has an entry point page (Start,java) that you only see once, the refinement
page (Refine.java) that you iterate through a few times, and the end page
(End.java) the is served when refinement is complete.

-George
On Wed, Aug 1, 2012 at 6:21 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 01 Aug 2012 20:46:44 -0300, George Ludwig <ge...@gmail.com>
> wrote:
>
>> My current implementation doesn't work, as it appears that each
>> previousPage is the same object. What's the best way to do this?
>>
>
> You posted just a snippet from your code that doesn't include one
> important step: how do you get the previous page object?
>
>
>
>> Current implementation:
>>
>> Before the next iteration of the page is loaded, I set it up:
>>
>> @Persist
>>
>> private Object previousPage;
>> void setup(Object previousPage) {
>>    this.previousPage=**previousPage;
>> }
>>
>> Then when the user clicks back:
>>
>>   Object onBack() {
>>
>>    return previousPage;
>>
>> }
>>
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Creating a linked list of pages for easy backward navigation?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 01 Aug 2012 20:46:44 -0300, George Ludwig <ge...@gmail.com>  
wrote:
> My current implementation doesn't work, as it appears that each
> previousPage is the same object. What's the best way to do this?

You posted just a snippet from your code that doesn't include one  
important step: how do you get the previous page object?

>
> Current implementation:
>
> Before the next iteration of the page is loaded, I set it up:
>
> @Persist
>
> private Object previousPage;
> void setup(Object previousPage) {
>    this.previousPage=previousPage;
> }
>
> Then when the user clicks back:
>
>   Object onBack() {
>
>    return previousPage;
>
> }


-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Creating a linked list of pages for easy backward navigation?

Posted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
Hi Ludwig

Am I right you are always using the same page for your refinement selection? Or is it more like a wizzard containing multiple pages?

For the first I wonder if this is really a T5 problem.. Can't you just use a stack like object and push/pop the values you need to create/recreate the activation context for your page (to store the selection a user made on each "continue")?

Jens

Sent from my iPhone

On 02.08.2012, at 01:46, George Ludwig <ge...@gmail.com> wrote:

> I'm building a page that iteratively refines a data set. After selecting
> filter criteria, they can either click Continue or Back.
> 
> The Continue part is no problem, it's working. But I want them to be able
> to click Back and return to the page with the state it had when they
> clicked Continue. Essentially, I want a backwards-facing linked list of
> pages.
> 
> My current implementation doesn't work, as it appears that each
> previousPage is the same object. What's the best way to do this?
> 
> Current implementation:
> 
> Before the next iteration of the page is loaded, I set it up:
> 
> @Persist
> 
> private Object previousPage;
> void setup(Object previousPage) {
>   this.previousPage=previousPage;
> }
> 
> Then when the user clicks back:
> 
>  Object onBack() {
> 
>   return previousPage;
> 
> }

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org