Thursday, November 24, 2011

ADF Faces: Navigate on Checkbox selection

Used in Version: 11.1.1.2

As you may have noticed there is no action attribute on af:selectBooleanCheckbox. So how could you trigger a navigation case if user changed selection state of the checkbox.

In a customers scenario I need to trigger a navigation in a BTF from a checkbox insige a jsff

<af:selectBooleanCheckbox label="Klick me" id="sbc1"
                                       selected="#{MyBean.selected}"
                                       autoSubmit="true"/>

image

MyBean.java looks like

 public void setSelected(String value) {
final FacesContext context = FacesContext.getCurrentInstance();

if ("true".equalsIgnoreCase(value)) {
// checkbox is selected
context.getApplication()
.getNavigationHandler()
.handleNavigation(context,null,"selected");
return;
}

// checkbox is not selected
context.getApplication()
.getNavigationHandler()
.handleNavigation(context,null,"notSelected");
}

No comments:

Post a Comment