And in addition, I think It would be necessary to implement this in
onSubmit() rather than say adding validators in fields.
as otherwise I'd guess it'd either be flagged in both fields or the
first field if they don't match.
I guessed I may have 'found a solution' e.g. in onSubmit() I'd perhaps
check that and if it doesn't match, I call
error("message") so that the reporter would instead be the Form itself.
Then I can perhaps make a custom filter to check that it is the form
itself rather than the children fields.
Well, I'm not sure if there are better ways.
Thanks in advance.
On 07/04/2025 00:52, andrew goh wrote:
I'm using Apache Wicket 9. I'm looking at field validations and
feedback messages and I'm wondering how to do this properly:
I've got a form of the nature
<input type="password" wicket:id="field1" label="password"/>
<span wicket:id="feedback">field feedback will be here</span>
<input type="password" wicket:id="field2" label="confirm password"/>
<span wicket:id="feedback">field feedback will be here</span>
<hr>
<span wicket:id="feedback">global feedback will be here</span>
---
ComponentFeedbackMessageFilter:
https://nightlies.apache.org/wicket/guide/9.x/single.html#_displaying_feedback_messages_and_filtering_them
works well for the field feedbacks.
But that supposing that I'm checking that password and confirm
password should match, and if they don't I post an error message in
the 'global feedback' feedback that is for the form.
What would be a good way to do that? As it seemed
ContainerFeedbackMessageFilter would simply include messages from all
the child fields.
I need to flag a ValidationError or FeedbackMessage as 'global' and
pass that such that I can perhaps construct a custom
FeedbackMessageFilter to look for 'global' error messages, e.g. to say
that password and confirm password do not match.
But it'd seem FeedbackMessage passed in public interface
IFeedbackMessageFilter
boolean accept(FeedbackMessage message);
And FeedbackMessage neither contains a link to the original
ValidationError() nor can a custom FeedbackMessage be passed
sub-classed say in ValidationError.setMessage(String message). e.g.
that setMessage uses a custom sub-classed FeedbackMessage instead of a
string.
Thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org