[
https://issues.apache.org/jira/browse/WICKET-3899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17955592#comment-17955592
]
ASF GitHub Bot commented on WICKET-3899:
----------------------------------------
papegaaij commented on code in PR #1033:
URL: https://github.com/apache/wicket/pull/1033#discussion_r2120274875
##########
wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java:
##########
@@ -2059,13 +2020,13 @@ protected final void validateFormValidator(final
IFormValidator validator)
}
// check if the dependent component is visible
and is attached to
// the page
- else if
(!isFormComponentVisibleInPage(dependent))
+ else if (!dependent.isVisibleInHierarchy() ||
!dependent.isEnabledInHierarchy() || !dependent.isFormParticipant())
Review Comment:
IMHO an `IFormValidator` should be executed if at least one of the dependent
components is enabled. It should not be necessary for all components to be
enabled. We've been bitten by this problem as well.
Suppose you have a form where you can enter a certain property in 2 ways.
For example, a form where you can upload a certificate with private key, either
in PKCS#12 format (1 single file) or in PEM format (2 files). You can toggle
these fields via radio buttons, so only one of the 2 formats is visible at a
given moment. In this form, there's also a field for the domain name, which
needs to match with the provided certificate. The easiest way would be to have
an `IFormValidator` with all these fields as dependent components. However,
this does not work as either the PKCS#12 or the PEM fields are not visible, so
your validator is never executed.
A problem I do see is that disabled components do not participate in form
processing, so their converted input is always null. Your validator needs to be
able to deal with this properly. In the example above, this is not an issue,
because the validator simply checks the state of the radio buttons before
reading either the PKCS#12 or PEM fields.
> IFormVisitorParticipant don't get tested when validating form validators
> dependent components
> ---------------------------------------------------------------------------------------------
>
> Key: WICKET-3899
> URL: https://issues.apache.org/jira/browse/WICKET-3899
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4.17, 1.5-RC5.1
> Reporter: Pedro Santos
> Assignee: Pedro Santos
> Priority: Major
> Fix For: 10.3.0
>
> Attachments: WICKET-3899-fix-test.patch, WICKET-3899.patch,
> image-2025-01-29-09-26-47-144.png
>
>
> Currently Form#validateFormValidator only check if dependent components are
> visible in the page, which causes it to validate forms depending on
> components that didn't participate in the form processing like:
> * disable form components
> * components under an IFormVisitorParticipant parent that returned false in
> the #processChildren test
> * components inside a form that was not processed due the
> Form#wantSubmitOnParentFormSubmit test inside a parent form
--
This message was sent by Atlassian Jira
(v8.20.10#820010)