function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Felipe DiasFelipe Dias 

Selected value from picklist always returns Null.

Hello!

 

I'm trying to do the following:

 

When the user select a different value on the picklist on the page. It has to call an action function that on the controller, will check what is the value selected and do different things depending on what was select.

 

PAGE:

...

 <apex:inputField label="Modal: " value="{!Opc.Modal__c}" onchange="return VModal()"/>

...

<apex:actionFunction action="{!Verifica}" name="VModal" immediate="TRUE"/>

 

CONTROLLER:

 

Public pageReference Verifica(){
        if(Opc.Modal__c == '01'){ 

               visible = TRUE;
          }  
        Return null;
}

 

 

When I select the option '01' the variable 'Visible' doens't turns TRUE.  The thing is that the value from the picklist is returning Null. Whatever option from the list I select it always returns null.

I tried to create a variable called "message" to show the value selected from the picklist, and the value is Null.

 

 

All of this is on a TabPanel, I don't know if it changes something, but is the first time I use Tabs and things doesn't seem to work as it should on then.

 

 

Can anybody help?

 

Thx

Felipe.

 

Avidev9Avidev9
Remove the immediate="true" from the actionfunction.

<apex:actionFunction action="{!Verifica}" name="VModal" immediate="TRUE"/>

Felipe DiasFelipe Dias

When I do this, and select the picklist the page tries to validate the requiered fields. And then don't complete the action.

 

thx

Avidev9Avidev9
Well then you have to add a dummy rerender attribute, Or rerender the section that doesnt have any validations involved

<apex:actionFunction action="{!Verifica}" name="VModal" rerender="x"/>
Felipe DiasFelipe Dias

It didn't work.


It still doesn't became TRUE. : (

 

Avidev9Avidev9
Are you sure you have removed immediate="true" from action function?
Felipe DiasFelipe Dias

Yes I am. Now the code is like this:

 

Page:

 

<apex:actionFunction action="{!Verifica}" name="VModal" rerender="PainelRod"/>

<apex:outputPanel id="PainelRod" rendered="{!Visivel}">

 

Controller:

 

Public pageReference Verifica(){
        if(Opc.Modal__c == '01'){ 

               visible = TRUE;
          }  
        Return null;
}

Avidev9Avidev9
Public pageReference Verifica(){
System.debug('######Opc.Modal__c###########'+Opc.Modal__c);
if(Opc.Modal__c == '01'){
visible = TRUE;
}
Return null;
}

Check the debug log if the value is being set.

Another thing try to rerender the parent component of "PainelRod"

Something like
<apex:actionFunction action="{!Verifica}" name="VModal" rerender="PainelRodParent"/>

<apex:outputPanel id="PainelRodParent" >
<apex:outputPanel id="PainelRod" rendered="{!Visivel}">
Felipe DiasFelipe Dias

 10:22:54.172 (172911000)|USER_DEBUG|[271]|DEBUG|RetornoPicklist:null

 

It really returns null. I'm using a picklist from a custom object. 'll try creating a pickilist on the page and adding the items to check what it will return.

Avidev9Avidev9
Can you post your full code?
The seems to be somewhere else
Felipe DiasFelipe Dias

Yes, here it is: 

I created this selectlist picklist Modal2 as I said before, but it also returns null.

 

PAGE:

 

<apex:page standardController="CTe__c" extensions="ControllerEmissaoCTe">
<apex:form >
<apex:pageblock title="Emissão CTe">

<apex:tabPanel switchType="client" selectedTab="Abertura" id="CTe" tabClass="activeTab" inactiveTabClass="inactiveTab"> 
<apex:tab label="Abertura" name="Abertura" id="Abertura" > 
<apex:outputPanel id="PainelAbertura" >
<apex:pageBlockSection title="Informações iniciais" columns="2" > 


<apex:inputField label="Nº CTe: " value="{!CTe__c.Numero_CTe__c}"/>
<apex:inputField label="Serie: " value="{!CTe__c.Serie__c}"/>
<apex:inputField label="Emitente: " value="{!CTe__c.Emitente__c}"/>
<apex:inputField label="Destinatário: " value="{!CTe__c.Pessoa__c}"/>
<apex:inputField label="Tomador: " value="{!CTe__c.Tomador__c}"/>
<apex:inputField label="Recebedor " value="{!CTe__c.Recebedor__c}"/>
<apex:inputField label="Expedidor: " value="{!CTe__c.Expedidor__c}"/>
<apex:inputField label="Cid. Inicio prestação : " value="{!CTe__c.Cidade_inicio_de_prestacao__c}"/>
<apex:inputField label="Cid. Fim de prestação: " value="{!CTe__c.Cidade_termino_de_prestacao__c}"/>
<apex:inputField label="Cid. Envio Ct-e: " value="{!CTe__c.Cidade_de_envio_CTe__c}"/>
<apex:inputField label="Modal: " value="{!OpcCte.Modal__c}" onchange="return VModal()"/>

<apex:selectList size="1" value="{!tipoConsulta}" label="Modal2" onchange="return VModal()">
<apex:selectOptions value="{!tipo2}"/>
</apex:selectList>
<apex:inputField label="Tipo de serviço: " value="{!CTe__c.Tipo_de_servico__c}"/>
<apex:inputField label="Tipo de conhecimento: " value="{!CTe__c.Tipo_de_conhecimento__c}"/>
<apex:inputField label="CFOP: " value="{!CTe__c.CFOP__c}"/> 
<apex:inputField label="Recebedor retira no Aeroporto, Filial, Porto ou Estação de Destino? " value="{!CTe__c.Recebedor_retira__c}"/> 
<apex:inputField label="Detalhes da retirada " value="{!CTe__c.Detalhes_da_retirada__c}"/> 
</apex:pageBlockSection>
<apex:pageBlockSection title="Detalhes da entrega" columns="2" > 


<apex:inputField label="Tipo de data programada: " value="{!Tipo.Tipo_de_data_programada__c}"> 
<apex:actionSupport action="{!VerificaData}" immediate="TRUE" event="onchange" reRender="PainelAbertura"/>
</apex:inputField> 
<apex:inputField label="Data&colon; " value="{!CTe__c.Data_programada__c}" rendered="{!Data}"/> 
<apex:inputField label="De: " value="{!CTe__c.Data_inicial__c}" rendered="{!IF(CTe__c.Tipo_de_data_programada__c=='1 - Na data',true,false)}"/> 
<apex:inputField label="Até: " value="{!CTe__c.Data_final__c}" rendered="{!Data2}"/> 
</apex:pageBlockSection> 
</apex:outputpanel>
</apex:tab>
<apex:tab label="Documentos" name="Documentos" id="Documentos" > 



<apex:outputPanel id="PainelDocumentos"> 

<apex:pageBlockSection title="Inclusão de documentos" columns="2" > 
</apex:pageBlockSection>
<apex:pageBlock >
<apex:pageBlockButtons location="Top">
<apex:commandButton value="NFe" action="{!InserirNFe}" immediate="TRUE" rendered="{!BTNFeVisivel}" reRender="PainelDocumentos"/> &nbsp;&nbsp;&nbsp;
<apex:commandButton value="Nota Fiscal" action="{!InserirNFe}" immediate="TRUE" rendered="{!BTNFVisivel}" reRender="PainelDocumentos"/> &nbsp;&nbsp;&nbsp;
<apex:commandButton value="Outros" action="{!InserirNFe}" immediate="TRUE" rendered="{!BTOutrosVisivel}" reRender="PainelDocumentos"/> 
</apex:pageBlockButtons>
</apex:pageBlock>


<apex:pageBlockSection columns="2" > 

<apex:commandButton value="Inserir" action="{!InserirDoc}" rendered="{!BTInserirVisivel}" rerender="PainelDocumentos" immediate="true"/> 

<apex:inputField Value="{!Nota.Chave_NF_e__c}" rendered="{!NFeVisivel}" />
<apex:inputField Value="{!Nota.Romaneio__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Pedido__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Modelo__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Serie_NF__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Numero_NF__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Emissao_NF__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Base_de_Calculo_ICMS__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Base_de_calculo_ICMS_ST__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Valor_total_dos_produtos__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Peso__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.PIN_SUFRAMA__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.CFOP_predominante__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Valor_total_do_ICMS__c}" rendered="{!NFVisivel}" /> 


</apex:pageBlockSection>



<br/><br/><b>Itens inseridos</b><hr color="#66CDAA"></hr>
<apex:pageBlockTable value="{!itemSalvo}" var="lst" rendered="{!TBDocVisivel}">
<apex:column headervalue="Chave" value="{!lst.Chave_NF_e__c}"/> 

</apex:pageBlockTable> 
</apex:outputPanel> 

</apex:tab>
<apex:tab label="Informação da carga" name="infCarga" id="infCarga" > 
<apex:pageBlockSection columns="2" > 
<apex:inputField Value="{!CTe__c.Valor_da_carga__c}" />
<apex:inputField Value="{!CTe__c.Produto_predominante__c}" />
<apex:inputField Value="{!CTe__c.Caracteristica_da_carga__c}" ><apex:outputLabel >EX:'FRIA','GRANEL','REFRIGERADA','MEDIDAS','12X12X12'</apex:outputLabel>
</apex:inputField>
</apex:pageBlockSection>
<br/><br/><b>Cargas</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!carga.Quantidade__c}"/>
<apex:inputField value="{!carga.Tipo_de_medida__c}"/>
<apex:inputField value="{!carga.Unidade__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!cargas}" var="c">
<apex:column value="{!c.Quantidade__c}"/>
<apex:column value="{!c.Tipo_de_medida__c}"/>
<apex:column value="{!c.Unidade__c}"/>

</apex:pageBlockTable>

<br/><br/><b>Containers</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!container.Name}"/>
<apex:inputField value="{!container.Prevista_de_entrada__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!containers}" var="con">
<apex:column value="{!con.Name}"/>
<apex:column value="{!con.Prevista_de_entrada__c}"/>

</apex:pageBlockTable>

<br/><br/><b>Seguros</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!seguro.Name}"/>
<apex:inputField value="{!seguro.Numero_da_Apolice__c}"/>
<apex:inputField value="{!seguro.Numero_da_averbacao__c}"/>
<apex:inputField value="{!seguro.Responsavel__c}"/>
<apex:inputField value="{!seguro.Valor_da_carga__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!seguradoras}" var="s">
<apex:column value="{!s.Name}"/>
<apex:column value="{!s.Numero_da_Apolice__c}"/>
<apex:column value="{!s.Numero_da_averbacao__c}"/>
<apex:column value="{!s.Responsavel__c}"/>
<apex:column value="{!s.Valor_da_carga__c}"/>
</apex:pageBlockTable>

<br/><br/><b>Produtor perigosos</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!perigoso.Classe__c}"/>
<apex:inputField value="{!perigoso.Embalagem__c}"/>
<apex:inputField value="{!perigoso.Nome_de_embarque__c}"/>
<apex:inputField value="{!perigoso.ONU__c}"/>
<apex:inputField value="{!perigoso.Ponto_de_fulgor__c}"/>
<apex:inputField value="{!perigoso.Quant_e_tipo_de_volumes__c}"/>
<apex:inputField value="{!perigoso.Quantidade_total__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!perigosos}" var="p">
<apex:column value="{!p.Classe__c}"/>
<apex:column value="{!p.Embalagem__c}"/>
<apex:column value="{!p.Nome_de_embarque__c}"/>
<apex:column value="{!p.ONU__c}"/>
<apex:column value="{!p.Ponto_de_fulgor__c}"/>
<apex:column value="{!p.Quant_e_tipo_de_volumes__c}"/>
<apex:column value="{!p.Quantidade_total__c}"/>
</apex:pageBlockTable>

<br/><br/><b>Veículos novos</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:tab> 

<apex:tab label="Serviços prestados" name="Servicos" id="ServicosCte">

<apex:outputPanel id="Servicos" >
<apex:pageBlockSection title="Inclusão de serviços" columns="2" > 
<apex:inputField value="{!componente.Servico__c}"/>
<apex:inputField value="{!componente.Inclui_no_valor_total_do_CTe__c}"/>
<apex:CommandButton value="Incluir"/> 
</apex:pageBlockSection> 

<br/><br/><b>Itens inseridos</b><hr color="#66CDAA"></hr>
<apex:pageBlockTable value="{!ComponentesInclusos}" var="Comp">
<apex:column headervalue="Serviço" value="{!Comp.Servico__c}"/> 
<apex:column headervalue="Valor" value="{!Comp.Valor__c}"/> 
<apex:column headervalue="Inclui no valor total do CTe" value="{!Comp.Inclui_no_valor_total_do_CTe__c}"/> 
</apex:pageBlockTable> 
</apex:outputPanel>
</apex:tab>


<apex:tab label="Documento anterior" name="DocAnterior" id="DocAnterior">
<b>Emitentes</b><hr color="#66CDAA"></hr>
<apex:pageBlockSection > 
<apex:inputField value="{!EmitenteDoc.Name}"/>
<apex:inputField value="{!EmitenteDoc.Inscricao_estadual__c}"/>
<apex:inputField value="{!EmitenteDoc.Razao_social__c}"/>
<apex:inputField value="{!EmitenteDoc.Logradouro__c}"/>
<apex:inputField value="{!EmitenteDoc.Numero__c}"/>
<apex:inputField value="{!EmitenteDoc.CEP__c}"/>
<apex:inputField value="{!EmitenteDoc.Cidade__c}"/>
</apex:pageBlockSection> 
<apex:pageBlockTable value="{!Emitentes}" var="em">

</apex:pageBlockTable> 
<br/><br/><b>Documetos</b><hr color="#66CDAA"></hr>
<apex:pageBlockSection > 
<apex:inputField value="{!docAnterior.Formato__c}"/>
<apex:inputField value="{!docAnterior.Tipo__c}"/>
<apex:inputField value="{!docAnterior.Numero_do_documento__c}"/>
<apex:inputField value="{!docAnterior.Serie__c}"/>
<apex:inputField value="{!docAnterior.Sub_serie__c}"/>
<apex:inputField value="{!docAnterior.Emissao__c}"/>
<apex:inputField value="{!docAnterior.Chave_CTe__c}"/>

</apex:pageBlockSection> 

<apex:pageBlockTable value="{!ComponentesInclusos}" var="Comp">

</apex:pageBlockTable> 
</apex:tab> 

<apex:tab label="Transporte">
<apex:actionFunction action="{!VerificaModal}" name="VModal" rerender="PainelRodoviarioPai"/>
<apex:outputPanel id="PainelRodoviarioPai">
<apex:outputPanel id="PainelRodoviario" rendered="{!RodoviarioVisivel}">

<apex:pageBlockSection title="Informações rodoviário" columns="2" > 

<apex:inputField value="{!CTe__c.RNTRC__c}"/>
<apex:inputField value="{!CTe__c.Data_entrega__c}"/>
<apex:inputField value="{!CTe__c.conta_frete__c}"/>
<apex:inputField value="{!CTe__c.Lotacao__c}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title="Ordens de coleta" columns="2" >
 
</apex:pageBlockSection>

</apex:outputPanel> 
</apex:outputPanel>
</apex:tab> 
</apex:tabPanel> 
</apex:pageBlock> 
</apex:form>
</apex:page>

 

 

 

 

 

 

CONTROLLER:

 

public with sharing class ControllerEmissaoCTe 
{

    Public Boolean Data{get;set;}
    Public Boolean Data1{get;set;}
    Public Boolean Data2{get;set;}
    Boolean BTNFeVisivel = TRUE;
    Boolean NFeVisivel = FALSE;
    Boolean NFVisivel = FALSE;
    public String MSG{get;set;}
    Boolean BTNFVisivel = TRUE;
    Boolean BTOutrosVisivel = TRUE;
    Boolean BTInserirVisivel = FALSE;
    Boolean TBDocVisivel = FALSE;
    List<nota__c> itemSalvo = new list <nota__c>();
    Container__c container=new Container__c();
    Carga__c carga=new Carga__c();
    Seguradora__c seguro=new Seguradora__c();
    Produto_perigoso__c perigoso=new Produto_perigoso__c();
    CTe__c OpcCte = new CTe__c();
    Boolean RodoviarioVisivel = FALSE;
    
    String tipo2;
    List<SelectOption> opTipo = new List<SelectOption>();
    String tipoConsulta;
    
   
    
    
    
    public ControllerEmissaoCTe(ApexPages.StandardController controller) 
    {
     
        if (controller != null) {
            this.tipo = (CTe__c)controller.getRecord();
        }

    }
    
    public boolean getTBDocVisivel(){
        return TBDocvisivel;
    }
    
    public boolean getRodoviarioVisivel(){
        return RodoviarioVisivel;
    }
       
    public CTe__c getOpcCte(){
        return OpcCte;
    }
 
    
    
    public boolean getBTNFeVisivel(){
    
        
    return BTNFeVisivel;
    }
    
     public boolean getBTInserirVisivel(){
    
        
    return BTInserirVisivel;
    }
    
     public boolean getBTOutrosVisivel(){
    
        
    return BTOutrosVisivel;
    }
     public boolean getBTNFVisivel(){
    
        
    return BTNFVisivel;
    }
       public Nota__c nota = new nota__c();
    
    
    public boolean getNFeVisivel(){
    
    return NFeVisivel;
    }
    
       public boolean getNFVisivel(){
    
    return NFeVisivel;
    }
    
    public Nota__c getNota()
    {
 
        Return nota;
    }
    
    
    
    
    public pageReference VerificaData()
    
    {
    
    getTipo();
        if(Tipo.Tipo_de_data_programada__c == '0 - Sem data definida')
        {
            Data = FALSE;
            Data1 = FALSE;
            Data2= FALSE;
        }else if(Tipo.Tipo_de_data_programada__c == '4 - No período')
        {
            Data = FALSE; 
            Data1 = TRUE;
            Data2= TRUE;
        }
        else 
        {    
            
            tipo.Detalhes_da_retirada__c=Tipo.Tipo_de_data_programada__c + 'ALO';
            Data = TRUE;
            Data1 = FALSE;
            Data2= FALSE;
        }
        
        Return null;
    
    }
         CTe__c Tipo;
         
     public CTe__c getTipoData() 
     {
          
         return Tipo;
     }
            
    
             
      public CTe__c getTipo() 
      {
                 return Tipo;
      }
      
      Public PageReference InserirNFe()
      {
    
      nota = new nota__c();
      nota.clear();
      NFVisivel = TRUE;
      NFeVisivel = FALSE;
      BTNFVisivel = FALSE;
      BTOutrosVisivel = FALSE;
      BTInserirVisivel = TRUE;
      
      Return null;      
      
      }
      
      
       public list<nota__c> getItemSalvo(){
        return itemSalvo;
    }

    public PageReference InserirDoc(){
    
    TBDocVisivel = TRUE;
    

     itemSalvo.add(nota);
     nota__c nota=new nota__c();
     
     return null;  
   
    }
    
    public Carga__c getCarga(){
    
        return carga;
    
    }
    
    List<Carga__c> cargas=new List<Carga__c>();
    
    public List<Carga__c> getCargas(){
    
        cargas=[SELECT Quantidade__c,Tipo_de_medida__c, Unidade__c FROM Carga__c];
    
        return cargas;
    
    }
    
    public Container__c Getcontainer(){
    
        return container;
    
    }
    
    List<Container__c> containers=new List<Container__c>();
    
    public List<Container__c> getContainers(){
    
        containers=[SELECT Name,Prevista_de_entrada__c FROM Container__c];
    
        return containers;
    
    }
    
     public Seguradora__c getSeguro(){
    
        return seguro;
    
    }
    
     List<Seguradora__c> seguradoras=new List<Seguradora__c>();
    
    public List<Seguradora__c> getSeguradoras(){
    
        seguradoras=[SELECT Name, Numero_da_Apolice__c, Numero_da_averbacao__c, Responsavel__c, Valor_da_carga__c FROM Seguradora__c];
    
        return seguradoras;
    
    }
    
    public Produto_perigoso__c getPerigoso(){
    
        return perigoso;
    
    }
    
    List<Produto_perigoso__c> perigosos=new List<Produto_perigoso__c>();
    
    public List<Produto_perigoso__c> getPerigosos(){
    
        perigosos=[SELECT Classe__c,Embalagem__c,Nome_de_embarque__c,ONU__c,Ponto_de_fulgor__c,Quant_e_tipo_de_volumes__c,Quantidade_total__c FROM Produto_perigoso__c];
    
        return perigosos;
    
    }
    
   Componente_do_CTe__c Componente=new Componente_do_CTe__c();
   
    public Componente_do_CTe__c getComponente(){
        Return Componente;
    }
    
      List<Componente_do_CTe__c> ComponentesInclusos=new List<Componente_do_CTe__c>();
   
    public List<Componente_do_CTe__c> getComponentesInclusos(){
        Return ComponentesInclusos;
    }
    
    Pessoa__c EmitenteDoc=new Pessoa__c();
   
    public Pessoa__c getEmitenteDoc(){
        Return emitenteDoc;
    }
    
    List<Pessoa__c> emitentes=new List<Pessoa__c>();

      public List<Pessoa__c> getEmitentes(){
    
        emitentes=[SELECT Name,inscricao_estadual__c,razao_social__c,logradouro__c,numero__c,cep__c,cidade__c FROM pessoa__c];
    
        return emitentes;
    
    }
    
    Documento_anterior__c docAnterior=new Documento_anterior__c();
   
    public Documento_anterior__c getDocAnterior(){
    
        return docAnterior;
    }

    Public pageReference VerificaModal(){
    
        System.debug('RetornoPicklist:'+OpcCte.Modal__c);
        
        System.debug('RetornoPicklist2:'+TipoConsulta);
    
        if(TipoConsulta == '01 - Rodoviário'){
            RodoviarioVisivel = TRUE;
            
        
        
        } 
        Return null;
    
    }
    
    
      public List<SelectOption> getTipo2(){
    
        opTipo.add(new SelectOption('01 - Rodoviário','01 - Rodoviário'));
        opTipo.add(new SelectOption('02 - Aviário','02 - Aviário'));
        
        return opTipo;
    
    }
    
      public String getTipoConsulta(){

       
        return tipoConsulta;
    }
    
   public String setTipoConsulta(String tipoConsulta){
        this.tipoConsulta = tipoConsulta;
        return tipoConsulta;
    }
    
    
}

 

Thanks man.

Felipe DiasFelipe Dias

Yes, here it is: 

I created this selectlist picklist Modal2 as I said before, but it also returns null.

 

PAGE:

 

<apex:page standardController="CTe__c" extensions="ControllerEmissaoCTe">
<apex:form >
<apex:pageblock title="Emissão CTe">

<apex:tabPanel switchType="client" selectedTab="Abertura" id="CTe" tabClass="activeTab" inactiveTabClass="inactiveTab"> 
<apex:tab label="Abertura" name="Abertura" id="Abertura" > 
<apex:outputPanel id="PainelAbertura" >
<apex:pageBlockSection title="Informações iniciais" columns="2" > 


<apex:inputField label="Nº CTe: " value="{!CTe__c.Numero_CTe__c}"/>
<apex:inputField label="Serie: " value="{!CTe__c.Serie__c}"/>
<apex:inputField label="Emitente: " value="{!CTe__c.Emitente__c}"/>
<apex:inputField label="Destinatário: " value="{!CTe__c.Pessoa__c}"/>
<apex:inputField label="Tomador: " value="{!CTe__c.Tomador__c}"/>
<apex:inputField label="Recebedor " value="{!CTe__c.Recebedor__c}"/>
<apex:inputField label="Expedidor: " value="{!CTe__c.Expedidor__c}"/>
<apex:inputField label="Cid. Inicio prestação : " value="{!CTe__c.Cidade_inicio_de_prestacao__c}"/>
<apex:inputField label="Cid. Fim de prestação: " value="{!CTe__c.Cidade_termino_de_prestacao__c}"/>
<apex:inputField label="Cid. Envio Ct-e: " value="{!CTe__c.Cidade_de_envio_CTe__c}"/>
<apex:inputField label="Modal: " value="{!OpcCte.Modal__c}" onchange="return VModal()"/>

<apex:selectList size="1" value="{!tipoConsulta}" label="Modal2" onchange="return VModal()">
<apex:selectOptions value="{!tipo2}"/>
</apex:selectList>
<apex:inputField label="Tipo de serviço: " value="{!CTe__c.Tipo_de_servico__c}"/>
<apex:inputField label="Tipo de conhecimento: " value="{!CTe__c.Tipo_de_conhecimento__c}"/>
<apex:inputField label="CFOP: " value="{!CTe__c.CFOP__c}"/> 
<apex:inputField label="Recebedor retira no Aeroporto, Filial, Porto ou Estação de Destino? " value="{!CTe__c.Recebedor_retira__c}"/> 
<apex:inputField label="Detalhes da retirada " value="{!CTe__c.Detalhes_da_retirada__c}"/> 
</apex:pageBlockSection>
<apex:pageBlockSection title="Detalhes da entrega" columns="2" > 


<apex:inputField label="Tipo de data programada: " value="{!Tipo.Tipo_de_data_programada__c}"> 
<apex:actionSupport action="{!VerificaData}" immediate="TRUE" event="onchange" reRender="PainelAbertura"/>
</apex:inputField> 
<apex:inputField label="Data&colon; " value="{!CTe__c.Data_programada__c}" rendered="{!Data}"/> 
<apex:inputField label="De: " value="{!CTe__c.Data_inicial__c}" rendered="{!IF(CTe__c.Tipo_de_data_programada__c=='1 - Na data',true,false)}"/> 
<apex:inputField label="Até: " value="{!CTe__c.Data_final__c}" rendered="{!Data2}"/> 
</apex:pageBlockSection> 
</apex:outputpanel>
</apex:tab>
<apex:tab label="Documentos" name="Documentos" id="Documentos" > 



<apex:outputPanel id="PainelDocumentos"> 

<apex:pageBlockSection title="Inclusão de documentos" columns="2" > 
</apex:pageBlockSection>
<apex:pageBlock >
<apex:pageBlockButtons location="Top">
<apex:commandButton value="NFe" action="{!InserirNFe}" immediate="TRUE" rendered="{!BTNFeVisivel}" reRender="PainelDocumentos"/> &nbsp;&nbsp;&nbsp;
<apex:commandButton value="Nota Fiscal" action="{!InserirNFe}" immediate="TRUE" rendered="{!BTNFVisivel}" reRender="PainelDocumentos"/> &nbsp;&nbsp;&nbsp;
<apex:commandButton value="Outros" action="{!InserirNFe}" immediate="TRUE" rendered="{!BTOutrosVisivel}" reRender="PainelDocumentos"/> 
</apex:pageBlockButtons>
</apex:pageBlock>


<apex:pageBlockSection columns="2" > 

<apex:commandButton value="Inserir" action="{!InserirDoc}" rendered="{!BTInserirVisivel}" rerender="PainelDocumentos" immediate="true"/> 

<apex:inputField Value="{!Nota.Chave_NF_e__c}" rendered="{!NFeVisivel}" />
<apex:inputField Value="{!Nota.Romaneio__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Pedido__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Modelo__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Serie_NF__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Numero_NF__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Emissao_NF__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Base_de_Calculo_ICMS__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Base_de_calculo_ICMS_ST__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Valor_total_dos_produtos__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Peso__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.PIN_SUFRAMA__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.CFOP_predominante__c}" rendered="{!NFVisivel}" />
<apex:inputField Value="{!Nota.Valor_total_do_ICMS__c}" rendered="{!NFVisivel}" /> 


</apex:pageBlockSection>



<br/><br/><b>Itens inseridos</b><hr color="#66CDAA"></hr>
<apex:pageBlockTable value="{!itemSalvo}" var="lst" rendered="{!TBDocVisivel}">
<apex:column headervalue="Chave" value="{!lst.Chave_NF_e__c}"/> 

</apex:pageBlockTable> 
</apex:outputPanel> 

</apex:tab>
<apex:tab label="Informação da carga" name="infCarga" id="infCarga" > 
<apex:pageBlockSection columns="2" > 
<apex:inputField Value="{!CTe__c.Valor_da_carga__c}" />
<apex:inputField Value="{!CTe__c.Produto_predominante__c}" />
<apex:inputField Value="{!CTe__c.Caracteristica_da_carga__c}" ><apex:outputLabel >EX:'FRIA','GRANEL','REFRIGERADA','MEDIDAS','12X12X12'</apex:outputLabel>
</apex:inputField>
</apex:pageBlockSection>
<br/><br/><b>Cargas</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!carga.Quantidade__c}"/>
<apex:inputField value="{!carga.Tipo_de_medida__c}"/>
<apex:inputField value="{!carga.Unidade__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!cargas}" var="c">
<apex:column value="{!c.Quantidade__c}"/>
<apex:column value="{!c.Tipo_de_medida__c}"/>
<apex:column value="{!c.Unidade__c}"/>

</apex:pageBlockTable>

<br/><br/><b>Containers</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!container.Name}"/>
<apex:inputField value="{!container.Prevista_de_entrada__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!containers}" var="con">
<apex:column value="{!con.Name}"/>
<apex:column value="{!con.Prevista_de_entrada__c}"/>

</apex:pageBlockTable>

<br/><br/><b>Seguros</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!seguro.Name}"/>
<apex:inputField value="{!seguro.Numero_da_Apolice__c}"/>
<apex:inputField value="{!seguro.Numero_da_averbacao__c}"/>
<apex:inputField value="{!seguro.Responsavel__c}"/>
<apex:inputField value="{!seguro.Valor_da_carga__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!seguradoras}" var="s">
<apex:column value="{!s.Name}"/>
<apex:column value="{!s.Numero_da_Apolice__c}"/>
<apex:column value="{!s.Numero_da_averbacao__c}"/>
<apex:column value="{!s.Responsavel__c}"/>
<apex:column value="{!s.Valor_da_carga__c}"/>
</apex:pageBlockTable>

<br/><br/><b>Produtor perigosos</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!perigoso.Classe__c}"/>
<apex:inputField value="{!perigoso.Embalagem__c}"/>
<apex:inputField value="{!perigoso.Nome_de_embarque__c}"/>
<apex:inputField value="{!perigoso.ONU__c}"/>
<apex:inputField value="{!perigoso.Ponto_de_fulgor__c}"/>
<apex:inputField value="{!perigoso.Quant_e_tipo_de_volumes__c}"/>
<apex:inputField value="{!perigoso.Quantidade_total__c}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!perigosos}" var="p">
<apex:column value="{!p.Classe__c}"/>
<apex:column value="{!p.Embalagem__c}"/>
<apex:column value="{!p.Nome_de_embarque__c}"/>
<apex:column value="{!p.ONU__c}"/>
<apex:column value="{!p.Ponto_de_fulgor__c}"/>
<apex:column value="{!p.Quant_e_tipo_de_volumes__c}"/>
<apex:column value="{!p.Quantidade_total__c}"/>
</apex:pageBlockTable>

<br/><br/><b>Veículos novos</b><hr color="#66CDAA"></hr>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Incuir"/>
<apex:commandButton value="Excluir"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:tab> 

<apex:tab label="Serviços prestados" name="Servicos" id="ServicosCte">

<apex:outputPanel id="Servicos" >
<apex:pageBlockSection title="Inclusão de serviços" columns="2" > 
<apex:inputField value="{!componente.Servico__c}"/>
<apex:inputField value="{!componente.Inclui_no_valor_total_do_CTe__c}"/>
<apex:CommandButton value="Incluir"/> 
</apex:pageBlockSection> 

<br/><br/><b>Itens inseridos</b><hr color="#66CDAA"></hr>
<apex:pageBlockTable value="{!ComponentesInclusos}" var="Comp">
<apex:column headervalue="Serviço" value="{!Comp.Servico__c}"/> 
<apex:column headervalue="Valor" value="{!Comp.Valor__c}"/> 
<apex:column headervalue="Inclui no valor total do CTe" value="{!Comp.Inclui_no_valor_total_do_CTe__c}"/> 
</apex:pageBlockTable> 
</apex:outputPanel>
</apex:tab>


<apex:tab label="Documento anterior" name="DocAnterior" id="DocAnterior">
<b>Emitentes</b><hr color="#66CDAA"></hr>
<apex:pageBlockSection > 
<apex:inputField value="{!EmitenteDoc.Name}"/>
<apex:inputField value="{!EmitenteDoc.Inscricao_estadual__c}"/>
<apex:inputField value="{!EmitenteDoc.Razao_social__c}"/>
<apex:inputField value="{!EmitenteDoc.Logradouro__c}"/>
<apex:inputField value="{!EmitenteDoc.Numero__c}"/>
<apex:inputField value="{!EmitenteDoc.CEP__c}"/>
<apex:inputField value="{!EmitenteDoc.Cidade__c}"/>
</apex:pageBlockSection> 
<apex:pageBlockTable value="{!Emitentes}" var="em">

</apex:pageBlockTable> 
<br/><br/><b>Documetos</b><hr color="#66CDAA"></hr>
<apex:pageBlockSection > 
<apex:inputField value="{!docAnterior.Formato__c}"/>
<apex:inputField value="{!docAnterior.Tipo__c}"/>
<apex:inputField value="{!docAnterior.Numero_do_documento__c}"/>
<apex:inputField value="{!docAnterior.Serie__c}"/>
<apex:inputField value="{!docAnterior.Sub_serie__c}"/>
<apex:inputField value="{!docAnterior.Emissao__c}"/>
<apex:inputField value="{!docAnterior.Chave_CTe__c}"/>

</apex:pageBlockSection> 

<apex:pageBlockTable value="{!ComponentesInclusos}" var="Comp">

</apex:pageBlockTable> 
</apex:tab> 

<apex:tab label="Transporte">
<apex:actionFunction action="{!VerificaModal}" name="VModal" rerender="PainelRodoviarioPai"/>
<apex:outputPanel id="PainelRodoviarioPai">
<apex:outputPanel id="PainelRodoviario" rendered="{!RodoviarioVisivel}">

<apex:pageBlockSection title="Informações rodoviário" columns="2" > 

<apex:inputField value="{!CTe__c.RNTRC__c}"/>
<apex:inputField value="{!CTe__c.Data_entrega__c}"/>
<apex:inputField value="{!CTe__c.conta_frete__c}"/>
<apex:inputField value="{!CTe__c.Lotacao__c}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title="Ordens de coleta" columns="2" >
 
</apex:pageBlockSection>

</apex:outputPanel> 
</apex:outputPanel>
</apex:tab> 
</apex:tabPanel> 
</apex:pageBlock> 
</apex:form>
</apex:page>

 

 

 

 

 

 

CONTROLLER:

 

public with sharing class ControllerEmissaoCTe 
{

    Public Boolean Data{get;set;}
    Public Boolean Data1{get;set;}
    Public Boolean Data2{get;set;}
    Boolean BTNFeVisivel = TRUE;
    Boolean NFeVisivel = FALSE;
    Boolean NFVisivel = FALSE;
    public String MSG{get;set;}
    Boolean BTNFVisivel = TRUE;
    Boolean BTOutrosVisivel = TRUE;
    Boolean BTInserirVisivel = FALSE;
    Boolean TBDocVisivel = FALSE;
    List<nota__c> itemSalvo = new list <nota__c>();
    Container__c container=new Container__c();
    Carga__c carga=new Carga__c();
    Seguradora__c seguro=new Seguradora__c();
    Produto_perigoso__c perigoso=new Produto_perigoso__c();
    CTe__c OpcCte = new CTe__c();
    Boolean RodoviarioVisivel = FALSE;
    
    String tipo2;
    List<SelectOption> opTipo = new List<SelectOption>();
    String tipoConsulta;
    
   
    
    
    
    public ControllerEmissaoCTe(ApexPages.StandardController controller) 
    {
     
        if (controller != null) {
            this.tipo = (CTe__c)controller.getRecord();
        }

    }
    
    public boolean getTBDocVisivel(){
        return TBDocvisivel;
    }
    
    public boolean getRodoviarioVisivel(){
        return RodoviarioVisivel;
    }
       
    public CTe__c getOpcCte(){
        return OpcCte;
    }
 
    
    
    public boolean getBTNFeVisivel(){
    
        
    return BTNFeVisivel;
    }
    
     public boolean getBTInserirVisivel(){
    
        
    return BTInserirVisivel;
    }
    
     public boolean getBTOutrosVisivel(){
    
        
    return BTOutrosVisivel;
    }
     public boolean getBTNFVisivel(){
    
        
    return BTNFVisivel;
    }
       public Nota__c nota = new nota__c();
    
    
    public boolean getNFeVisivel(){
    
    return NFeVisivel;
    }
    
       public boolean getNFVisivel(){
    
    return NFeVisivel;
    }
    
    public Nota__c getNota()
    {
 
        Return nota;
    }
    
    
    
    
    public pageReference VerificaData()
    
    {
    
    getTipo();
        if(Tipo.Tipo_de_data_programada__c == '0 - Sem data definida')
        {
            Data = FALSE;
            Data1 = FALSE;
            Data2= FALSE;
        }else if(Tipo.Tipo_de_data_programada__c == '4 - No período')
        {
            Data = FALSE; 
            Data1 = TRUE;
            Data2= TRUE;
        }
        else 
        {    
            
            tipo.Detalhes_da_retirada__c=Tipo.Tipo_de_data_programada__c + 'ALO';
            Data = TRUE;
            Data1 = FALSE;
            Data2= FALSE;
        }
        
        Return null;
    
    }
         CTe__c Tipo;
         
     public CTe__c getTipoData() 
     {
          
         return Tipo;
     }
            
    
             
      public CTe__c getTipo() 
      {
                 return Tipo;
      }
      
      Public PageReference InserirNFe()
      {
    
      nota = new nota__c();
      nota.clear();
      NFVisivel = TRUE;
      NFeVisivel = FALSE;
      BTNFVisivel = FALSE;
      BTOutrosVisivel = FALSE;
      BTInserirVisivel = TRUE;
      
      Return null;      
      
      }
      
      
       public list<nota__c> getItemSalvo(){
        return itemSalvo;
    }

    public PageReference InserirDoc(){
    
    TBDocVisivel = TRUE;
    

     itemSalvo.add(nota);
     nota__c nota=new nota__c();
     
     return null;  
   
    }
    
    public Carga__c getCarga(){
    
        return carga;
    
    }
    
    List<Carga__c> cargas=new List<Carga__c>();
    
    public List<Carga__c> getCargas(){
    
        cargas=[SELECT Quantidade__c,Tipo_de_medida__c, Unidade__c FROM Carga__c];
    
        return cargas;
    
    }
    
    public Container__c Getcontainer(){
    
        return container;
    
    }
    
    List<Container__c> containers=new List<Container__c>();
    
    public List<Container__c> getContainers(){
    
        containers=[SELECT Name,Prevista_de_entrada__c FROM Container__c];
    
        return containers;
    
    }
    
     public Seguradora__c getSeguro(){
    
        return seguro;
    
    }
    
     List<Seguradora__c> seguradoras=new List<Seguradora__c>();
    
    public List<Seguradora__c> getSeguradoras(){
    
        seguradoras=[SELECT Name, Numero_da_Apolice__c, Numero_da_averbacao__c, Responsavel__c, Valor_da_carga__c FROM Seguradora__c];
    
        return seguradoras;
    
    }
    
    public Produto_perigoso__c getPerigoso(){
    
        return perigoso;
    
    }
    
    List<Produto_perigoso__c> perigosos=new List<Produto_perigoso__c>();
    
    public List<Produto_perigoso__c> getPerigosos(){
    
        perigosos=[SELECT Classe__c,Embalagem__c,Nome_de_embarque__c,ONU__c,Ponto_de_fulgor__c,Quant_e_tipo_de_volumes__c,Quantidade_total__c FROM Produto_perigoso__c];
    
        return perigosos;
    
    }
    
   Componente_do_CTe__c Componente=new Componente_do_CTe__c();
   
    public Componente_do_CTe__c getComponente(){
        Return Componente;
    }
    
      List<Componente_do_CTe__c> ComponentesInclusos=new List<Componente_do_CTe__c>();
   
    public List<Componente_do_CTe__c> getComponentesInclusos(){
        Return ComponentesInclusos;
    }
    
    Pessoa__c EmitenteDoc=new Pessoa__c();
   
    public Pessoa__c getEmitenteDoc(){
        Return emitenteDoc;
    }
    
    List<Pessoa__c> emitentes=new List<Pessoa__c>();

      public List<Pessoa__c> getEmitentes(){
    
        emitentes=[SELECT Name,inscricao_estadual__c,razao_social__c,logradouro__c,numero__c,cep__c,cidade__c FROM pessoa__c];
    
        return emitentes;
    
    }
    
    Documento_anterior__c docAnterior=new Documento_anterior__c();
   
    public Documento_anterior__c getDocAnterior(){
    
        return docAnterior;
    }

    Public pageReference VerificaModal(){
    
        System.debug('RetornoPicklist:'+OpcCte.Modal__c);
        
        System.debug('RetornoPicklist2:'+TipoConsulta);
    
        if(TipoConsulta == '01 - Rodoviário'){
            RodoviarioVisivel = TRUE;
            
        
        
        } 
        Return null;
    
    }
    
    
      public List<SelectOption> getTipo2(){
    
        opTipo.add(new SelectOption('01 - Rodoviário','01 - Rodoviário'));
        opTipo.add(new SelectOption('02 - Aviário','02 - Aviário'));
        
        return opTipo;
    
    }
    
      public String getTipoConsulta(){

       
        return tipoConsulta;
    }
    
   public String setTipoConsulta(String tipoConsulta){
        this.tipoConsulta = tipoConsulta;
        return tipoConsulta;
    }
    
    
}

 

Thanks man.

Avidev9Avidev9

You dont seem to have setter methiod for "OpcCte".

public void setOpcCte(CTe__c OpcCte){
  this.OpcCte =OpcCte;
}

 



Do you have something like this in your code ?

Felipe DiasFelipe Dias

Oh yes, I forgot it.

Now I put it. But nothing changed.