2
I have a problem to load the selected value in <f:selectItem>
by the user
When render gets that way:
<option value="320">Coordenador Desenvolvimento</option>
I wanted the attribute to be set selected="selected"
Follow my xhtml:
<div class="span3">
<h:selectOneMenu id="txttecnicosselecionaveis" required="true"
requiredMessage="Selecione o tecnico responsável pelo cliente"
binding="#{cadastradorCliente.txtTecnicosSelecionaveis}" disabled="#{cadastradorCliente.desabilitarCampos}" styleClass="span12">
<f:selectItems value="#{cadastradorCliente.tecnicosSelecionaveis}"
itemLabel="#{cliente.tecnico.nome}" itemValue="#{cliente.tecnico.id}"/>
</h:selectOneMenu>
</div>
My MB where I recover the data
public String actSelecionarTabela()
{
FacesContext context = FacesContext.getCurrentInstance();
HttpSession sessao = (HttpSession) context.getExternalContext().getSession(true);
if (sessao != null)
{
sessao = (HttpSession) context.getExternalContext().getSession(true);
sessao.setAttribute("cliente", cliente);
}
txtCnpj.setValue(cliente.getCnpj());
txtRazaoSocial.setValue(cliente.getRazaoSocial());
txtNomeFantasia.setValue(cliente.getNomeFantasia());
txtInscricaoEstadual.setValue(cliente.getInscricaoEstadual());
txtSite.setValue(cliente.getSite());
txtEndereco.setValue(cliente.getEndereco().getDescricao());
txtResponsavel.setValue(cliente.getResponsavel().getNome());
txtTelefone.setValue(cliente.getResponsavel().getContato().getTelefone());
txtEmail.setValue(cliente.getResponsavel().getContato().getEmail());
txtCemail.setValue(cliente.getResponsavel().getContato().getCemail());
txtAtivo.setValue(cliente.isAtivo());
txtTecnicosSelecionaveis.setValue(cliente.getTecnico().getCodigo());
txtGerentesSelecionaveis.setValue(cliente.getGerente().getCodigo());
When I return the data saved on the screen back so my selectItem
I would like to return already loaded the values that were selected the first time
Here is the result of database saved data
I’ve tried several ways and I can’t fix it, anyone has any idea?
"i wanted it to be set the attribute Selected="Selected" - I didn’t understand.
– Caffé
Example I have already registered in database with the id of selectItem, however I want to load on the screen back the data for the user to be able to edit, I can recover on screen all the data of the register less my selected item
– Wellington Avelino
How about posting a property to the bean that returns the selected item, and then setting the component’s "value" attribute pointing to this property
<h:selectOneMenu value="#{cadastradorCliente.tecnicoSelecionado}">
?– Caffé
@Caffé my returns to xhtml are returning the correct value, the problem is when I click to select on the screen and trigger my actionListener "txtTecnicosSelectible.setValue(client.getTecnico().getCodigo());" It brings me the code that was saved it just doesn’t click on the screen :(
– Wellington Avelino
I imagine that the problem is not only display, but that you also could not yet save in the bank a selected item on the page (inserted in the bank by another means). Right?
– Caffé
With you, I save the id and name of the selected technician and manager , I can also change this data through the application. It just doesn’t display :(
– Wellington Avelino
"the problem is when I click to select on the screen and fires my actionListener..." Well, I really couldn’t understand the problem. Good luck there!
– Caffé