2 Replies Latest reply on May 7, 2008 5:05 PM by Fredrik Forsberg

    Form bean binding fails after pojo method call

    Fredrik Forsberg Newbie

      I use Seam 2.0.2-SNAPSHOT and I have a case where all my pages on my web site requires the user to login. This is done with

      <page view-id="*" login-required="true" />

      in pages.xml.

      The exception is that I want to let the user be able to access another view for creating an beta account. This view should not be protected by any login requirement.

      I thought the easiest way doing this was to fit these two forms (login and create account) on one single page and render either the login form or create account form based on the result of a sort of validation method.

      public class ValidateBetaInvite {
           private Long id;
           private String authkey;
           private FacesMessages facesMessages;
           // injection of various stateless DAO beans for DB access
           public boolean invitationIsValid() {
                // lookup invitation request in database and return true or false depending on the
                // invitation status
           public boolean invitationIsProvided(){
                // check if id and authkey parameters are provided in url

      The following markup is the principles of how I share the same page for two different views:

      <s:div rendered="#{!betaInviteValidator.invitationIsProvided()}">
                     <!-- login fields -->
           <s:div rendered="#{betaInviteValidator.invitationIsProvided() and betaInviteValidator.invitationIsValid()}">
                     <!-- create account fields -->

      If user requests

           login.seam (without any parameters)

      the login form will show up.

      If user requests


      the method InvitationAction.invitationIsValid and invitationIsProvided will be called and either show error message or the create account form.

      The InvitationAction bean works in the sense that it returns the expected values based on if the user provides invite data in the URL so the view switch logic works.

      The problem is that the calls to the InvitationAction methods makes the 'create account' form not bind to the formbean that is called on create account submit button. When submit is pressed the login page is reloaded without parameters and no exceptions are thrown.

      public class RegisterBetaAccountActionBean implements com.yourstardom.user.RegisterAccountActionLocal {
           // field property declarations
           public java.lang.String register() throws ServiceException {
                // register the user
           // getters and setters and life cycle methods

      If I remove the calls to the InviteAction methods the action method is called and the registerbetaaccount component behaves as expected.

      I made it EVENT scoped without any results.

      Why does the call to my validationbean mess up the binding to the createaccount bean? I have no long running conversation active anywhere.

      Thanks in advice,

      Fredrik F