[Wicket-user] Where/how to store state information

2005-10-19 Thread Timo Stamm

Hi list,


I have created a navigation menu component and a menu model.

The menu component should show on every page of my application, so I 
derive all pages from a page class which creates and adds a menu instance.


The menu must remember which item is selected (the state is 
representable by a simple String).



Now I have the following problem: Where do I keep the state of the menu?

It seems obvious to use the session, but how? The Wicket Session class 
does not allow arbitrary attributes. I guess I could get the original 
HttpSession somehow, but I am sure that there is a better way.



Timo


---
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Where/how to store state information

2005-10-19 Thread Eelco Hillenius
For anything you want to store in the session, you can provide your
own session implementation. Not having some kind of generic map in
session was deliberate, as we think it is better to provide a custom
one that has strongly typed properties. See for example the hangman
example in wicket-examples.

For this specific case, I think storing it in the session is probably
the easiest way, though not the most elegant way; what if you decide
to have multiple navigation components in your application? If
possible, the best way imo is to design your navigation component such
that you don't need any extra state info; just the current page and
maybe some additional attributes of that page and the current user. If
that is not possible, you might check out whether it is doable to pass
the state whenever you navigate to other pages. Not sure whether that
is a better idea than storing session info though.

Eelco



On 10/19/05, Timo Stamm [EMAIL PROTECTED] wrote:
 Hi list,


 I have created a navigation menu component and a menu model.

 The menu component should show on every page of my application, so I
 derive all pages from a page class which creates and adds a menu instance.

 The menu must remember which item is selected (the state is
 representable by a simple String).


 Now I have the following problem: Where do I keep the state of the menu?

 It seems obvious to use the session, but how? The Wicket Session class
 does not allow arbitrary attributes. I guess I could get the original
 HttpSession somehow, but I am sure that there is a better way.


 Timo


 ---
 This SF.Net email is sponsored by:
 Power Architecture Resource Center: Free content, downloads, discussions,
 and more. http://solutions.newsforge.com/ibmarch.tmpl
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



---
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Where/how to store state information

2005-10-19 Thread Dipu
Can't you declare an instance variable in your own application specific 
session class and add getter/setter methods.
I am not sure if this is the best solution. Please let me know if you find a 
better way for doing it.


Regards
Dipu
- Original Message - 
From: Timo Stamm [EMAIL PROTECTED]

To: wicket-user@lists.sourceforge.net
Sent: Wednesday, October 19, 2005 2:48 PM
Subject: [Wicket-user] Where/how to store state information



Hi list,


I have created a navigation menu component and a menu model.

The menu component should show on every page of my application, so I 
derive all pages from a page class which creates and adds a menu instance.


The menu must remember which item is selected (the state is representable 
by a simple String).



Now I have the following problem: Where do I keep the state of the menu?

It seems obvious to use the session, but how? The Wicket Session class 
does not allow arbitrary attributes. I guess I could get the original 
HttpSession somehow, but I am sure that there is a better way.



Timo


---
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user





---
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Where/how to store state information

2005-10-19 Thread Timo Stamm

Eelco Hillenius wrote:

For anything you want to store in the session, you can provide your
own session implementation. Not having some kind of generic map in
session was deliberate, as we think it is better to provide a custom
one that has strongly typed properties. See for example the hangman
example in wicket-examples.


Thanks, that's what I was looking for.



If
possible, the best way imo is to design your navigation component such
that you don't need any extra state info; just the current page and
maybe some additional attributes of that page and the current user. If
that is not possible, you might check out whether it is doable to pass
the state whenever you navigate to other pages. Not sure whether that
is a better idea than storing session info though.


I have considered both, but right now it is too early for generalization.


Timo


---
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Where/how to store state information

2005-10-19 Thread Timo Stamm

Dipu wrote:
Can't you declare an instance variable in your own application specific 
session class and add getter/setter methods.
I am not sure if this is the best solution. Please let me know if you 
find a better way for doing it.



Thanks, Eelco pointed me to the hangman example which shows how to use 
such a specific session implementation.



Timo


---
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user