ValueActionListener não funciona

1 resposta
E

Olá pessoal!

Estou com um problema com JSF. Tenho um “ComboBox” e quero acessar seu ValueChengeListener em um Bean gerenciado, mas parece que o evento não ocorre. Já pesquisei muito e nada!

Managed Bean:

package web.managedbean;

import javax.enterprise.context.RequestScoped;

import javax.inject.Named;

import javax.faces.event.ValueChangeEvent;

/**
*

  • @author Toshiba
    
    */
    
    <a class="mention" href="/u/named">@Named</a>(value = “index”)
    
    @RequestScoped
    
    public class Index {
    

    private Integer valorPesquisaMaxLength;
    private String valorPesquisaValue;

    public Index() {
    
    valorPesquisaMaxLength = 11;
    
    valorPesquisaValue = “”;
    
    }
    
    public void campoPesquisaValueChangeListener(ValueChangeEvent event) {
    
    switch ((Integer)event.getNewValue()) {
    
    case 1:
    
    valorPesquisaMaxLength = 11;
    
    break;
    
    case 2:
    
    valorPesquisaMaxLength = 14;
    
    break;
    
    case 3:
    
    valorPesquisaMaxLength = 11;
    
    break;
    
    case 4:
    
    valorPesquisaMaxLength = 10;
    
    break;
    
    case 5:
    
    valorPesquisaMaxLength = 8;
    
    break;
    
    default:
    
    valorPesquisaMaxLength = 0;
    
    break;
    
    }
    
    valorPesquisaValue = “”;
    
    }
    
    public Integer getValorPesquisaMaxLength() {
    
    return valorPesquisaMaxLength;
    
    }
    
    public void setValorPesquisaMaxLength(Integer valorPesquisaMaxLength) {
    
    this.valorPesquisaMaxLength = valorPesquisaMaxLength;
    
    }
    
    public String getValorPesquisaValue() {
    
    return valorPesquisaValue;
    
    }
    
    public void setValorPesquisaValue(String valorPesquisaValue) {
    
    this.valorPesquisaValue = valorPesquisaValue;
    
    }
    
    }
    

JSF:

<?xml version='1.0' encoding='UTF-8' ?> Sistema Gestor de Transporte por Moto-Táxi Coloque aqui os componetes
<h:selectOneMenu id="CampoPesquisa" valueChangeListener="#{index.campoPesquisaValueChangeListener(event)}">
        <f:selectItem itemLabel="CPF" itemValue="1"></f:selectItem>
        <f:selectItem itemLabel="CNPJ" itemValue="2"></f:selectItem>
        <f:selectItem itemLabel="CNH" itemValue="3"></f:selectItem>
        <f:selectItem itemLabel="Nº da Permissão" itemValue="4"></f:selectItem>
        <f:selectItem itemLabel="Nº da Placa" itemValue="5"></f:selectItem>
    </h:selectOneMenu>
    
    <b></b>
    
    <h:inputText id="ValorPesquisa" size="20" maxlength="#{index.valorPesquisaMaxLength}" value="#{index.valorPesquisaValue}">
    </h:inputText>

</h:body>

Me ajudem por favor! Desde já agradeço!

1 Resposta

ViniGodoy
Criado 5 de maio de 2012
Ultima resposta 6 de mai. de 2012
Respostas 1
Participantes 2