I need your assistance in rendering inputText based on the selecttio of the selectManyCheckbox in the xhtml. The code is:
<p:selectManyCheckbox id="basic" value="#{user1.selectedConsoles}">
<f:selectItem itemLabel="Xbox One SS" itemValue="XboxOne" />
<f:selectItem itemLabel="PS4 SS" itemValue="PS4" />
<f:selectItem itemLabel="Wii U SS" itemValue="WiiU" />
<p:ajax listener="#{user1.renderInput}" update="name"/>
</p:selectManyCheckbox>
<h:panelGroup id="name">
<p:inputText value="" rendered="#{user1.renderText}"/>
</h:panelGroup>
And the bean code:
private String[] selectedConsoles; //Setter & Getter
private List<String> list = new ArrayList<String>(); //Setter & Getter
private boolean renderText = false; //Setter & Getter
public void renderInput() {
list= Arrays.asList(selectedConsoles);
if (list.contains("PS4")) {
renderText = true;
}
else if (!list.contains("PS4")) {
renderText = false;
}
}
In the above case, once I have selected PS4, the inputText will be shown. But when I unckeck PS4, the inputText will remain visible in the form and will not be 'unrendered'. How can I achieve this.