Posts Tagged ‘af:panelGroupLayout’

It is possible to disable each component one by one but the easiest method is getting the list of all the components within the af:panelGroupLayout on page load and setting the properties to the desired status for each one. The same solution can be performed also for other surrounding element.

First bind your component (af:panelGroupLayout in this case) in your managed bean:


RichPanelGroupLayout yourPanelGroupBind;
public void setYourPanelGroupBind(RichPanelGroupLayout yourPanelGroupBind) {
this.yourPanelGroupBind = yourPanelGroupBind;
}
public RichPanelGroupLayout getYourPanelGroupBind() {
return yourPanelGroupBind;
}

Then within a method do this:


List outer = yourPanelGroupBind.getChildren();
for (UIComponent outerComponent : outer) {
if (outerComponent instanceof RichPanelFormLayout) {
List uiComponentList = outerComponent.getChildren();
for (UIComponent uiComponent : uiComponentList) {
if (uiComponent instanceof RichPanelLabelAndMessage) {
List uiComponentList2 = uiComponent.getChildren();
for (UIComponent uiComponent2 : uiComponentList2) {
if (uiComponent2 instanceof RichInputText) {
((RichInputText)uiComponent2).setDisabled(true);
} else if (uiComponent2 instanceof RichSelectBooleanCheckbox) {
((RichSelectBooleanCheckbox)uiComponent2).setDisabled(true);
} else if (uiComponent2 instanceof RichInputDate) {
((RichInputDate)uiComponent2).setDisabled(true);
} else if (uiComponent2 instanceof RichSelectOneChoice) {
((RichSelectOneChoice)uiComponent2).setDisabled(true);
} else if (uiComponent2 instanceof RichPanelGroupLayout) {
List uiComponentList3 = uiComponent2.getChildren();
for (UIComponent uiComponent3 : uiComponentList3) {
if (uiComponent3 instanceof RichInputText) {
((RichInputText)uiComponent3).setDisabled(true);
} else if (uiComponent3 instanceof RichSelectBooleanCheckbox) {
((RichSelectBooleanCheckbox)uiComponent3).setDisabled(true);
} else if (uiComponent3 instanceof RichInputDate) {
((RichInputDate)uiComponent3).setDisabled(true);
} else if (uiComponent3 instanceof RichSelectOneChoice) {
((RichSelectOneChoice)uiComponent3).setDisabled(true);
}}}}}}}

The code above checks for a wide variety of components that might be located within the af:panelGroupLayout.