6 Replies Latest reply on Feb 25, 2007 2:27 AM by Chico Chen

    h:commandButton not work

    Chico Chen Newbie

      2 things in one webpage:

      1. <h:commandButton id="findButton" value="Filter" action="#{projectAction.find}"/>
      2. <s:link action="#{projectAction.find}" value="Projects" />
      also has <h:inputText id="searchString" value="#{projectAction.searchString}" size="15" />

      I find "h:commandButton" cannot call "projectAction.find" method, only can set "projectAction.searchString" field to new value; but "s:link" can.

      anyone could help me?

        • 1. Re: h:commandButton not work
          Mike Quilleash Newbie

          Do you have a form around the commandButton and input field?

          Note that s:link does NOT do a form submission so searchString won't be updated in the model using s:link.

          • 2. Re: h:commandButton not work
            Chico Chen Newbie


            Do you have a form around the commandButton and input field?

            Note that s:link does NOT do a form submission so searchString won't be updated in the model using s:link.

            thanks for your feedback!

            yes, i have a <h:form id="projectSearchForm"> around the commandButton and input field.

            • 3. Re: h:commandButton not work
              Mike Quilleash Newbie

              Possible an error in one of the earlier JSF phases.

              One thing I use for debugging is this...

              public class DebugPhaseListener implements PhaseListener
               public void afterPhase( PhaseEvent event )
               System.out.println("afterPhase: " + event.getPhaseId());
               public void beforePhase( PhaseEvent event )
               System.out.println("beforePhase: " + event.getPhaseId());
               public PhaseId getPhaseId()
               return PhaseId.ANY_PHASE;

              If you configure this listener in faces-config you can see as each phase runs. It might be failing somewhere in the validate phase in which case you'll see it jump straight to the render phase.

              • 4. Re: h:commandButton not work
                Chico Chen Newbie

                just click the button, find following info:

                14:06:01,791 INFO [STDOUT] beforePhase: RESTORE_VIEW(1)
                14:06:01,822 INFO [STDOUT] afterPhase: RESTORE_VIEW(1)
                14:06:01,822 INFO [STDOUT] beforePhase: APPLY_REQUEST_VALUES(2)
                14:06:01,854 INFO [STDOUT] afterPhase: APPLY_REQUEST_VALUES(2)
                14:06:01,854 INFO [STDOUT] beforePhase: PROCESS_VALIDATIONS(3)
                14:06:01,885 INFO [STDOUT] afterPhase: PROCESS_VALIDATIONS(3)
                14:06:01,885 INFO [STDOUT] beforePhase: UPDATE_MODEL_VALUES(4)
                14:06:01,900 INFO [STDOUT] afterPhase: UPDATE_MODEL_VALUES(4)
                14:06:01,916 INFO [STDOUT] beforePhase: RENDER_RESPONSE(6)
                14:06:02,072 INFO [STDOUT] afterPhase: RENDER_RESPONSE(6)

                Also, here are the code:

                <h:form id="projectSearchForm">
                 <table class="jiraform maxWidth">
                 <td class="jiraformheader" colspan="7">
                 <a href="#"
                 <h:graphicImage url="/img/help_blue.gif"
                 border="0" width="16" align="right"
                 title="Get online help about Defining Project Versions"
                 alt="Get help!" />
                 <h3 class="formtitle">Administration</h3></td></tr>
                 <td class="jiraformbody" colspan="7">
                 <p>Below is the list of all 1 projects for this installation
                 of JIRA. </p>
                 <h:graphicImage url="/img/bullet_creme.gif"
                 border="0" height="8" width="8" align="absMiddle" />
                 <b><a id="add_project" href="#">Add Project</a></b>
                 Displaying proects <b><h:outputText value="#{projectQueryAction.startIndex}" /></b>
                 to <b><h:outputText value="#{projectQueryAction.endIndex}" /></b>
                 of <b><h:outputText value="#{projectQueryAction.totalCount}" /></b>.
                 <font size="1">(<a href="#">Reset Filter</a>) </font>
                 <tr bgcolor="#ffffff">
                 <td align="right" bgcolor="#fffff0"><b>Project Per Page:</b></td>
                 <h:selectOneMenu value="#{projectQueryAction.pageSize}">
                 <f:selectItem itemLabel="All" itemValue="1000000"/>
                 <f:selectItem itemLabel="3" itemValue="3"/>
                 <f:selectItem itemLabel="20" itemValue="20"/>
                 <f:selectItem itemLabel="50" itemValue="50"/>
                 <td align="right" bgcolor="#fffff0">
                 <b>Name Contains:</b>
                 <h:inputText id="searchString" value="#{projectQueryAction.searchString}" size="15" />
                 <td align="right" bgcolor="#fffff0">
                 <h:selectOneMenu value="#{projectQueryAction.searchStatus}">
                 <f:selectItem itemLabel="Any" itemValue=""/>
                 <f:selectItem itemLabel="Open" itemValue="open"/>
                 <f:selectItem itemLabel="Closed" itemValue="closed"/>
                 <h:commandButton id="findButton" value="Filter" action="#{projectQueryAction.find2}" />

                package com.eastidea.qaforum.action;
                import java.io.Serializable;
                import java.util.List;
                import javax.ejb.Remove;
                import javax.ejb.Stateful;
                import javax.persistence.EntityManager;
                import javax.persistence.PersistenceContext;
                import javax.persistence.Query;
                import org.jboss.seam.ScopeType;
                import org.jboss.seam.annotations.Destroy;
                import org.jboss.seam.annotations.Factory;
                import org.jboss.seam.annotations.Name;
                import org.jboss.seam.annotations.Scope;
                import org.jboss.seam.annotations.datamodel.DataModel;
                import org.jboss.seam.annotations.datamodel.DataModelSelection;
                import org.jboss.seam.annotations.security.Restrict;
                import com.eastidea.qaforum.entity.Project;
                public class ProjectQueryAction implements ProjectQueryInterface, Serializable {
                 public EntityManager em;
                 private List<Project> projectList;
                 public void initProjectList() {
                 public void find() {
                 if (curPage == -1) curPage = 1;
                 public String searchString;
                 public String searchStatus;
                 public String conditions;

                • 5. Re: h:commandButton not work
                  Chico Chen Newbie


                  <h:commandButton id="findButton" value="Filter" action="#{projectQueryAction.find2}" />
                  should be
                  <h:commandButton id="findButton" value="Filter" action="#{projectQueryAction.find}" />
                  , but still work.

                  • 6. Re: h:commandButton not work
                    Chico Chen Newbie

                    i missed

                    public void setPageSize(int pageSize);
                    in it's interface, it's work now.