Model for simple UI state? (Apart from 'regular' Model)

2010-07-05 Thread Anh
Hi,

I'm having trouble on how to best implement something simple:

I'm frequently finding the need to have 2 Models for a component:

One Model is the bound data object (persisted),
The other is lightweight UI state, such as whether a section is expanded, etc.
The UI state is not needed outside of the component itself.
It does not make sense to combine it with the bound data Model.


When I first ran into this need, I tried storing the UI state as
properties in the component, without using a model for it.
This led to issues with the state resetting on refresh, etc.

What I think I need is a Model that:

* Is instantiated by the component
* Keeps state across a page refresh
* Ajax component refresh.
* Leaving the page and loading the page later should reset the UI state.
* UI state is not persisted in a DB, etc.

What might be the best way to do the above?


Thanks

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



Re: Model for simple UI state? (Apart from 'regular' Model)

2010-07-05 Thread James Carman
Wicket stores the state (its fields) of a component (and thus pages)
between requests.  So, your idea should work.  Did you see any
serialization errors/warnings on your output log?  Perhaps the
component's state can't be serialized?

On Mon, Jul 5, 2010 at 3:10 PM, Anh 7za...@gmail.com wrote:
 Hi,

 I'm having trouble on how to best implement something simple:

 I'm frequently finding the need to have 2 Models for a component:

 One Model is the bound data object (persisted),
 The other is lightweight UI state, such as whether a section is expanded, etc.
 The UI state is not needed outside of the component itself.
 It does not make sense to combine it with the bound data Model.


 When I first ran into this need, I tried storing the UI state as
 properties in the component, without using a model for it.
 This led to issues with the state resetting on refresh, etc.

 What I think I need is a Model that:

 * Is instantiated by the component
 * Keeps state across a page refresh
 * Ajax component refresh.
 * Leaving the page and loading the page later should reset the UI state.
 * UI state is not persisted in a DB, etc.

 What might be the best way to do the above?


 Thanks

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



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



Re: Model for simple UI state? (Apart from 'regular' Model)

2010-07-05 Thread Pedro Santos
UI state as properties in the component should be to fine, see if using
session relative urls the problem remains

On Mon, Jul 5, 2010 at 4:10 PM, Anh 7za...@gmail.com wrote:

 Hi,

 I'm having trouble on how to best implement something simple:

 I'm frequently finding the need to have 2 Models for a component:

 One Model is the bound data object (persisted),
 The other is lightweight UI state, such as whether a section is expanded,
 etc.
 The UI state is not needed outside of the component itself.
 It does not make sense to combine it with the bound data Model.


 When I first ran into this need, I tried storing the UI state as
 properties in the component, without using a model for it.
 This led to issues with the state resetting on refresh, etc.

 What I think I need is a Model that:

 * Is instantiated by the component
 * Keeps state across a page refresh
 * Ajax component refresh.
 * Leaving the page and loading the page later should reset the UI state.
 * UI state is not persisted in a DB, etc.

 What might be the best way to do the above?


 Thanks

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




-- 
Pedro Henrique Oliveira dos Santos


Re: Model for simple UI state? (Apart from 'regular' Model)

2010-07-05 Thread Anh
Thank you, this works fine.

Of course, now I can't remember the example that made me think this
approach wouldn't work!

Thanks again

On Mon, Jul 5, 2010 at 12:33 PM, Pedro Santos pedros...@gmail.com wrote:
 UI state as properties in the component should be to fine, see if using
 session relative urls the problem remains

 On Mon, Jul 5, 2010 at 4:10 PM, Anh 7za...@gmail.com wrote:

 Hi,

 I'm having trouble on how to best implement something simple:

 I'm frequently finding the need to have 2 Models for a component:

 One Model is the bound data object (persisted),
 The other is lightweight UI state, such as whether a section is expanded,
 etc.
 The UI state is not needed outside of the component itself.
 It does not make sense to combine it with the bound data Model.


 When I first ran into this need, I tried storing the UI state as
 properties in the component, without using a model for it.
 This led to issues with the state resetting on refresh, etc.

 What I think I need is a Model that:

 * Is instantiated by the component
 * Keeps state across a page refresh
 * Ajax component refresh.
 * Leaving the page and loading the page later should reset the UI state.
 * UI state is not persisted in a DB, etc.

 What might be the best way to do the above?


 Thanks

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




 --
 Pedro Henrique Oliveira dos Santos


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