I'm trying to dynamically set the isRequired() field for a component, but not sure how to do so. For example, in the following example, I'd like to set the streetAddress component to be required if the pin1 field has data entered for it. My first attempt (which doesn't work since it's binding statically) is as follows:

 PINTextField pin1 = new PINTextField("pin1",
                new PropertyModel(propertyUse, "otherPropertyPin1"));
        pin1.add(StringValidator.maximumLength(20));
        commonQuestionsWMC.add(pin1);

streetAddress1.add(StringValidator.maximumLength(35)).setRequired(isCommonQuestionsVisible);
        streetAddress1.setRequired(StringUtils.isNotBlank(pin1.getValue()));
        commonQuestionsWMC.add(streetAddress1);

Reply via email to