3 Replies Latest reply on Oct 22, 2009 5:29 PM by Nikos Paraskevopoulos

    Understanding s:button h:commandButton and @RequestParameter

    Tanya Ruttenberg Expert

      Just to further my own understand of the difference between s:button and h:commandButton I am trying a little exercise.

      I have a simple form into which I input a String

      <h:inputText id="officeId" value="#{officeViewHome.officeViewOfficeId}"/>

      I submit the form with h:commandButton

      <h:commandButton label="Find Office" action="/OfficeView.xhtml"/>

      OfficeView.xhtml just displays some info about the office whose ID was entered in the form.

      This information about the OfficeViewHome instance in OfficeView.xhtml displays without a problem.

      I am attempting to see what other changes would be necessary were I to change the h:commandLink to s:button.  So here is what I did:

      Left the inputText field the same.

      Changed h:commandButton to this

      <s:button view="/OfficeView.xhtml" value="Find Office" >
       <f:param name="officeViewOfficeId" value="#{officeViewHome.officeViewOfficeId}"/>

      Added this to OfficeViewHome.java

      private Integer officeViewOfficeId;
      @Override public Object getId() {
        System.out.println("TDR getId "+ officeViewOfficeId);
            return officeViewOfficeId;

      But I can see by my debugging statement that officeViewOfficeId is null.  It seems to me that the parameter is not getting passed to the @RequestParameter when I click on s:button.

      Can anyone see why this is not working and explain how to make it work?