5 Replies Latest reply on Nov 29, 2006 2:58 AM by Norman Richards

    Seam + JSF

    lara khoury Newbie

      Hi there,

      I have the following code in the JSF page:

      <h:commandLink type="submit" value="Apply"
       action="#{updatePasswordAction.UpdatePassword}">
       <f:param name="actorId" value="#{actorEditor.instance.id}"/>
      </h:commandLink>



      The above code is working perfectly which means that I can get the value of the id in the
      updatePasswordAction bean. However, I want to use <h:commandButton/> instead of <h:commandLink/> in the JSF page but I am not able to use <f:param> in this case.
      How can I send a parameter using <h:commandButton/> in the JSF page knowing that the parameter is not a constant value?

      I would appreciate any help.
      Regards,
      Lara

        • 1. Re: Seam + JSF
          Norman Richards Master

          Do you actually need anything from the h:form that h:commandButton would require? If not, why not try Seam's s:button?

          • 2. Re: Seam + JSF
            lara khoury Newbie

            Thanks for replying..
            Well this is my JSF page:

            <!DOCTYPE html 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:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:t="http://myfaces.apache.org/tomahawk"
             template="templates/admin.xhtml">
            
             <ui:define name="content">
            <f:view>
             <f:loadBundle basename="messages" var="msg" />
            
            <head>
             <title>
            <h:outputText value="#{msg.pageTitleModifyActor}" rendered="#{!actorEditor.new}" />
            </title>
            </head>
            
            <body>
            
            <div class="pageTitle"><h:outputText value="#{msg.pageTitleModifyActor}" rendered="#{!actorEditor.new}"/></div>
            
            <h:form enctype="multipart/form-data">
            
             <table class="tableProperties">
            
             <tr>
             <td>
             <h:outputLabel value="#{msg.name}"></h:outputLabel>
             </td>
             <td>
             <h:inputText value="#{actorEditor.instance.name}" id="name" required="true" rendered="#{actorEditor.new}"/>
             <h:outputText value="#{actorEditor.instance.name}" rendered="#{!actorEditor.new}" class="viewText"/>
             </td>
             </tr>
            
             </table>
            
            
             <div style="padding-left:10px">
             <span> <h:commandButton type="submit" value="#{msg.Update}" action="#{actorEditor.update}" rendered="#{!
             actorEditor.new}" /> </span>
             </div>
            
            </h:form>
            
            
            
            <h:form rendered="#{!actorEditor.new}">
            
            
             <table class="tableProperties">
             <tr>
             <td><h:outputLabel value="New Password"></h:outputLabel></td>
             <td>
             <h:inputSecret value="#{updatePasswordAction.password}" id="password" required="true"/>
            
             </td>
             </tr>
             </table>
            
             <div style="padding-left:10px">
             <h:commandLink type="submit" value="Apply" action="#{updatePasswordAction.UpdatePassword}">
             <f:param name="name" value="#{actorEditor.instance.name}"/>
             <f:param name="actorId" value="#{actorEditor.instance.id}"/>
             </h:commandLink>
             </div>
            
            </h:form>
            </body>
            </f:view>
             </ui:define>
            </ui:composition>
            



            In this JSF page, I showed the main code. There are two forms:
            the first form contains the name of the actor to be edited and the bean in question is actorEditor bean
            the second form contains the password field to be edited and the bean in question is updatePasswordAction

            Inside the second form there is the following code:

             <h:commandLink type="submit" value="Apply" action="#{updatePasswordAction.UpdatePassword}">
             <f:param name="name" value="#{actorEditor.instance.name}"/>
             <f:param name="actorId" value="#{actorEditor.instance.id}"/>
             </h:commandLink>
            


            I am passing as parameters the name and id of the actor inside the <f:param> using <h:commandLink>
            How can do the same assuming that I have a button Apply instead of a link and knowing that I am getting the value of the parameters from the other form?

            Regards,
            Lara

            • 3. Re: Seam + JSF
              Gavin King Master

              Try using a Seam page parameter.

              • 4. Re: Seam + JSF
                lara khoury Newbie

                Thx for replying but could you be more specific and give me a simplified example?
                The parameter as I already mentioned in not constant.

                Regards,