4 Replies Latest reply on Mar 22, 2007 4:34 PM by Francisco Neto

    Action Method <aj4:support> is not called!!!!

    Francisco Neto Newbie

      Hi everyone,

      I'm using ajax4jsf and I've got in trouble using <a4j:support> tag. Below we have the piece of code that isn't working.

      
      <h:selectOneMenu id="selectTipo" style="width:200">
       <a4j:support event="onchange" action="#registroProcesso.showMensagemProtocolizacao}" reRender="info"/>
      <f:selectItems value="#{registroProcesso.selectTodosItens}"/>
      </h:selectOneMenu>
      
      


      This method "showMensagemProtocolizacao" is not called even when other part of my file using <a4j:support> the same way is calling another action method. This is the other part

      <h:inputText id="nomeAssunto" valueChangeListener="#{registroProcesso.addNomeAssunto}" size="20"/>
      


      I talked with other 3 developers in my job and they, too, don't know why it's not working.

      Could anyone point me what "could" be hapenning?!!

      thanks in advance,
      Francisco.

        • 1. Re: Action Method <aj4:support> is not called!!!!
          Sergey Smirnov Master

          Usually, the action method is not invoked if validation phase is failed. So, it is a primary place you can look at.

          Do you have an <h:messages /> on the page. if so, do not forget to make it enabled for ajax updates:

          <a4j:outputPanel ajaxRendered="true">
           <h:messages />
          </a4j:outputPanel>


          If you expect that you want to manipulate with selectOneMenu only during this Ajax request, limit the component tree processing with a4j:region component. I.e.:

          <a4j:region>
           <h:selectOneMenu id="selectTipo" style="width:200">
           <a4j:support event="onchange" action="#registroProcesso.showMensagemProtocolizacao}" reRender="info"/>
           <f:selectItems value="#{registroProcesso.selectTodosItens}"/>
           </h:selectOneMenu>
          </a4j:region>


          • 2. Re: Action Method <aj4:support> is not called!!!!
            Francisco Neto Newbie


            I tried the second one (I don't have any validation in my page yet) and it doesn't work yet. So, here are my page

            <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
            
            <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
            
            <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
            <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
            <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
            
            <f:view>
            
            <html>
             <h:form>
             <h:outputText value="Nome do Assunto*:" styleClass="edit"/>
             <h:inputText id="nomeAssunto" valueChangeListener="#{registroProcesso.addNomeAssunto}" size="20"/>
            
             <h:commandButton value="Pesquisar" styleClass="botao" action="#{registroProcesso.showTipoAssunto}"/>
            
             <h:panelGroup>
            
             <h:panelGroup rendered="#{not registroProcesso.imprimirDocumentos}"/>
            
             <h:panelGroup rendered="#{registroProcesso.imprimirDocumentos}">
             <h:outputText value="Lista de Assuntos*:" styleClass="edit"/>
             <h:selectOneMenu style="width:200">
             <a4j:support event="onclick" action="#{registroProcesso.showMensagemProtocolizacao}"></a4j:support>
             <f:selectItems value="#{registroProcesso.selectTodosItens}"/> </h:selectOneMenu>
             </h:panelGroup>
            
             </h:panelGroup>
            
            
             </h:form>
            
            </html>
            
            </f:view>
            
            <%@ include file="/jsp/sigaProcesso/inc/Exception.inc" %>
            
            


            And, this is my bean

            
            public class BeanRegistroProcesso {
            
             private String nomeAssunto; // Nome que o usuário digita na primeira tela.
            
             private List<SelectItem> selectTodosItens;
            
             private List<SelectItem> selectItensSelecionados;
            
             private Collection<DocumentoRequerido> documentosRequeridos;
            
             private HtmlPanelGrid panelDocumentosRequeridos;
            
             private boolean imprimirDocumentos;
            
             private boolean mostrarMensagemProtocolizacao;
            
             public BeanRegistroProcesso() {
            
             // Some kind of initialization!!
             }
            
             // Getters and Setters.
            
             public String showMensagemProtocolizacao() {
             System.out.println("showMensagemProcolizacao"); // I WANT TO PRINT OUT THIS!!!!!!
            
             return null;
             }
            
            
             public void atualizarSelect(ActionEvent ex) {
            
             try {
             RepositorioPessoasIteravel rep = sistema.getRecursosHumanos().consultarPessoasParteNomeIteravel(this.getSolicitante().getNomePessoa().toUpperCase(), 10000, true);
             this.selectTodosItens = new ArrayList<SelectItem>();
            
             SelectItem item = new SelectItem();
             item.setLabel(" ");
             item.setValue(" ");
             this.selectTodosItens.add(item);
            
             for (Object objeto : rep.getCollection()) {
             Pessoa pessoa = (Pessoa) objeto;
            
             item = new SelectItem();
             item.setLabel(pessoa.getNomePessoa());
             item.setValue(pessoa);
             this.selectTodosItens.add(item);
             }
            
             } catch (EntradaInexistenteException e) {
             e.printStackTrace();
             } catch (NumeroRegistrosExcedidosException e) {
             e.printStackTrace();
             } catch (SistemaException e) {
             e.printStackTrace();
             }
             }
            
             public String showTipoAssunto() {
            
             this.imprimirDocumentos = !this.imprimirDocumentos;
             this.selectTodosItens = new ArrayList<SelectItem>();
            
             for (TipoAssunto assunto : tiposAssunto) { // Assume tiposAssunto is already populated.
            
             SelectItem item = new SelectItem();
             item.setLabel(assunto.getDescricao());
             item.setValue(assunto.getCodigo());
             this.selectTodosItens.add(item);
             }
            
             return null;
             }
            
             public void addNomeAssunto(ValueChangeEvent ev) {
             this.setNomeAssunto((String)ev.getNewValue());
             }
            }
            
            
            
            


            • 3. Re: Action Method <aj4:support> is not called!!!!
              Sergey Smirnov Master

              Do not forget about conversion. It is a typical problem for select elements. So, check the issue with h:messages

              It is helpful to have a phase tracker during the development. It helps to understand where the jsf lifecycle stops and jumps to the latest phase bypassing the INVOKE APPLICATION phase where actions are called.

              Ready-to-use tracker:
              http://www.jsftutorials.net/faces-config/phaseTracker.html

              • 4. Re: Action Method <aj4:support> is not called!!!!
                Francisco Neto Newbie


                It's a kind of validation error!!!

                thanks a lot guy! I'm gonna see what's really going on!

                thanks a lot!!!