Hello,
I’ve got a screen where UI components build dynamically based on saved data. I’m able to access these for show/hide functionality in the following way:
private void hideAllQuestions() {
for (SurveyQuestion question : surveyQuestions) {
String questionComponentId = getQuestionComponentId(question);
Component component = Objects.requireNonNull(questionsBox.getComponent(questionComponentId));
component.setVisible(false);
}
}
(Obviously I could just hide the UI container as a whole, but this was just an example of how I’m doing it.)
This works beautifully. However I’m not able to access the setRequired
method. My customer has one particular component that they would like to change to not required based on another component’s selected value, but they want the component to still be visible so the users can provide information either way. How can I achieve this? Is there a way to cast the component directly based on instanceof
type to access the setRequired
modifier?
Thanks,
Adam