I have a "registration" page where the user fills some info, including some bank account info.
There are 2 ways the user can Select a bank (and load the info from that bank):
- He can Select the name of the bank from the selectOneMenu, and the code of the Bank will be loaded into the inpuText;
- He can fill the code of the Bank into the inputText, and the Bank will be selected from the selectOneMenu.
The first part of the function is working fine, I'm having a problem when I try to select an item from the ComboBox after inserting the code into the inputText.
This is the page component:
<p:panel header="Dados Bancários" toggleable="true" toggleableHeader="true" id="panelBancoPF">
<h:panelGrid columns="2" columnClasses="coluna1,coluna2">
<h:outputText value="Código do Banco: " />
<h:panelGrid columns="4" columnClasses="coluna2,coluna1,coluna2,coluna2">
<h:inputText size="10" onkeypress="mascaraInteiro(this);" value="#{pess.dsnobanco}" maxlength="38">
<p:ajax onstart="PF('dialogProcessando').show();"
onsuccess="PF('dialogProcessando').hide();"
onerror="PF('dialogProcessando').hide();"
oncomplete="PF('dialogProcessando').hide();"
event="change"
listener="#{cadastroPeritoControl.encontraBanco('Fisica')}"/>
</h:inputText>
<h:outputText value="Nome do Banco: " />
<p:selectOneMenu id="listaNomesBancos" size="50" widgetVar="editaBanco"
filterMatchMode="contains" value="#{cadastroPeritoControl.bancoSelecionado}"
converter="CptbancoConverter" rendered="#{not empty cadastroPeritoControl.listaBancos}"
maxlength="200" onkeyup="maiuscula(this)" >
<f:selectItem itemValue="" itemLabel="" noSelectionOption="true" />
<f:selectItems value="#{cadastroPeritoControl.listaBancos}"
var="banco" itemLabel="#{banco.fullName}" />
<p:ajax event="change" update="formPrincipal:panelBancoPF"
listener="#{cadastroPeritoControl.bancoOnChange('Fisica')}"
onstart="PF('dialogProcessando').show();"
onsuccess="PF('dialogProcessando').hide();"
onerror="PF('dialogProcessando').hide();"
oncomplete="PF('dialogProcessando').hide();" />
</p:selectOneMenu>
</h:panelGrid>
....
First I've tried updating the "bancoSelecionado" Object in the backend, but that was just overwriting the last selected Object, so I've saw there's a selectValue(value) function on PrimeFaces that looks like it's exactly what I need, but I don't know how to use it, and every place I've tried to put it didn't worked.
if someone can give me an example of how to use this selectValue(value) function, or if there's a better way to do it using PrimeFaces, or creating a function on the backend (Java) I'd appreciate it.