You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Emond Papegaaij (JIRA)" <ji...@apache.org> on 2012/05/08 10:06:45 UTC

[jira] [Created] (WICKET-4540) Allow AJAX callback function generation to also generate parameters

Emond Papegaaij created WICKET-4540:
---------------------------------------

             Summary: Allow AJAX callback function generation to also generate parameters
                 Key: WICKET-4540
                 URL: https://issues.apache.org/jira/browse/WICKET-4540
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 6.0.0-beta1
            Reporter: Emond Papegaaij
            Assignee: Emond Papegaaij


We need an easy way to pass parameters from JavaScript to Java via a function that takes parameters. For example, of JQuery UI event callbacks, the function takes two parameters: event and ui. But, these aren't the parameters you want to pass to Java. A conversion is needed.

I was thinking about the following: let getCallbackFunction take a CallbackParameter vararg, with 4 implementations for CallbackParameter: ContextParameter, ExplicitParameter, ResolvedParameter and ConvertedParameter. A context parmater, only provides context to the function, it is not added to the Ajax call. Both event and ui are context parameter. Explicit parameters are context parameters that are also passed to the Ajax call. Resolved parameters are resolved using some javascript code. The last adds a context parameter and a conversion script to add it to the Ajax call.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4540) Allow AJAX callback function generation to also generate parameters

Posted by "Emond Papegaaij (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13270407#comment-13270407 ] 

Emond Papegaaij commented on WICKET-4540:
-----------------------------------------

All are right, except for the last: it's more like function(x) { var params = { 'x' : x.substring(0,3)}. You can use it, for example, when you want to stringify an object or limit the string length.

Good catch about using jQuery. I'll open another ticket for that.
                
> Allow AJAX callback function generation to also generate parameters
> -------------------------------------------------------------------
>
>                 Key: WICKET-4540
>                 URL: https://issues.apache.org/jira/browse/WICKET-4540
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.0.0-beta1
>            Reporter: Emond Papegaaij
>            Assignee: Emond Papegaaij
>             Fix For: 6.0.0-RC1
>
>
> We need an easy way to pass parameters from JavaScript to Java via a function that takes parameters. For example, of JQuery UI event callbacks, the function takes two parameters: event and ui. But, these aren't the parameters you want to pass to Java. A conversion is needed.
> I was thinking about the following: let getCallbackFunction take a CallbackParameter vararg, with 4 implementations for CallbackParameter: ContextParameter, ExplicitParameter, ResolvedParameter and ConvertedParameter. A context parmater, only provides context to the function, it is not added to the Ajax call. Both event and ui are context parameter. Explicit parameters are context parameters that are also passed to the Ajax call. Resolved parameters are resolved using some javascript code. The last adds a context parameter and a conversion script to add it to the Ajax call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4540) Allow AJAX callback function generation to also generate parameters

Posted by "Sebastien Briquet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13279517#comment-13279517 ] 

Sebastien Briquet commented on WICKET-4540:
-------------------------------------------

Hi Emond,

Sorry for the delay in my answer. I just had a look on your implementation within the version 6.0.0-beta2.
I like the approach using static method (context, resolved, etc) instead of the 4 classes!
I test it on my 2 use cases I had and it is working well! :)

Just for reference (if someone else read the ticket), the code needed to get a javascript like:

function (event,ui) {
    var attrs = {"u":"my-behavior-url","c":"mycomponent"};
    var params = {'index': ui.item.id};
    attrs.ep = params;
    Wicket.Ajax.ajax(attrs);
} 

is written like this: ajaxBehavior.getCallbackFunction(CallbackParameter.context("event"), CallbackParameter.context("ui"), CallbackParameter.resolved("index", "ui.item.id"));

Thanks again,
Sebastien.
                
> Allow AJAX callback function generation to also generate parameters
> -------------------------------------------------------------------
>
>                 Key: WICKET-4540
>                 URL: https://issues.apache.org/jira/browse/WICKET-4540
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.0.0-beta1
>            Reporter: Emond Papegaaij
>            Assignee: Emond Papegaaij
>             Fix For: 6.0.0-beta2
>
>
> We need an easy way to pass parameters from JavaScript to Java via a function that takes parameters. For example, of JQuery UI event callbacks, the function takes two parameters: event and ui. But, these aren't the parameters you want to pass to Java. A conversion is needed.
> I was thinking about the following: let getCallbackFunction take a CallbackParameter vararg, with 4 implementations for CallbackParameter: ContextParameter, ExplicitParameter, ResolvedParameter and ConvertedParameter. A context parmater, only provides context to the function, it is not added to the Ajax call. Both event and ui are context parameter. Explicit parameters are context parameters that are also passed to the Ajax call. Resolved parameters are resolved using some javascript code. The last adds a context parameter and a conversion script to add it to the Ajax call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4540) Allow AJAX callback function generation to also generate parameters

Posted by "Sebastien Briquet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13270397#comment-13270397 ] 

Sebastien Briquet commented on WICKET-4540:
-------------------------------------------

Hi Emond,

So, if I sum-up (and if I understood well):

- Using ContextParameter gets something like: function (event,ui) { ... }
- Using ExplicitParameter gets something like: function (event,ui) { var params = {'event': event, 'ui': ui}; ... }. This is the actual implementation.
- Using ResolvedParameter could get something like: var myresolvedvalue = 2 + 2; var params = {'myresolvedvalue': myresolvedvalue} ?
- Using ConvertedParameter could get something like:  function (event,ui) { var params = { 'itemId': ui.item.id } ... }

Did I understood well until here?

Moreover, just because I am thinking of that now: I forgot to mention in my first mail that getCallbackFunctionBody is using a jQuery statement directly (jQuery.extend({}, attrs.ep, params)).
According to https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax:
"All Java components and behaviors should still use the Wicket.** API. This way if someday we decide to not use JQuery anymore we will have less work to do. Also if a user uses Dojo/YUI/ExtJS/... and prefer to not have JQuery in her application then she will be able to provide wicket-ajax-xyz.js implementation and replace the default one."

It is just a small mistake, but I prefer to point it so can fix it while updating getCallbackFunctionBody...

To be continued...
Thanks again,
Sebastien.
                
> Allow AJAX callback function generation to also generate parameters
> -------------------------------------------------------------------
>
>                 Key: WICKET-4540
>                 URL: https://issues.apache.org/jira/browse/WICKET-4540
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.0.0-beta1
>            Reporter: Emond Papegaaij
>            Assignee: Emond Papegaaij
>             Fix For: 6.0.0-RC1
>
>
> We need an easy way to pass parameters from JavaScript to Java via a function that takes parameters. For example, of JQuery UI event callbacks, the function takes two parameters: event and ui. But, these aren't the parameters you want to pass to Java. A conversion is needed.
> I was thinking about the following: let getCallbackFunction take a CallbackParameter vararg, with 4 implementations for CallbackParameter: ContextParameter, ExplicitParameter, ResolvedParameter and ConvertedParameter. A context parmater, only provides context to the function, it is not added to the Ajax call. Both event and ui are context parameter. Explicit parameters are context parameters that are also passed to the Ajax call. Resolved parameters are resolved using some javascript code. The last adds a context parameter and a conversion script to add it to the Ajax call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (WICKET-4540) Allow AJAX callback function generation to also generate parameters

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

Emond Papegaaij resolved WICKET-4540.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 6.0.0-RC1

The resolution given in the description has been implemented.
                
> Allow AJAX callback function generation to also generate parameters
> -------------------------------------------------------------------
>
>                 Key: WICKET-4540
>                 URL: https://issues.apache.org/jira/browse/WICKET-4540
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.0.0-beta1
>            Reporter: Emond Papegaaij
>            Assignee: Emond Papegaaij
>             Fix For: 6.0.0-RC1
>
>
> We need an easy way to pass parameters from JavaScript to Java via a function that takes parameters. For example, of JQuery UI event callbacks, the function takes two parameters: event and ui. But, these aren't the parameters you want to pass to Java. A conversion is needed.
> I was thinking about the following: let getCallbackFunction take a CallbackParameter vararg, with 4 implementations for CallbackParameter: ContextParameter, ExplicitParameter, ResolvedParameter and ConvertedParameter. A context parmater, only provides context to the function, it is not added to the Ajax call. Both event and ui are context parameter. Explicit parameters are context parameters that are also passed to the Ajax call. Resolved parameters are resolved using some javascript code. The last adds a context parameter and a conversion script to add it to the Ajax call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira