You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Peter Ertl (JIRA)" <ji...@apache.org> on 2007/04/20 11:43:16 UTC

[jira] Created: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Allow more complex behaviour for AutoCompleter component
--------------------------------------------------------

                 Key: WICKET-488
                 URL: https://issues.apache.org/jira/browse/WICKET-488
             Project: Wicket
          Issue Type: Improvement
          Components: wicket-extensions
         Environment: wicket-1.x snapshot
            Reporter: Peter Ertl


It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.


current behaviour:

### snip : wicket-autocomplete.js line 93-97 ###
  case KEY_ENTER:
    if(selected>-1){
      obj.value=getSelectedValue();
      hideAutoComplete();
      hidingAutocomplete=1;
### eof snip ###

Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.

pseudo code:
  if selected
      if callback
        callback(value)
      else
        obj.value = current value   
      end
    .....

probably the right place for such a on-select contribution would be the autocomplete renderer.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Peter Ertl updated WICKET-488:
------------------------------

    Attachment: autocomplete-on-select-including-onclick.patch

This patch is similar to the first, just that I forgot to include the event of clicking on a list item instead of pressing enter.

so this patch includes that as well...

> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select-including-onclick.patch, autocomplete-on-select.patch
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492695 ] 

Igor Vaynberg commented on WICKET-488:
--------------------------------------

well, yes of course nothing happens:) you have to invoke onselect yourself. but you see the difference between how this does it and how your patch does? with the capxous way every item can have a custom onselect script, they are not limited to using the same one. and it will also shift this scriptlet into the renderer rather then the autocomplete component itself, which i think i rather like. and yes, wicket-autocomplete.js has to invoke the custom onselect handler when the user presses enter,or call it onautocomplete or whatever - the name isnt important, just has to be documented.

> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select-including-onclick.patch, autocomplete-on-select.patch, jquery.js
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492638 ] 

Peter Ertl commented on WICKET-488:
-----------------------------------

Igor, the example is a bit misleading...

This is a definition of onSelect (from http://www.w3schools.com/jsref/jsref_onselect.asp)

> The onselect event occurs when text is selected in a text or textarea field

It seems that the CAPXOUS component is checking for onSelect on a list item, like that:

  <div onselect='blah'>value</div>

and firing a custom onSelect event for this.

When trying this with the wicket-autocomplete

<ul>
  <li onselect='bla' textvalue='foo'>bar</li>
  ..
</ul>

just nothing will happen :-(

we could attach the onselect on the autocomplete input text field, but this kind of fragile / quick and dirty, 
as this scenario could occur:

- user selects item from list
- input text field gets filled with textvalue from wicket-autocomplete.js
- inputfield:onselect is fired and _another_ request is created
- kaboom, the request just dies for some reason (connection problem, whatever)
- result: invalid data in form / db
- also: we need two requests for one action *ugh*

so *imho* the proper solution would be to trigger onSelect from wicket-autocomplete.js

> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select-including-onclick.patch, autocomplete-on-select.patch, jquery.js
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491964 ] 

Peter Ertl commented on WICKET-488:
-----------------------------------

sorry, the attachment was for the wrong ticket (wicket-501 instead)

> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select-including-onclick.patch, autocomplete-on-select.patch, jquery.js
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492044 ] 

Igor Vaynberg commented on WICKET-488:
--------------------------------------

i wonder if it is better to push the onselect thing into the renderer and allow each returned result to provide one.

see how this component does it: http://capxous.com/docs/

> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select-including-onclick.patch, autocomplete-on-select.patch, jquery.js
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Peter Ertl updated WICKET-488:
------------------------------

    Attachment: autocomplete-on-select.patch

This patch makes the onSelect behavior of autocomplete customizable. in order to do something different from filling in a text value in the form component you override AbstractAutoCompleteBehaviour#getOnSelectJavascript which returns something like e.g.

new AutoCompleteBehavior(acRenderer)
{
      @Override
      protected String getOnSelectJavascript()
      {
        return "function(id,val) { alert('you selected ' + val + ' on ' + id)}";
      }
      ...
}

this way any behavior on select is imaginable.

I extended the javascript by providing a hash of options, so putting more optional stuff is easy.


> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select.patch
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-488) Allow more complex behaviour for AutoCompleter component

Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-488?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Peter Ertl updated WICKET-488:
------------------------------

    Attachment: jquery.js

I attached the file where the problem happened to me.

environment:

- jdk1.4.2
- wicket-1.3-snapshot (don't know exact revision)
- sap j2ee web server


> Allow more complex behaviour for AutoCompleter component
> --------------------------------------------------------
>
>                 Key: WICKET-488
>                 URL: https://issues.apache.org/jira/browse/WICKET-488
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>         Environment: wicket-1.x snapshot
>            Reporter: Peter Ertl
>         Attachments: autocomplete-on-select-including-onclick.patch, autocomplete-on-select.patch, jquery.js
>
>
> It would be nice to be able to modify the default behaviour of the ajax autocompleter component upon selection of an list item. this would make it a even more useful component and exceed it's capabilities beyond simple text replacement.
> current behaviour:
> ### snip : wicket-autocomplete.js line 93-97 ###
>   case KEY_ENTER:
>     if(selected>-1){
>       obj.value=getSelectedValue();
>       hideAutoComplete();
>       hidingAutocomplete=1;
> ### eof snip ###
> Instead of having obj.value= being filled by the current text value it would be nice to have the option of specifying a js function callback to e.g. post back the selected value to the server. This way you could implement more complex behaviour, for example select a company address from a list and, on selecting it, send back the address id to the server which then would fill out street, house number, zip code and city.
> pseudo code:
>   if selected
>       if callback
>         callback(value)
>       else
>         obj.value = current value   
>       end
>     .....
> probably the right place for such a on-select contribution would be the autocomplete renderer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.