You need to sign in to do that
Don't have an account?
Diego Vieira 8
Help with ActionSupport and Param Visualforce
Can someone help me?
I need to call a method from my extension controller when onclick happens in my apex:tab, so I use apex:actionSupport and apex:param to do that.
The method i should call receive one param, produto.
When i try to save, salesforce tells me that vf can't find the method on standardController:
Result: [OPERATION FAILED]: pages/ConfiguracaoDoProduto.page: Método 'Configuracoes_com_produtos__cStandardController.setProdutoAtual()' desconhecido
Here is part of the vf code of that:
here is the part of the extension controller code:
Here is the vf full code:
Here is the Extension Controller full code:
I need to call a method from my extension controller when onclick happens in my apex:tab, so I use apex:actionSupport and apex:param to do that.
The method i should call receive one param, produto.
When i try to save, salesforce tells me that vf can't find the method on standardController:
Result: [OPERATION FAILED]: pages/ConfiguracaoDoProduto.page: Método 'Configuracoes_com_produtos__cStandardController.setProdutoAtual()' desconhecido
Here is part of the vf code of that:
<apex:tabPanel height="250px" switchType="client" id="TabelaPainel" styleClass="TheTabPanel" tabClass="TheTabPanel" contentClass="tabContent" activeTabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:repeat var="item" value="{!fasesDaConfiguracao}"> <apex:tab label="{!item}" name="{!item}" rendered="{!(fasesDaConfiguracao.size != null)}"> <apex:actionSupport event="onclick" action="{!setProdutoAtual}"> <apex:param name="produto" value="{!item}"/> </apex:actionSupport> <pageBlockTable value="{!item}" var="config" rendered="{!(fasesDaConfiguracao.size != null)}" columnsWidth="15%,85%"> <apex:column headerValue="Incluir" headerClass="headerStyle" rendered="{!config.render}"> <apex:inputCheckbox onclick="uncheckOthers(this)"/> </apex:column> <apex:column value="{!produtosBanco.Name}" headerClass="headerStyle" rendered="{!config.render}"/> </pageBlockTable> </apex:tab> </apex:repeat> </apex:tabPanel>
here is the part of the extension controller code:
public void setProdutoAtual(string produto) { produtoAtual = produto; }
Here is the vf full code:
<apex:page standardController="Configuracoes_com_produtos__c" extensions="ConfiguracaoDoProdutoController"> <apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css"/> <style type="text/css"> .selected { background-color: #C0C0C0; color: #000000; font-size: 170%; font-weight: bold; } .headerStyle { background: rgb(255, 127, 0) !important; color: #FFFFFF !important; } .myCustomMessage .message { background: none !important; border: none !important; } </style> <apex:sectionHeader title="{!Configuracoes_com_produtos__c.Name}"/> <apex:form id="formulario"> <apex:pageBlock id="configuracoes"> Pais: <apex:selectList value="{!pais}" id="pais" size="1" multiselect="false"> <apex:selectOptions value="{!opcoesPais}"/> <apex:actionSupport event="onchange" action="{!procurar}"/> </apex:selectList> Família de Produtos: <apex:selectList value="{!familia}" id="familia" size="1" multiselect="false"> <apex:selectOptions value="{!opcoesFamilia}"/> <apex:actionSupport event="onchange" action="{!procurar}"/> </apex:selectList> Voltagem: <apex:selectList value="{!voltagem}" id="voltagem" size="1" multiselect="false"> <apex:selectOptions value="{!opcoesVoltagem}"/> <apex:actionSupport event="onchange" action="{!procurar}"/> </apex:selectList> <apex:tabPanel height="250px" switchType="client" id="TabelaPainel" styleClass="TheTabPanel" tabClass="TheTabPanel" contentClass="tabContent" activeTabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:repeat var="item" value="{!fasesDaConfiguracao}"> <apex:tab label="{!item}" name="{!item}" rendered="{!(fasesDaConfiguracao.size != null)}"> <apex:actionSupport event="onclick" action="{!setProdutoAtual}"> <apex:param name="produto" value="{!item}"/> </apex:actionSupport> <pageBlockTable value="{!item}" var="config" rendered="{!(fasesDaConfiguracao.size != null)}" columnsWidth="15%,85%"> <apex:column headerValue="Incluir" headerClass="headerStyle" rendered="{!config.render}"> <apex:inputCheckbox onclick="uncheckOthers(this)"/> </apex:column> <apex:column value="{!produtosBanco.Name}" headerClass="headerStyle" rendered="{!config.render}"/> </pageBlockTable> </apex:tab> </apex:repeat> </apex:tabPanel> <div align="center"> <apex:commandButton action="{!adicionar}" value="Adicionar"/> <apex:commandButton action="{!salvar}" value="Salvar"/> </div> </apex:pageBlock> <script type="text/javascript"> function uncheckOthers(obj) { var vTbl = obj.parentNode.parentNode.parentNode; var vCheckboxes = vTbl.getElementsByTagName('INPUT'); for (var i = 0; i < vCheckboxes.length; i++) { if (vCheckboxes[i] != obj && obj.checked) vCheckboxes[i].checked = false; } } </script> </apex:form> </apex:page>
Here is the Extension Controller full code:
public class ConfiguracaoDoProdutoController { public List<SelectOption> opcoesPais {get;set;} public List<SelectOption> opcoesFamilia {get;set;} public List<SelectOption> opcoesVoltagem {get;set;} public string pais {get;set;} public string familia {get;set;} public string voltagem {get;set;} public string primeiroItem {get;set;} public string stringConfiguracao {get;set;} public string produtoAtual {get;set;} public List<string> fasesDaConfiguracao {get;set;} public List<Product2> produtosBanco {get;set;} public ConfiguracaoDoProdutoController(ApexPages.StandardController controller) { string idConfiguracao = controller.getId(); fasesDaConfiguracao = new List<string>(); opcoesPais = new List<SelectOption>(); opcoesPais.add(new SelectOption('Sem Filtro',' ')); opcoesFamilia = new List<SelectOption>(); opcoesFamilia.add(new SelectOption('Sem Filtro',' ')); opcoesVoltagem = new List<SelectOption>(); opcoesVoltagem.add(new SelectOption('Sem Filtro',' ')); List<Product2> produtos = [SELECT Voltagem__c, Family, Pais__c FROM Product2 WHERE Voltagem__c != null OR Family != null OR Pais__c != null]; Set<string> voltagens = new Set<string>(); Set<string> familias = new Set<string>(); Set<string> paises = new Set<string>(); for(Product2 produto : produtos) { if(produto.Voltagem__c != null) voltagens.add(produto.Voltagem__c); if(produto.Family != null) familias.add(produto.Family); if(produto.Pais__c != null) paises.add(produto.Pais__c); } for(string voltagem : voltagens) opcoesVoltagem.add(new SelectOption(voltagem, voltagem)); for(string familia : familias) opcoesFamilia.add(new SelectOption(familia, familia)); for(string pais : paises) opcoesVoltagem.add(new SelectOption(pais, pais)); Configuracoes_com_produtos__c configuracao = [SELECT Configuracao_Salva__c FROM Configuracoes_com_produtos__c WHERE Id =: idConfiguracao]; string stringConfiguracao = configuracao.Configuracao_Salva__c; List<string> fasesDaConfiguracao = stringConfiguracao.split('<br/>'); procurar(); } public void setProdutoAtual(string produto) { produtoAtual = produto; } public void procurar() { string conditionQuery = ''; if(pais != 'Sem Filtro' && pais != null) { conditionQuery += ' and Pais__c = ' + pais; } if(familia != 'Sem Filtro' && familia != null) { conditionQuery += ' and Family = ' + familia; } if(voltagem != 'Sem Filtro' && voltagem != null) { conditionQuery += ' and Voltagem__c = ' + voltagem; } string query = 'SELECT Id, Name From Product2 WHERE Tipo_de_Produto__c = ' + produtoAtual; query += conditionQuery; produtosBanco = Database.query(query); } }
Hope this helps.
I try it but still getting error :/
I need to call a fuction setProdutoAtual (that is on my extension controller) passing the param item, that is on my apex:repeat