Re: clarification on page versioning

2008-04-20 Thread Jeremy Thomerson
Another option is to add both panels, and have each override isVisible().
This makes the Login and CurrentProfile panels smarter, and keeps their
logic more encapsulated (allowing these panels to be used elsewhere without
having to copy-paste the logic about being signed in).

i.e:

// remove your if statement, and replace with this:
add(new Login(login));
add(new CurrentProfile(profile));

in Login.java:

class Login {

// your other code

public boolean isVisible() {
return BaseSession.get().getLoggedInUser() == null;
}
}

in CurrentProfile.java:

class CurrentProfile {

// your other code

public boolean isVisible() {
return BaseSession.get().getLoggedInUser() != null;
}
}

Hope this helps.

On Sat, Apr 19, 2008 at 6:47 PM, Martin Grigorov [EMAIL PROTECTED]
wrote:

 Probably you should move this code in onBeforeRender() (and use
 addOrReplace().
 This way every time you'll have the right panel.

 On Sat, 2008-04-19 at 07:28 -0700, Doug Donohoe wrote:
  I have a page which displays a [login box] (if not logged in) or an info
 box
  [user name|logout link] if logged in.
 
  I implemented this as follows:
 
  User user = BaseSession.get().getLoggedInUser();
  if (user == null)
  {
  add(new Login(login));
  }
  else
  {
  add(new CurrentProfile(login));
  }
 
  Both Login and CurrentProfile are subclasses of Panel.  When the login
  form is submitted or the logout link is submitted, in order to get the
 page
  to re-render, I had to use this code:
 
  setResponsePage(getPage().getClass()); // need to use class so
  page is re-rendered
 
  As a new wicket user, I'd like a clarification on why this is necessary.
  If
  I used this code:
 
 setResponsePage(getPage());
 
  ... which appears to be the default behavior if setResponsePage() isn't
  called ... then the page is simply displayed without re-rendering (e.g.,
  after login, the login box is still shown).  So, my question is what's
 the
  difference between the two?  Is there a way to mark a page as needing
  re-rendering?  Is my solution the correct way in Wicket?
 
  This also raises the question about how many pages are stored in the
 page
  map.  For example, if I were to login and logout 10 times in a row ...
 would
  there be 20 pages in the page map?  Is there a way to clear out the page
 map
  for a page?
 
  In my case, I invalidate the session on logout, so the above case isn't
 an
  issue in this exact case.  I'm more concerned about someone who
 navigates my
  site and visits hundreds of pages.  How do I keep the session from
 filling
  up with old pages?
 
  Finally, is there a best practice to debug/monitor session size and page
 map
  size?
 
  Thanks,
 
  -Doug


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




clarification on page versioning

2008-04-19 Thread Doug Donohoe

I have a page which displays a [login box] (if not logged in) or an info box
[user name|logout link] if logged in.

I implemented this as follows:

User user = BaseSession.get().getLoggedInUser();
if (user == null)
{
add(new Login(login));
}
else
{
add(new CurrentProfile(login));
}

Both Login and CurrentProfile are subclasses of Panel.  When the login
form is submitted or the logout link is submitted, in order to get the page
to re-render, I had to use this code:

setResponsePage(getPage().getClass()); // need to use class so
page is re-rendered

As a new wicket user, I'd like a clarification on why this is necessary.  If
I used this code:

   setResponsePage(getPage()); 

... which appears to be the default behavior if setResponsePage() isn't
called ... then the page is simply displayed without re-rendering (e.g.,
after login, the login box is still shown).  So, my question is what's the
difference between the two?  Is there a way to mark a page as needing
re-rendering?  Is my solution the correct way in Wicket?

This also raises the question about how many pages are stored in the page
map.  For example, if I were to login and logout 10 times in a row ... would
there be 20 pages in the page map?  Is there a way to clear out the page map
for a page?

In my case, I invalidate the session on logout, so the above case isn't an
issue in this exact case.  I'm more concerned about someone who navigates my
site and visits hundreds of pages.  How do I keep the session from filling
up with old pages?

Finally, is there a best practice to debug/monitor session size and page map
size?

Thanks,

-Doug
-- 
View this message in context: 
http://www.nabble.com/clarification-on-page-versioning-tp16783638p16783638.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: clarification on page versioning

2008-04-19 Thread Carl-Eric Menzel
 Both Login and CurrentProfile are subclasses of Panel.  When the 
 login form is submitted or the logout link is submitted, in order to 
 get the page to re-render, I had to use this code:
 
 setResponsePage(getPage().getClass());

In this case the page isn't re-rendered, it is re-created, i.e. a new
instance of your page class is instantiated, which then does the add(new
CurrentProfile()) in its constructor.

In the default behavior you're getting the exact same page instance you
initially created and in which you said add(new Login()).

To replace the login panel with the profile panel, keep a reference to
the login panel and in your form submit method do this:

login.replaceWith(new CurrentProfile())

This removes the login panel from the page and, as the method name
suggests, replaces it with the CurrentProfile instance. Remember the
latter in a field too, if you ever want to switch back.

This way you only have one page and swap out its components instead of
creating new page instances.


Hope this helps
Carl-Eric

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



Re: clarification on page versioning

2008-04-19 Thread Doug Donohoe

Thanks for the post. 

I'd probably have to do an anonymous subclass of my Login panel.  It doesn't
know about it's parent or what the parent might like to swap in when a
logged in user is present.

I'll look under the covers of replaceWith() - I basically want to do
whatever replaceWith() does without actually replacing anything.

-Doug


Carl-Eric Menzel-5 wrote:
 
 Both Login and CurrentProfile are subclasses of Panel.  When the 
 login form is submitted or the logout link is submitted, in order to 
 get the page to re-render, I had to use this code:
 
 setResponsePage(getPage().getClass());
 
 In this case the page isn't re-rendered, it is re-created, i.e. a new
 instance of your page class is instantiated, which then does the add(new
 CurrentProfile()) in its constructor.
 
 In the default behavior you're getting the exact same page instance you
 initially created and in which you said add(new Login()).
 
 To replace the login panel with the profile panel, keep a reference to
 the login panel and in your form submit method do this:
 
 login.replaceWith(new CurrentProfile())
 
 This removes the login panel from the page and, as the method name
 suggests, replaces it with the CurrentProfile instance. Remember the
 latter in a field too, if you ever want to switch back.
 
 This way you only have one page and swap out its components instead of
 creating new page instances.
 
 
 Hope this helps
 Carl-Eric
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/clarification-on-page-versioning-tp16783638p16784204.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: clarification on page versioning

2008-04-19 Thread Carl-Eric Menzel
Doug Donohoe wrote:
 I'd probably have to do an anonymous subclass of my Login panel.  It doesn't
 know about it's parent or what the parent might like to swap in when a
 logged in user is present.
 
 I'll look under the covers of replaceWith() - I basically want to do
 whatever replaceWith() does without actually replacing anything.

replaceWith() is provided by Component and knows all it needs to do it.
You shouldn't have to do anything to use it.

Carl-Eric

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



Re: clarification on page versioning

2008-04-19 Thread Doug Donohoe

I meant I'd look under the covers to see if I could find a way to force the
page to re-render without adding an entry to the page map.  Maybe I 'm
missing something.

With regards to my page map question, I'm searching for a description of how
the history mechanism works and what controls one has to limit the size of
the page map.  Anyone have any insights on this?

-Doug


Carl-Eric Menzel-5 wrote:
 
 Doug Donohoe wrote:
 I'd probably have to do an anonymous subclass of my Login panel.  It
 doesn't
 know about it's parent or what the parent might like to swap in when a
 logged in user is present.
 
 I'll look under the covers of replaceWith() - I basically want to do
 whatever replaceWith() does without actually replacing anything.
 
 replaceWith() is provided by Component and knows all it needs to do it.
 You shouldn't have to do anything to use it.
 
 Carl-Eric
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/clarification-on-page-versioning-tp16783638p16787301.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: clarification on page versioning

2008-04-19 Thread Igor Vaynberg
with diskstore (default in 1.3) each pagemap only contains one page.
the rest are spooled to disk.

-igor


On Sat, Apr 19, 2008 at 1:22 PM, Doug Donohoe [EMAIL PROTECTED] wrote:

  I meant I'd look under the covers to see if I could find a way to force the
  page to re-render without adding an entry to the page map.  Maybe I 'm
  missing something.

  With regards to my page map question, I'm searching for a description of how
  the history mechanism works and what controls one has to limit the size of
  the page map.  Anyone have any insights on this?


  -Doug


  Carl-Eric Menzel-5 wrote:
  


  Doug Donohoe wrote:
   I'd probably have to do an anonymous subclass of my Login panel.  It
   doesn't
   know about it's parent or what the parent might like to swap in when a
   logged in user is present.
  
   I'll look under the covers of replaceWith() - I basically want to do
   whatever replaceWith() does without actually replacing anything.
  
   replaceWith() is provided by Component and knows all it needs to do it.
   You shouldn't have to do anything to use it.
  
   Carl-Eric
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  

  --
  View this message in context: 
 http://www.nabble.com/clarification-on-page-versioning-tp16783638p16787301.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]



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



Re: clarification on page versioning

2008-04-19 Thread Martin Grigorov
Probably you should move this code in onBeforeRender() (and use
addOrReplace().
This way every time you'll have the right panel.

On Sat, 2008-04-19 at 07:28 -0700, Doug Donohoe wrote:
 I have a page which displays a [login box] (if not logged in) or an info box
 [user name|logout link] if logged in.
 
 I implemented this as follows:
 
 User user = BaseSession.get().getLoggedInUser();
 if (user == null)
 {
 add(new Login(login));
 }
 else
 {
 add(new CurrentProfile(login));
 }
 
 Both Login and CurrentProfile are subclasses of Panel.  When the login
 form is submitted or the logout link is submitted, in order to get the page
 to re-render, I had to use this code:
 
 setResponsePage(getPage().getClass()); // need to use class so
 page is re-rendered
 
 As a new wicket user, I'd like a clarification on why this is necessary.  If
 I used this code:
 
setResponsePage(getPage()); 
 
 ... which appears to be the default behavior if setResponsePage() isn't
 called ... then the page is simply displayed without re-rendering (e.g.,
 after login, the login box is still shown).  So, my question is what's the
 difference between the two?  Is there a way to mark a page as needing
 re-rendering?  Is my solution the correct way in Wicket?
 
 This also raises the question about how many pages are stored in the page
 map.  For example, if I were to login and logout 10 times in a row ... would
 there be 20 pages in the page map?  Is there a way to clear out the page map
 for a page?
 
 In my case, I invalidate the session on logout, so the above case isn't an
 issue in this exact case.  I'm more concerned about someone who navigates my
 site and visits hundreds of pages.  How do I keep the session from filling
 up with old pages?
 
 Finally, is there a best practice to debug/monitor session size and page map
 size?
 
 Thanks,
 
 -Doug


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