Click
  1. Click
  2. CLK-304

Cannot have more than one AutoCompleteTextField in a form

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0-M1
    • Component/s: extras
    • Labels:
      None
    • Environment:
      Click 1.4RC3

      Description

      Hi Malcolm,

      If you add multiple AutoCompleteTextFields on a form you will notice that only the first AutoCompleteTextField works. The second field never popup suggestions.

        Activity

        Bob Schellink created issue -
        Hide
        Malcolm Edgar added a comment -

        Hi Bob,

        thanks for identifying this issue. Fix checked in.

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi Bob, thanks for identifying this issue. Fix checked in. regards Malcolm Edgar
        Malcolm Edgar made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Bob Schellink added a comment -

        Hi Malcolm,

        Upon more testing I notice that if you have two controls with the same name, but in different forms, only the first AutoCompleteTextField is called. For example:

        postalAddressField = new AutoCompleteTextField("street", true) {
        public List getAutoCompleteList(String criteria)

        { List list = new ArrayList(); list.add("Short street"); return list; }

        }
        postalAddressForm.add(postalAddressField);

        physicalAddressField = new AutoCompleteTextField("street", true) {
        public List getAutoCompleteList(String criteria)

        { List list = new ArrayList(); list.add("Long street"); return list; }

        }
        physicalAddressForm.add(physicalAddressField);

        We have two forms portalAddressForm and physicalAddressForm both containing a Field named "street". Both fields return "Short street", instead of the second field returning "Long street".

        The problem is that there is no Form to qualify the field name, eg. "physicalAddressForm_name".

        Show
        Bob Schellink added a comment - Hi Malcolm, Upon more testing I notice that if you have two controls with the same name, but in different forms, only the first AutoCompleteTextField is called. For example: postalAddressField = new AutoCompleteTextField("street", true) { public List getAutoCompleteList(String criteria) { List list = new ArrayList(); list.add("Short street"); return list; } } postalAddressForm.add(postalAddressField); physicalAddressField = new AutoCompleteTextField("street", true) { public List getAutoCompleteList(String criteria) { List list = new ArrayList(); list.add("Long street"); return list; } } physicalAddressForm.add(physicalAddressField); We have two forms portalAddressForm and physicalAddressForm both containing a Field named "street". Both fields return "Short street", instead of the second field returning "Long street". The problem is that there is no Form to qualify the field name, eg. "physicalAddressForm_name".
        Bob Schellink made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Hide
        Bob Schellink added a comment -

        Looking at the code, we could check for #getId instead of #getName. That should uniquely identify the field right?

        Ajax.Autocompleter supports a paramName option to specify the name of the parameter:

        autoCompleteOptions =

        {minChars:1, paramName:\"" + getId() + "\"}
        Show
        Bob Schellink added a comment - Looking at the code, we could check for #getId instead of #getName. That should uniquely identify the field right? Ajax.Autocompleter supports a paramName option to specify the name of the parameter: autoCompleteOptions = {minChars:1, paramName:\"" + getId() + "\"}
        Hide
        Bob Schellink added a comment -

        Looking at the code "again" I realize fields with the same name is not supported. #onInit adds the control to the Page so there is no need for a Form.

        Show
        Bob Schellink added a comment - Looking at the code "again" I realize fields with the same name is not supported. #onInit adds the control to the Page so there is no need for a Form.
        Hide
        Bob Schellink added a comment -

        At some point we could look into improving Ajax support for example. Some thoughts I have been brewing over:

        #1 move the #isFormSubmission check from Form#onProcess to Field#onProcess. That way AjaxFields are still processed and can override Field#onProcess check. (this might not be backwards compatible, since custom Fields, which does not have this check could break)

        #2 introduce an AjaxForm which does the above (does not break backwards compatibility, but different AjaxForm must now be used)

        #3 add ability to call a control or page listener directly. One way of doing this is by registering all listeners in a central place eg. Context, and have ClickServlet invoke them one by one after #onProcess finishes. Ajax Controls could make use of the listener to provide feedback instead of overriding onProcess. Another advantage of this approach is that when listeners are called, all Controls have been bound to request parameters making things more deterministic. For example if Control A has a listener and that listener depends on the value of Control B, then Control B must be added to the Form or Page before Control A, otherwise the value of Control B will not have been set yet. Of course we can still get Control B value from the request, but its not as clean.

        Show
        Bob Schellink added a comment - At some point we could look into improving Ajax support for example. Some thoughts I have been brewing over: #1 move the #isFormSubmission check from Form#onProcess to Field#onProcess. That way AjaxFields are still processed and can override Field#onProcess check. (this might not be backwards compatible, since custom Fields, which does not have this check could break) #2 introduce an AjaxForm which does the above (does not break backwards compatibility, but different AjaxForm must now be used) #3 add ability to call a control or page listener directly. One way of doing this is by registering all listeners in a central place eg. Context, and have ClickServlet invoke them one by one after #onProcess finishes. Ajax Controls could make use of the listener to provide feedback instead of overriding onProcess. Another advantage of this approach is that when listeners are called, all Controls have been bound to request parameters making things more deterministic. For example if Control A has a listener and that listener depends on the value of Control B, then Control B must be added to the Form or Page before Control A, otherwise the value of Control B will not have been set yet. Of course we can still get Control B value from the request, but its not as clean.
        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]
        Hide
        Bob Schellink added a comment -

        fixed in trunk. AutoCompleteTextField is invoked directly through an AjaxBehavior. It is not added to the Page anymore which hindered adding multiple fields with the same name.

        Show
        Bob Schellink added a comment - fixed in trunk. AutoCompleteTextField is invoked directly through an AjaxBehavior. It is not added to the Page anymore which hindered adding multiple fields with the same name.
        Bob Schellink made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Assignee Malcolm Edgar [ medgar ] Bob Schellink [ sabob ]
        Fix Version/s 2.3.0-M1 [ 12314845 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1d 11h 55m 1 Malcolm Edgar 02/Feb/08 00:46
        Resolved Resolved Reopened Reopened
        15h 37m 1 Bob Schellink 02/Feb/08 16:23
        Reopened Reopened Resolved Resolved
        889d 15h 16m 1 Bob Schellink 11/Jul/10 08:39

          People

          • Assignee:
            Bob Schellink
            Reporter:
            Bob Schellink
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development