Announcement Announcement Module
Collapse
No announcement yet.
LoginForm focus and validations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LoginForm focus and validations

    Is anyone else seeing the LoginForm not set focus to the user name field? I always have to click on the user name field before typing. I think that will annoy my users.

    How do you turn of as-you-type validations for a form?

    I really don't want the first thing seen by a user to be a form "yelling" at them for not filling it out, when they haven't typed anything yet. Or is that naive?

    Thanks,
    Tom

  • #2
    I ran into both of these issues. We had to create our own Login dialog "from scratch" to meet various requirement, though we did base it on the code provided with Spring-rich. This gave me the luxury to tweak a couple of things. First, in our version of "LoginCommand" where the TitledPageApplicationDialog is being created (and extended via anonymous inner class), I override "onAboutToShow()" like so:
    Code:
            protected void onAboutToShow()
            {
              loginForm.requestFocusInWindow();
              super.onAboutToShow();
            }
    Obviously I have added a new method to LoginForm called "requestFocusInWindow()":
    Code:
      public boolean requestFocusInWindow()
      {
        if(this.sessionDetails != null && this.sessionDetails.getUserspace() != null &&
           this.sessionDetails.getUserspace().trim().length() > 0) {
          return this.usernameField.requestFocusInWindow();
        } else {
          return this.userspaceField.requestFocusInWindow();
        }
      }
    It should be much simpler for the stock LoginForm, as it doesn't have a "userspace" field to contend with.

    As for the problem of having the dialog pop up with an error already showing, I found that I never want this functionality in my application (I always want an initial, friendly, message displaying - only show errors once the user begins typing). So, I extended TitledPageApplicationDialog like so:
    Code:
    public abstract class TitledPageApplicationDialogEx extends TitledPageApplicationDialog
    {
      public TitledPageApplicationDialogEx(DialogPage dialogPage)
      {
        super(dialogPage);
      }
    
      public TitledPageApplicationDialogEx(Form form, Window parent)
      {
        super(form, parent);
      }
    
      public TitledPageApplicationDialogEx(DialogPage dialogPage, Window parent)
      {
        super(dialogPage, parent);
      }
    
      public TitledPageApplicationDialogEx(DialogPage dialogPage, Window parent,
                     CloseAction closeAction)
      {
        super(dialogPage, parent, closeAction);
      }
      
      protected void onAboutToShow()
      {
        super.onAboutToShow();
        setMessage(getDescription());
      }
    }
    I use TitledPageApplicationDialogEx instead of TitledPageApplicationDialog throughout all my code and so automatically get the friendly "description" message instead of the first invalid validation message when a dialog is shown. I use this in my own version of LoginCommand as well:
    Code:
    ...
          ApplicationDialog dialog = new TitledPageApplicationDialogEx(page, getParentWindowControl())
    ...
    - Andy

    Comment


    • #3
      Originally posted by adepue
      I ran into both of these issues. We had to create our own Login dialog "from scratch" to meet various requirement, though we did base it on the code provided with Spring-rich. This gave me the luxury to tweak a couple of things. First, in our version of "LoginCommand" where the TitledPageApplicationDialog is being created (and extended via anonymous inner class), I override "onAboutToShow()" like so:
      Code:
              protected void onAboutToShow()
              {
                loginForm.requestFocusInWindow();
                super.onAboutToShow();
              }
      Obviously I have added a new method to LoginForm called "requestFocusInWindow()":
      Code:
        public boolean requestFocusInWindow()
        {
          if(this.sessionDetails != null && this.sessionDetails.getUserspace() != null &&
             this.sessionDetails.getUserspace().trim().length() > 0) {
            return this.usernameField.requestFocusInWindow();
          } else {
            return this.userspaceField.requestFocusInWindow();
          }
        }
      It should be much simpler for the stock LoginForm, as it doesn't have a "userspace" field to contend with.

      As for the problem of having the dialog pop up with an error already showing, I found that I never want this functionality in my application (I always want an initial, friendly, message displaying - only show errors once the user begins typing). So, I extended TitledPageApplicationDialog like so:
      Code:
      public abstract class TitledPageApplicationDialogEx extends TitledPageApplicationDialog
      {
        public TitledPageApplicationDialogEx(DialogPage dialogPage)
        {
          super(dialogPage);
        }
      
        public TitledPageApplicationDialogEx(Form form, Window parent)
        {
          super(form, parent);
        }
      
        public TitledPageApplicationDialogEx(DialogPage dialogPage, Window parent)
        {
          super(dialogPage, parent);
        }
      
        public TitledPageApplicationDialogEx(DialogPage dialogPage, Window parent,
                       CloseAction closeAction)
        {
          super(dialogPage, parent, closeAction);
        }
        
        protected void onAboutToShow()
        {
          super.onAboutToShow();
          setMessage(getDescription());
        }
      }
      I use TitledPageApplicationDialogEx instead of TitledPageApplicationDialog throughout all my code and so automatically get the friendly "description" message instead of the first invalid validation message when a dialog is shown. I use this in my own version of LoginCommand as well:
      Code:
      ...
            ApplicationDialog dialog = new TitledPageApplicationDialogEx(page, getParentWindowControl())
      ...
      - Andy
      Thanks for your help. I just got back from vacation, which is why I haven't had a chance to look at this before.

      Again, thanks.

      Comment

      Working...
      X