5 Replies Latest reply on Jan 28, 2009 11:35 PM by Hicham GLIA

    h:commandButton and s:button on login

    Hicham GLIA Newbie

      This is how I coded login.xhtml

      <?xml version='1.0' encoding='UTF-8' ?>
      <!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"
              <rich:panel header="Connexion">
                  <h:form id="login">
                      <h:panelGrid columns="2">
                          <h:outputLabel for="username">username</h:outputLabel>
                          <h:inputText id="username" value="#{credentials.username}"/>
                          <h:outputLabel for="password">password</h:outputLabel>
                          <h:inputSecret id="password" value="#{credentials.password}"/>
                       <h:commandButton value="Login" action="#{identity.login}" />
                       <s:button  value="SeamLogin" action="#{identity.login}" />

      When I click on Login (using h:commandButton) every thing is ok:
      If the user exist : I can login, if not, I get the message Login failed

      When I click on SeamLogin, whenever the user exist or not, I always get the message Login failed.
      I am using seam 2.1.1GA with glassfish 2.

      my pagex.xml is :

      <?xml version="1.0" encoding="UTF-8"?>
      <pages xmlns="http://jboss.com/products/seam/pages"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
             no-conversation-view-id="/home.xhtml" login-view-id="/login.xhtml">
          <page view-id="/mypage.xhtml" login-required="true">
          <navigation from-action="#{identity.login}">
                  <!--rule if-outcome="loggedIn">
                      <redirect view-id="/profile.xhtml"/>
              <rule if="#{identity.loggedIn and authenticatedMember ne null}">
                  <redirect view-id="/home.xhtml"/>

        • 1. Re: h:commandButton and s:button on login
          Stefano Travelli Newbie

          The reason is that <s:button> doesn't submit form.

          <h:commandButton> looks like a button and it submits the form.

          <h:commandLink> looks like a link and it does submit the form.

          <s:link> looks like a link and it is a link. It doesn't submit the form.

          <s:button> looks like a button, but id doesn't submit the form.

          • 2. Re: h:commandButton and s:button on login
            Hicham GLIA Newbie

            So what are they used for?!!

            • 3. Re: h:commandButton and s:button on login
              Stefano Travelli Newbie

              One of the main criticism over JSF is that everything requires a form submission and a POST request.

              Among other things, this prevent from building web applications with so-called bookmarkable pages or pages that one can open in a new window/tab.

              Seam provides these controls in order to solve these limitations. Take a look at Section 7.4 of the reference documentation. It explains the concept in full detail.

              • 4. Re: h:commandButton and s:button on login
                Hicham GLIA Newbie

                Thanks for your explanations!

                I have now a new problem:
                When I use :

                        <h:outputText value="#{projectName}:"/>
                        <s:link view="/home.xhtml" value="Home" propagation="none"/>
                    <!-- @newMenuItem@ -->
                    <rich:toolBarGroup location="right">
                        <h:outputText value="signed in as: #{identity.username}" rendered="#{identity.loggedIn}"/>
                        <s:link view="/login.xhtml" value="Login" rendered="#{not identity.loggedIn}" propagation="none"/>
                        <s:link view="/home.xhtml" action="#{identity.logout}" value="Logout" rendered="#{identity.loggedIn}" propagation="none"/>

                (Generated by JBoss Developer Studio 2.0.0.CR1)

                I get the following exception

                An Error Occurred:
                /loginold.xhtml @10,69 propagation="none" object is not an instance of declaring class

                What could be the problem

                • 5. Re: h:commandButton and s:button on login
                  Hicham GLIA Newbie

                  It's ok now:

                  I have forgoten to add jboss-seam-ui.jar to the Library that I use.

                  but I still have some toubles from time to time and I have now one more question:

                  What are the libraries needed to use seam on glassfish on a basic CRUD application?!

                  I have one Library : SEAM with the following jar files :


                  Do I have to remove or add more jar files to use seam correctly?