2 Replies Latest reply on Mar 29, 2008 3:16 PM by Pete Muir

    Are parameters supposed to propagate with h:commandButton?

    Matthew Lieder Apprentice

      Given the following setup:


           <page view-id="/testParamProp.xhtml" conversation-required="false">
      
                <param name="param1" value="#{testParamProp.param1}" />
      
           </page>



      package sandbox.seam;
      
      
      import java.io.Serializable;
      
      
      import org.jboss.seam.ScopeType;
      
      import org.jboss.seam.annotations.Name;
      
      import org.jboss.seam.annotations.Scope;
      
      
      @Name("testParamProp")
      
      @Scope(ScopeType.CONVERSATION)
      
      public class TestParamPropPage implements Serializable {
      
           
      
           private String param1;
      
           
      
           public String getParam1() {
      
                return param1;
      
           }
      
           
      
           public void setParam1(String param1) {
      
                this.param1 = param1;
      
           }
      
           
      
      }



      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml"
      
            xmlns:ui="http://java.sun.com/jsf/facelets"
      
            xmlns:h="http://java.sun.com/jsf/html"
      
            xmlns:s="http://jboss.com/products/seam/taglib">
      
      <head>
      
           <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      
           <title>Seam Sandbox</title>
      
      </head>
      
      <body>
      
           <h:form>
      
                <h2>Test of parameter propagation</h2>
      
           
      
                <s:button view="/testParamProp.xhtml" value="This works" />
      
                <h:commandButton value="This doesn't" />
      
           </h:form>
      
      </body>
      
      </html>



      The first button on the page keeps the parameter on the URL, but the second button does not. Is this a bug, or expected behavior? The documentation says The value is transparently propagated with any JSF form submission for the page with the given view id, so I'm guessing it's a bug?

        • 1. Re: Are parameters supposed to propagate with h:commandButton?
          Stijn Cremers Novice

          I haven't use it that way, but when i worked with param, i did it the following way:



          <h:commandButton value="This doesn't" >
           <f:param name="param1" value="#{testParamProp.param1}" />
          </h:commandButton>


          • 2. Re: Are parameters supposed to propagate with h:commandButton?
            Pete Muir Master

            Matthew Lieder wrote on Mar 27, 2008 04:24 PM:


            The first button on the page keeps the parameter on the URL, but the second button does not. Is this a bug, or expected behavior? The documentation says The value is transparently propagated with any JSF form submission for the page with the given view id, so I'm guessing it's a bug?


            It's automatically added to <s:link/> or <s:button/>, you have to add it to h:commandLink/> using <f:param /> and you can't with <h:commandButton/> (as it doesn't accept <f:param/>s.


            The transparent propagation refers to the fact that when you submit the form it will be propagated in the page context (not on the URL). Take a look at how I implemented <s:conversationPropagation /> for command buttons if you really need to do this (it's not pleasant).