[
https://issues.apache.org/jira/browse/WICKET-5087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13599087#comment-13599087
]
Igor Vaynberg commented on WICKET-5087:
---------------------------------------
@martin the functionality is available, but the big difference is that you are
allowing the user to break encapsulation where as existing functionality does
not. the current functionality encapsulates the generation of the callback url
- ensuring that it is unique.
let me clarify - the convenience you are adding is a simple way to reference
wicket components from javascript without having to dynamically write out a
part of that js - namely the callback url. correct?
lets take the concrete usecase of making a stateless select2 component. using
your code the component author would add the behavior, override getShortUrl()
and set it to something like "select2-data", then use that to create a
callback. what about the component user though? they add the component,
override the method to feed it data, all is good. what happens when they add
another one though? now both components are fixed to the same url and one of
them will get incorrect data. so the component author now has to make the short
url available as a constructor arg - and it is on the component user to make
sure these tokens are unique. but, at this point, since the short url has to be
configurable, writing out javascript needs to be done in a dynamic way to plug
in the url - so we are back to square one - the only difference is who controls
the url - the user in the java code or the framework. at this point i think the
convenience is lost since i cannot have static javascript, i have to write it
out using a texttemplate...
> Make it easier to request (ajax)behaviors by name from JavaScript
> -----------------------------------------------------------------
>
> Key: WICKET-5087
> URL: https://issues.apache.org/jira/browse/WICKET-5087
> Project: Wicket
> Issue Type: New Feature
> Components: wicket
> Affects Versions: 6.6.0
> Reporter: Martin Grigorov
> Assignee: Martin Grigorov
> Attachments: WICKET-5087.patch, wicket-ajax-shorturl.tgz
>
>
> Many JavaScript libraries require server endpoint for making requests for
> loading/saving data.
> To integrate such JS library with Wicket the application developer should
> make the IRequestListener's url available as an endpoint. That is it need to
> store somewhere the url produced by #urlFor() or
> AjaxBehavior#getCallbackUrl().
> This new feature will make this much simpler for the application developer.
> A new method will be added to Wicket.Ajax namespace to facilitate this:
> Wicket.Ajax.short({
> 'su': 'countries',
> 'dep': [function() {return [{'name': 'extra', 'value': 'param'}]}],
> 'coh': [function() {console.log('Completed!')}]
> });
> This new method will again receive an object with all possible attributes
> plus a new one - 'su', stands for 'short/stable/simple' url.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira