Hi!

Can you share some code? (e.g. a quickstart which reproduces your issue)

It sounds to me like in the one case you are dealing with a stateless page,
and the other a stateful page.

In general, with stateless pages, everything is initialized on every render
/ submit, because there is no page instance (since the page is stateless).
If in some conditions you see that your behavior is run before the submit,
it sounds like you’re dealing with a stateless page. If in other conditions
the behavior is only run on initial page render and after the submit, it
sounds like you’re dealing with a stateful page.

But this is just me guessing without looking at your code.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 23 november 2023 bij 16:09:53, ihmehlm...@gmx.de (ihmehlm...@gmx.de)
schreef:

Hello,
upon working with StatelessForms for the first time I stumbled up an odd
behavior in regards to when the corresponding models are updated.

Following setup:

The base for this is a wicket quickstart 9.15.0. I modified the two
HomePage files, which can be found here:
https://gist.github.com/TekkiWuff/824e820427c16e204bde68e95fd566a6

In this I have a Page with a StatelessForm with a single TextField and a
Label. The TextField and Label share a single String-Model. The Label has a
Behavior which sets the visibility of the attached component to false in
the configure-phase if the String-Model is empty.
Here this is needed to hide the whole HTML-tag instead of rendering an
empty li-tag. In my actual application this applies to much bigger and more
complex panels and lists which need to be hidden/shown when certain form
values are set/not set.


Now the to me odd behavior:

If I initialise all components in the constructor of the page, everything
works as expected.
The request of the form submit gets processed, the model updated and then
afterwards the page gets rendered among which also the Behaviour is run to
set the visibility of the label.
So the visibility is decided on the just submitted form value.

Now if I initialise all components in the onInitialize() method, which by
my understanding is supposed to work like the constructor, the order of
execution seems wrong.
First, my Behaviour is run to set the visibility. Then the request of the
form submit gets processed, the model updated and the page rendered.
So here now the visibility is suddenly decided on the old value, which in
my case initially is an empty Model, so my Label is always hidden.

It's not a matter of using GET or POST and only seems to happen with
StatelessForm. Using a normal statefull Form is working just fine.

Is this a bug or an expected behaviour? I couldn't find anything about this
in the description of the StatelessForm about this.
I am exclusivly using the onInitialize() method for constructing all my
pages, so before having to change several hundred pages to using the
constructor, I rather ask first if it's maybe something that can be fixed.

Regards
Daniel

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

Reply via email to