I am having trouble getting a selectOneRadio component to cause an executeQuery on a view object. The view object has a view criteria that expects a number parameter. I dropped the VC method binding as an ADF Parameter form (with input text with label & query button) and can set the number, execute the query with the button and all works as expected. I created a selectOneRadio component with a static list to represent the possible choices for the VC (e.g. 1, 2, 3...). I then created a backing bean for the query button and a valueChangeListener method for the selectOneRadio component to set the parameter in the backing bean of the query. I modified the button method to invoke the valueChangeListener method with a null object, and moved the OperationBinding code into this method to execute the request. After this modification, the query executes properly with the parameter value of the radio button when the button is pushed. But, what I want is to remove the requirement to push the button, so that the change in the selectOneRadio component will execute the query without having to press the button.
I am sure there is something simple that I'm missing, but cannot figure it out. Any suggestions?
Here are the component values from the jspx page:
<af:panelGroupLayout layout="vertical" id="pgl3">
<af:panelGroupLayout layout="vertical" id="pgl4">
<af:panelHeader text="CompanyQuery" id="ph3"
inlineStyle="height:27px;"/>
</af:panelGroupLayout>
<af:selectOneRadio label="Select Company" id="sor1"
value="3"
layout="horizontal" autoSubmit="true"
valuePassThru="true" immediate="false"
valueChangeListener="#{backingBeanScope.CompanyRadioGroupBean.radioButtonChange}">
<af:selectItem label="Company 1" value="1" id="si2"/>
<af:selectItem label="Company 2" value="2" id="si3"/>
<af:selectItem label="Both Companies" value="3" id="si1"/>
</af:selectOneRadio>
<af:panelFormLayout id="pfl2">
<af:inputText value="#{bindings.setCompanyVC.company}"
label="#{bindings.company.hints.label}"
required="#{bindings.company.hints.mandatory}"
columns="#{bindings.company.hints.displayWidth}"
maximumLength="#{bindings.company.hints.precision}"
shortDesc="#{bindings.company.hints.tooltip}"
id="it2"
validator="#{backingBeanScope.CompanyRadioGroupBean.it2_validator}">
<f:validator binding="#{bindings.company.validator}"/>
</af:inputText>
<af:commandButton actionListener="#{bindings.setCompanyVC.execute}"
text="setCompanyVC"
disabled="#{!bindings.setCompanyVC.enabled}"
id="cb2"
action="#{backingBeanScope.CompanyRadioGroupBean.queryCompany}"/>
</af:panelFormLayout>
</af:panelGroupLayout>
Here are the methods in the CompanyRadioGroupBean backing bean:
public void setCompanyValue(RichInputText companyValue) {
this.companyValue = companyValue;
}
public RichInputText getCompanyValue() {
return companyValue;
}
public BindingContainer getBindings() {
return BindingContext.getCurrent().getCurrentBindingsEntry();
}
public String queryCompany() {
radioButtonChange(null);
return null;
}
public void radioButtonChange(ValueChangeEvent valueChangeEvent) {
// Add event code here...
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("setCompanyVC");
AttributeBinding ab1 = (AttributeBinding) bindings.get("company");
List errors = null;
if (valueChangeEvent != null) {
RichSelectOneRadio rsor = (RichSelectOneRadio)valueChangeEvent.getSource();
RichInputText rit = new RichInputText();
Object value = rsor.getValue();
rit.setValue(value);
this.setCompanyValue(rit);
System.out.println("The radio button value is "+value);
Integer intValue = new Integer((String)value);
ab1.setInputValue(intValue);
errors = ab1.getErrors();
}
Object result = operationBinding.execute();
errors = operationBinding.getErrors();
System.out.println(errors+" (errors)");
}
public void it2_validator(FacesContext facesContext,
UIComponent uIComponent, Object object) {
// Add event code here...
}