0 Replies Latest reply on Dec 18, 2011 10:47 PM by Oscar Calderon

    Problem invoking method from a:commandbutton

    Oscar Calderon Newbie

      I have a SEAM 2 application and i have a strange situation. I'm developing with Eclipse Indigo, and i need to create a page with a grid where each row has a button that display a popup window with a list and you can choose one item of the list with a link and the value selected is shown in the row.


      So i have this component:


      @Name("paramContHome")
      @Scope(ScopeType.CONVERSATION)
      public class ParamContHome extends KubeDAO<ParametroSistema>{
      
          private static final long serialVersionUID = 1L;
      
          @In
          private LoginUser loginUser;
      
          @In(required=false,create=true)
          private CuentaContHome cuentaContHome;
      
          public void load(){
              try{
                  setInstance(getEntityManager().find(ParametroSistema.class, prctId));
              }catch (Exception e) {
                  clearInstance();
                  setInstance(new ParametroSistema());
              }
          }
      
          public void selCuentaParam(ParametroSistema par) {
              setSelParam(par);
              cuentaContHome.getCuentasList();
          }
      
          public void setCuentaParam(CuentaContable cta) {
              selParam.setValorNum(cta.getId().floatValue());
              selParam.setSelObj(cta);
          }
      
          ...
      
          }



      That contains the methods that i'm trying to call from xhtml page. This is the xhtml page:


      <?xml version="1.0" encoding="iso-8859-1" ?>
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:a="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:p="http://primefaces.prime.com.tr/ui"
          template="/layout/templateKu.xhtml">
          <ui:define name="body">
              <rich:panel>
                  <f:facet name="header">#{app.paramact_head}</f:facet>
                  <rich:spacer height="20" />
                  <h:form id="formA">
                      <p:growl globalOnly="true" sticky="false" life="3000" />
                      <p:focus />
                      <a:queue name="q1" />
      
                      <rich:dataTable var="res" value="#{paramContHome.resultList}"
                          rendered="#{not empty paramContHome.resultList}" rows="10"
                          align="center" rowClasses="tableInfo1 tableInfo2"
                          headerClass="tablaHeader" footerClass="tableScroll">
                          <f:facet name="header">#{app.paramact_list}</f:facet>
      
                          <rich:column filterBy="#{res.nombre}" filterEvent="onkeyup">
                              <f:facet name="header">#{app.paramact_nombre}</f:facet>
                              <h:outputText value="#{res.nombre}" />
                          </rich:column>
                          <rich:column>
                              <f:facet name="header">#{app.transferencia_valornum}</f:facet>
                              <h:inputText value="#{res.selObj.nombre}" size="20" >
                                  <a:support event="onblur" ajaxSingle="true" eventsQueue="q1" reRender="_table"/>
                              </h:inputText>
                              <a:commandButton ajaxSingle="true"   
                                  action="#{paramContHome.selCuentaParam(res)}" reRender="sCta" 
                                  onclick="#{rich:component('selCta')}.show();"
                                  styleClass="modifyBtn" value=" " style="width:30px;">
                              </a:commandButton>
                          </rich:column>
                          <f:facet name="footer">
                              <rich:datascroller id="ds1" renderIfSinglePage="true" />
                          </f:facet>
                      </rich:dataTable>
                  </h:form>
              </rich:panel>
              <rich:modalPanel id="selCta" width="400" moveable="false" autosized="true" top="50px" 
                  onbeforeshow="activeModal.setActiveModalPanel('selCta');">
                  <f:facet name="header">#{app.general_lov}</f:facet>
                  <f:facet name="controls">
                      <h:panelGroup>
                          <h:graphicImage value="/kubeImg/close.png" styleClass="closeBtn" 
                              onclick="#{rich:component('selCta')}.hide();" />
                      </h:panelGroup>
                  </f:facet>
                  <s:div id="sCta"><ui:include  src="selCta.xhtml" /></s:div>
              </rich:modalPanel>
          </ui:define>
      </ui:composition>



      This is the button where i wanna call the method selCuentaParam of component paramContHome:


      <rich:column>
          <f:facet name="header">#{app.transferencia_valornum}</f:facet>
          <h:inputText value="#{res.selObj.nombre}" size="20" >
              <a:support event="onblur" ajaxSingle="true" eventsQueue="q1" reRender="_table"/>
          </h:inputText>
          <a:commandButton ajaxSingle="true"   
              action="#{paramContHome.selCuentaParam(res)}" reRender="sCta" 
              onclick="#{rich:component('selCta')}.show();"
              styleClass="modifyBtn" value=" " style="width:30px;">
          </a:commandButton>
      </rich:column>



      Inside this method, i call a method from another component, cuentaContHome:


      @In(required=false,create=true)
      private CuentaContHome cuentaContHome;
      ...
      public void selCuentaParam(ParametroSistema par) {
      setSelParam(par);
      cuentaContHome.getCuentasList();
      }



      This is list.page.xml:


      <?xml version="1.0" encoding="UTF-8"?>
      <page xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">
           <action execute="#{paramContHome.getParametrosContables()}" on-postback="false" />
           
      </page>



      But when i run the application and enter to the page, and i press the button, it doesn't calle the method selCuentaParam. I've checked this because i put breakpoints inside it and put System.out.println and doesn't invoke it. Do you know why this happens, is something related to component initialization?


      Regards.