3 Replies Latest reply on May 3, 2010 2:56 PM by sappo

    Unable to pass parameters to h:commandButton

      I am trying to pass parameters while executing h:commandButton. The parameters are not propagated like it does for s:button. So, how to pass f:param for a h:commandButton. My code looks likes this


          <h:commandButton action="#{books}"value="#{Save}">
              <f:param name="bookId" value="#{book}"/>
          </h:commandButton>



        • 1. Re: Unable to pass parameters to h:commandButton
          thokuest

          What exactly doesn't work? Did you use @RequestParameter in your bean?

          • 2. Re: Unable to pass parameters to h:commandButton
            This is the way we used -
            <ice:panelSeries var="icon">
            <ice:commandButton id="name" value="#{icon.name}" action="#{Test.execute(icon)}">
                 <f:param name="iconId" value="#{icon.id.iconId}" />
            </ice:commandButton>
            </ice:panelSeries>
            • 3. Re: Unable to pass parameters to h:commandButton
              sappo

              Hi Shravan,


              there are two way to catch the your f:param.


              Either you annotate a variable with @RequestParameter in your bean:


              @RequestParameter
              private Long iconId;
              @Out
              private Icon icon
              
              //do some action
              public void execute() {
                  icon = entityManager.find(Icon.class, iconId);
              }
              


              Or you declare the parameter within your page.xml


              <?xml version="1.0" encoding="UTF-8"?>
              <page view-id="/receiver.xhtml"
                    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">
                  <param name= "iconId"/>
              
              </page>
              



              //Kevin