Thanks for the idea, but there doesn't seem to be any difference between adding 
the components before or after calling super.onInitialize()
 

Gesendet: Freitag, 24. November 2023 um 13:56 Uhr
Von: "Martin Grigorov" <mgrigo...@apache.org>
An: users@wicket.apache.org
Betreff: Re: Odd behaviour with StatelessForm and onInitialize()
Hi,

I don't have time to debug the problem right now but could you try
something: swap these two lines -
https://gist.github.com/TekkiWuff/824e820427c16e204bde68e95fd566a6#file-homepage-java-L25-L26
I.e. first add() the components to the page and then call
super.onInitialize()

On Thu, Nov 23, 2023 at 5:09 PM <ihmehlm...@gmx.de> wrote:

> 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[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
>
>

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

Reply via email to