On Tue, 2005-03-15 at 09:11 +0100, Reinhard Poetz wrote:
Sylvain Wallez wrote:
Reinhard Poetz wrote:
Sylvain Wallez wrote:
Reinhard Poetz wrote:
Today I've tried to run a form that uses the widget state "INVISIBLE" and when the form state is saved in the request. (my experiments are based on the form1 action example)
If I use the event framework to change the state from ACTIVE to INVISIBLE, toggling works, but the value of the changed widget gets lost.
Looking at the samples I can't figure out ...
- How can a widget have the state "INVISIBLE"? Where is this information stored, or better from where is it read?
Have a look at AbstractWidget.{get|set|getCombined}State() and also at WidgetState.
- If I'm right and the described behavior (losing the values of INVISIBLE widgets) is a bug, how can it be fixed? Any ideas?
If it behaves as you describe it, then yes it's a bug. A field only reads its value when in ACTIVE state, and keeps its current value otherwise.
and here seems to be the bug: the inactive widget can't keep its state as its state would have to be available as request parameter and this never comes (as it's inactive).
Hmm... before being invisible, the widget is active, no? So that means that its value is submitted along with the action that will change the state. So, except if you have some fancy layout, it should read its value before having its state changed.
I assume that it works so far but ...
And later, once invisible, the widget doesn't read its value on the request.
if the widget is invisible, there is no request value any more and as the form is not saved in the session, the widget loses its value.
Yep, though I'd say that's not a bug but a limitation. If you choose to work stateless, there are some features you loose (for example, value changed events won't do anything meaningful either).
In particular the value changed event works for me as long as I don't change the widget's state. But you're right, saving the form in the request-scope brings some limitations.
I try to find these limitations and then I can decide together with my customer what we will do.
Another idea I had is, that I could work on making the form object serializable and save the state in a hidden form field. The price to pay would be increased network traffic but the advantage of a stateless presentation layer wouldn't get lost. Hmmm the more I think about it the more I like this idea .... wdot?
--
Reinhard P�tz Independant Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}web(log): http://www.poetz.cc --------------------------------------------------------------------
