WarnerJan Veldhuis wrote:
Gents,
Where is the best place to modify the presence of fields in a Form? I
have tried to modify the fields by overriding Form#getFieldList(),
Form#onInit(), Form#onProcess(), but I keep running into issues, where
the onLogin() ActionListener of the Submit gets fired after all these
methods.
I assume your login form is a stateless page and you want to check in
your onLogin method whether to force a logout?
Couple of ways you can try (perhaps you already did :)
1. The event methods onGet/onPost and onRender are all invoked after
the actionListener is dispatched, so you can override them to add the
"forceLogoff" checkbox. However on the subsequent request the checkbox
won't be part of the Form when the Form is processed (as the checkbox
is only added after the onProcess event). But the "forceLogoff"
request parameter will still be present so you can check if its
available and force the logoff.
2. Dynamic Pages can be difficult to work with in a stateless
environment because at design time some controls (in your case the
checkbox) are not part of the Form. So how about reversing this
problem and ensuring that all dynamic parts are part of the Form at
design time. Then at runtime instead of adding the checkbox you
instead remove it. For example you can have a boolean Page property,
"userLoggedOn", which is false by default. In the onRender method you
can query this check whether the checkbox should be rendered or not.
By default "userLoggedOn" will be false so you end up removing the
checkbox. However if your login fails, you can set "userLoggedOn" to
true, meaning it will render and when the Form submits, you can check
if logoff should be forced.
Hope this helps.
kind regards
bob