Re: Are pages stored in session?

2008-11-07 Thread Jeremy Thomerson
Is there dynamic content in this page?  If not, there's no real loss in
creating a new one for each request - this is very inexpensive.  If there
is, just cache it somewhere in your service layer or the application, etc...
Components (including pages) should generally not be reused for multiple
users / sessions

Also - you can save some code by using new
BookmarkablePageLink(faqPageLink, FAQPage.class)

-- 
Jeremy Thomerson
http://www.wickettraining.com

On Fri, Nov 7, 2008 at 12:18 PM, danelav [EMAIL PROTECTED] wrote:


 I have a very basic link to a FAQPage, as shown below. Every time that link
 is clicked, the FAQPage constructor is called. This page is fairly static,
 and there's no reason for it to be re-constructed on every request. Is
 there
 a way to create the link so that it will use an existing instance of
 FAQPage
 rather than re-constructing the whole page every time the link is called?

 faqPageLink = new Link(faqPageLink) {
  public void onClick() {
setResponsePage(FAQPage.class);
  }
 };
 --
 View this message in context:
 http://www.nabble.com/Are-pages-stored-in-session--tp20386141p20386141.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Are pages stored in session?

2008-11-07 Thread Bruno Borges
Let say your FAQPage loads data from the database.

You could put an instance of that page at your MyWicketApplication. Like
this:

MyApp extends WebApplication {

private FAQPage faqPage;
public FAQPage getFAQPage() {
  return faqPage;
}

protected void init()  {
  reloadFAQPage(); // creates an instance, etc...
}

public void reloadFAQPage() {
   ... // reloads data from database after changing something at the FAQ
DB Table, or something like that
}
}

And then you just need to do a new Link referencing that instance. :)

cheers,
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099

The glory of great men should always be
measured by the means they have used to
acquire it.
- Francois de La Rochefoucauld


On Fri, Nov 7, 2008 at 12:26 PM, Jeremy Thomerson [EMAIL PROTECTED]
 wrote:

 Is there dynamic content in this page?  If not, there's no real loss in
 creating a new one for each request - this is very inexpensive.  If there
 is, just cache it somewhere in your service layer or the application,
 etc...
 Components (including pages) should generally not be reused for multiple
 users / sessions

 Also - you can save some code by using new
 BookmarkablePageLink(faqPageLink, FAQPage.class)

 --
 Jeremy Thomerson
 http://www.wickettraining.com

 On Fri, Nov 7, 2008 at 12:18 PM, danelav [EMAIL PROTECTED]
 wrote:

 
  I have a very basic link to a FAQPage, as shown below. Every time that
 link
  is clicked, the FAQPage constructor is called. This page is fairly
 static,
  and there's no reason for it to be re-constructed on every request. Is
  there
  a way to create the link so that it will use an existing instance of
  FAQPage
  rather than re-constructing the whole page every time the link is called?
 
  faqPageLink = new Link(faqPageLink) {
   public void onClick() {
 setResponsePage(FAQPage.class);
   }
  };
  --
  View this message in context:
 
 http://www.nabble.com/Are-pages-stored-in-session--tp20386141p20386141.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



Re: Are pages stored in session?

2008-11-07 Thread Bruno Borges
Ok, forget about it... Components are NOT Thread safe... :-)

Just make FAQPage a Stateless WebPage... ;-)

Cheers,
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099

The glory of great men should always be
measured by the means they have used to
acquire it.
- Francois de La Rochefoucauld


On Fri, Nov 7, 2008 at 12:30 PM, Bruno Borges [EMAIL PROTECTED]wrote:

 Let say your FAQPage loads data from the database.

 You could put an instance of that page at your MyWicketApplication. Like
 this:

 MyApp extends WebApplication {

 private FAQPage faqPage;
 public FAQPage getFAQPage() {
   return faqPage;
 }

 protected void init()  {
   reloadFAQPage(); // creates an instance, etc...
 }

 public void reloadFAQPage() {
... // reloads data from database after changing something at the
 FAQ DB Table, or something like that
 }
 }

 And then you just need to do a new Link referencing that instance. :)

 cheers,
 Bruno Borges
 blog.brunoborges.com.br
 +55 21 76727099

 The glory of great men should always be
 measured by the means they have used to
 acquire it.
 - Francois de La Rochefoucauld



 On Fri, Nov 7, 2008 at 12:26 PM, Jeremy Thomerson 
 [EMAIL PROTECTED] wrote:

 Is there dynamic content in this page?  If not, there's no real loss in
 creating a new one for each request - this is very inexpensive.  If there
 is, just cache it somewhere in your service layer or the application,
 etc...
 Components (including pages) should generally not be reused for multiple
 users / sessions

 Also - you can save some code by using new
 BookmarkablePageLink(faqPageLink, FAQPage.class)

 --
 Jeremy Thomerson
 http://www.wickettraining.com

 On Fri, Nov 7, 2008 at 12:18 PM, danelav [EMAIL PROTECTED]
 wrote:

 
  I have a very basic link to a FAQPage, as shown below. Every time that
 link
  is clicked, the FAQPage constructor is called. This page is fairly
 static,
  and there's no reason for it to be re-constructed on every request. Is
  there
  a way to create the link so that it will use an existing instance of
  FAQPage
  rather than re-constructing the whole page every time the link is
 called?
 
  faqPageLink = new Link(faqPageLink) {
   public void onClick() {
 setResponsePage(FAQPage.class);
   }
  };
  --
  View this message in context:
 
 http://www.nabble.com/Are-pages-stored-in-session--tp20386141p20386141.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]