You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Serkan Camurcuoglu <se...@telenity.com> on 2008/06/22 19:53:39 UTC

Best practice for navigating between pages

Hi all,
I'm quite new to Wicket and I'd like to ask whether what I'm doing is 
right. Say I have two pages A and B. Page A loads a list of information 
from the database and keeps it in an instance field. When a link on page 
A is clicked, a new page B is created and page A passes itself as one of 
the constructor arguments of B. Page B displays the information and 
includes a link at the bottom saying "Back". When this link is clicked, 
Page B calls setResponsePage() using the instance of Page A that was 
passed in its constructor, and Page A is displayed again.

That way I believe that I avoid reloading the data from the database 
again in Page A.

But I think somewhere in the mail archives I've read that it's 
recommended to use setResponsePage(Class) instead of using 
setResponsePage(Page). So I'm wondering whether I'm doing it right, and 
if there is a better way I'd like to learn it.

Sorry if this is a dumb question but I want to be confident about what 
I'm developing..

Regards,

SerkanC


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


Re: Best practice for navigating between pages

Posted by Eyal Golan <eg...@gmail.com>.
How about this option?
In page A:
add(new Link("linkToB") {
  public void onClick() {
    B other = new B(...);
    other.setBackPage(A.this);
    setResponsePage(other);
  }
}



On Sun, Jun 22, 2008 at 8:53 PM, Serkan Camurcuoglu <se...@telenity.com>
wrote:

> Hi all,
> I'm quite new to Wicket and I'd like to ask whether what I'm doing is
> right. Say I have two pages A and B. Page A loads a list of information from
> the database and keeps it in an instance field. When a link on page A is
> clicked, a new page B is created and page A passes itself as one of the
> constructor arguments of B. Page B displays the information and includes a
> link at the bottom saying "Back". When this link is clicked, Page B calls
> setResponsePage() using the instance of Page A that was passed in its
> constructor, and Page A is displayed again.
>
> That way I believe that I avoid reloading the data from the database again
> in Page A.
>
> But I think somewhere in the mail archives I've read that it's recommended
> to use setResponsePage(Class) instead of using setResponsePage(Page). So I'm
> wondering whether I'm doing it right, and if there is a better way I'd like
> to learn it.
>
> Sorry if this is a dumb question but I want to be confident about what I'm
> developing..
>
> Regards,
>
> SerkanC
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Best practice for navigating between pages

Posted by Eyal Golan <eg...@gmail.com>.
This is the way we do it.
But I'll leave the expert respond to that :)

On Sun, Jun 22, 2008 at 8:53 PM, Serkan Camurcuoglu <se...@telenity.com>
wrote:

> Hi all,
> I'm quite new to Wicket and I'd like to ask whether what I'm doing is
> right. Say I have two pages A and B. Page A loads a list of information from
> the database and keeps it in an instance field. When a link on page A is
> clicked, a new page B is created and page A passes itself as one of the
> constructor arguments of B. Page B displays the information and includes a
> link at the bottom saying "Back". When this link is clicked, Page B calls
> setResponsePage() using the instance of Page A that was passed in its
> constructor, and Page A is displayed again.
>
> That way I believe that I avoid reloading the data from the database again
> in Page A.
>
> But I think somewhere in the mail archives I've read that it's recommended
> to use setResponsePage(Class) instead of using setResponsePage(Page). So I'm
> wondering whether I'm doing it right, and if there is a better way I'd like
> to learn it.
>
> Sorry if this is a dumb question but I want to be confident about what I'm
> developing..
>
> Regards,
>
> SerkanC
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Best practice for navigating between pages

Posted by Serkan Camurcuoglu <se...@telenity.com>.
Ok, I got your point.. It's ok to reference pages from one another but 
I'd rather focus on attaching/detaching and the amount of data I keep in 
my models.. Thanks very much for the clarification..


Igor Vaynberg wrote:
> On Sun, Jun 22, 2008 at 12:03 PM, brian.diekelman <de...@gmail.com> wrote:
>   
>> Passing a Page instance to the constructor of another Page doesn't sound
>> right to me.  Again, it depends on what you're trying to do, but I haven't
>> seen many instances where passing an instance of 'Page a' versus an IModel
>> with the data 'Page a' is displaying is the 'right' thing to do (in my
>> opinion).
>>     
>
> actually passing a page into another page for a back reference is
> perfectly suitable. as usual the thing to watch for is that you
> properly use detachable models.
>
> -igor
>
>
>   
>> So basically if it's worth it for you to grow the session size on the app
>> server to avoid the overhead of re-querying it from the database, go
>> crazy... but I don't think the UI framework is the best place to handle data
>> caching.
>>
>>
>>
>> Serkan Camurcuoglu-2 wrote:
>>     
>>> Hi all,
>>> I'm quite new to Wicket and I'd like to ask whether what I'm doing is
>>> right. Say I have two pages A and B. Page A loads a list of information
>>> from the database and keeps it in an instance field. When a link on page
>>> A is clicked, a new page B is created and page A passes itself as one of
>>> the constructor arguments of B. Page B displays the information and
>>> includes a link at the bottom saying "Back". When this link is clicked,
>>> Page B calls setResponsePage() using the instance of Page A that was
>>> passed in its constructor, and Page A is displayed again.
>>>
>>> That way I believe that I avoid reloading the data from the database
>>> again in Page A.
>>>
>>> But I think somewhere in the mail archives I've read that it's
>>> recommended to use setResponsePage(Class) instead of using
>>> setResponsePage(Page). So I'm wondering whether I'm doing it right, and
>>> if there is a better way I'd like to learn it.
>>>
>>> Sorry if this is a dumb question but I want to be confident about what
>>> I'm developing..
>>>
>>> Regards,
>>>
>>> SerkanC
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>       
>> --
>> View this message in context: http://www.nabble.com/Best-practice-for-navigating-between-pages-tp18057162p18057871.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>   


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


Re: Best practice for navigating between pages

Posted by Igor Vaynberg <ig...@gmail.com>.
On Sun, Jun 22, 2008 at 12:03 PM, brian.diekelman <de...@gmail.com> wrote:
>
>
> Passing a Page instance to the constructor of another Page doesn't sound
> right to me.  Again, it depends on what you're trying to do, but I haven't
> seen many instances where passing an instance of 'Page a' versus an IModel
> with the data 'Page a' is displaying is the 'right' thing to do (in my
> opinion).

actually passing a page into another page for a back reference is
perfectly suitable. as usual the thing to watch for is that you
properly use detachable models.

-igor


>
> So basically if it's worth it for you to grow the session size on the app
> server to avoid the overhead of re-querying it from the database, go
> crazy... but I don't think the UI framework is the best place to handle data
> caching.
>
>
>
> Serkan Camurcuoglu-2 wrote:
>>
>> Hi all,
>> I'm quite new to Wicket and I'd like to ask whether what I'm doing is
>> right. Say I have two pages A and B. Page A loads a list of information
>> from the database and keeps it in an instance field. When a link on page
>> A is clicked, a new page B is created and page A passes itself as one of
>> the constructor arguments of B. Page B displays the information and
>> includes a link at the bottom saying "Back". When this link is clicked,
>> Page B calls setResponsePage() using the instance of Page A that was
>> passed in its constructor, and Page A is displayed again.
>>
>> That way I believe that I avoid reloading the data from the database
>> again in Page A.
>>
>> But I think somewhere in the mail archives I've read that it's
>> recommended to use setResponsePage(Class) instead of using
>> setResponsePage(Page). So I'm wondering whether I'm doing it right, and
>> if there is a better way I'd like to learn it.
>>
>> Sorry if this is a dumb question but I want to be confident about what
>> I'm developing..
>>
>> Regards,
>>
>> SerkanC
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Best-practice-for-navigating-between-pages-tp18057162p18057871.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Best practice for navigating between pages

Posted by "brian.diekelman" <de...@gmail.com>.

Calling setResponsePage(Page a) increases your session size by the size of a
serialized version of 'a'.  If 'a' has a List of data that 'a' is going to
display, that size may be non-trivial.  As long as you're okay with that,
it's fine... but I wouldn't recommend doing that unless there's a good
reason.  I do this in some cases with wizards as you're filling 'SomeObject'
with data throughout the wizard steps, and then at the end commiting it to
the database.  But again, understand that this is using a lot more memory
than keeping the data outside the page.  It's a trade off based on the
situation.

Passing a Page instance to the constructor of another Page doesn't sound
right to me.  Again, it depends on what you're trying to do, but I haven't
seen many instances where passing an instance of 'Page a' versus an IModel
with the data 'Page a' is displaying is the 'right' thing to do (in my
opinion).

So basically if it's worth it for you to grow the session size on the app
server to avoid the overhead of re-querying it from the database, go
crazy... but I don't think the UI framework is the best place to handle data
caching.



Serkan Camurcuoglu-2 wrote:
> 
> Hi all,
> I'm quite new to Wicket and I'd like to ask whether what I'm doing is 
> right. Say I have two pages A and B. Page A loads a list of information 
> from the database and keeps it in an instance field. When a link on page 
> A is clicked, a new page B is created and page A passes itself as one of 
> the constructor arguments of B. Page B displays the information and 
> includes a link at the bottom saying "Back". When this link is clicked, 
> Page B calls setResponsePage() using the instance of Page A that was 
> passed in its constructor, and Page A is displayed again.
> 
> That way I believe that I avoid reloading the data from the database 
> again in Page A.
> 
> But I think somewhere in the mail archives I've read that it's 
> recommended to use setResponsePage(Class) instead of using 
> setResponsePage(Page). So I'm wondering whether I'm doing it right, and 
> if there is a better way I'd like to learn it.
> 
> Sorry if this is a dumb question but I want to be confident about what 
> I'm developing..
> 
> Regards,
> 
> SerkanC
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Best-practice-for-navigating-between-pages-tp18057162p18057871.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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