I have the following problem ...
I have two selectonchoices that are dependent, that is, as soon as I choose A value in the first selectionchoice, the second should show values ??related to the value I chose in the first:
<af:selectOneChoice label="Razão Social"
binding="#{backing_Inscricao.razao_social}"
autoSubmit="true" id="razao" partialTriggers="plano">
<f:selectItems value="#{backing_Inscricao.tipos}"/>
</af:selectOneChoice>
<af:selectOneChoice label="Tipo de Plano"
binding="#{backing_Inscricao.plano}"
autoSubmit="true" partialTriggers="razao" id="plano">
<f:selectItems value="#{backing_Inscricao.planos}"/>
</af:selectOneChoice>
public SelectItem[] getPlanos() {
if(getRazao_social().getValue()!=null){
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("ExecuteWithParams4"); operationBinding.getParamsMap().put("wcodigo_empresa",Integer.parseInt(getRazao_social().getValue().toString()) );
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}
}
FacesContext fctx = FacesContext.getCurrentInstance();
ValueBinding vbinding = fctx.getApplication().createValueBinding("#{bindings.Assoplanos_usuarioView1Iterator}");
DCIteratorBinding locationsIterBinding = (DCIteratorBinding)vbinding.getValue(fctx);
locationsIterBinding.executeQuery();
locationsIterBinding.setRangeSize(-1);
Row[] locRowsArray = locationsIterBinding.getAllRowsInRange();
planos = new SelectItem[locRowsArray.length];
for (int indx = 0; indx < locRowsArray.length; indx++) {
SelectItem addItem = new SelectItem();
addItem.setLabel((String)locRowsArray[indx].getAttribute("Descricao"));
addItem.setValue(locRowsArray[indx].getAttribute("Codigo"));
planos[indx] = addItem;
}
return planos;
}
public SelectItem[] getTipos() {
FacesContext fctx = FacesContext.getCurrentInstance();
ValueBinding vbinding = fctx.getApplication().createValueBinding("#{bindings.Empresas_acessoView1Iterator}");
DCIteratorBinding locationsIterBinding = DCIteratorBinding)vbinding.getValue(fctx);
locationsIterBinding.executeQuery();
locationsIterBinding.setRangeSize(-1);
Row[] locRowsArray = locationsIterBinding.getAllRowsInRange();
tipos = new SelectItem[locRowsArray.length];
for (int indx = 0; indx < locRowsArray.length; indx++) {
SelectItem addItem = new SelectItem();
addItem.setLabel((String)locRowsArray[indx].getAttribute("Razsoc"));
addItem.setValue(locRowsArray[indx].getAttribute("Codigo"));
tipos[indx] = addItem;
}
return tipos;
}
It is working perfectly .. When I change the value in the first selectoncho the second is updated normally ... but when I choose a value in the second selectionchoice, and then I try change a value in the first .. it stops working ....: cry:
I tried to put a
getPlano().resetvalue()
... to clean the second ... and it was working well ... but then when I click on a button to be able to send the data .. he is resetting também and sending the value in white !!! ....