Thanks for the quick reply. Works like a charm!

Please let me know how I can buy you a beer.

Cheers

Am 13.08.2014 um 09:05 schrieb Martin Grigorov <mgrigo...@apache.org>:

> Hi,
> 
> You can use AjaxEventBehavior as with any other event type.
> The 'data' is reachable thru: attrs.event.extraData:
> 
> new AjaxEventBehavior("customEvent") {
> 
>  @Override protected void updateAjaxAttributes(AjaxRequestAttributes
> attributes)
>  {
>     super.updateAjaxAttributes(attributes);
>     attributes.getDynamicExtraParameters().add("return [{\"name\":
> \"value\", \"value\": attrs.event.extraData.value}]");
>  }
> 
>  @Override public void onEvent(AjaxRequestTarget target) {
>    StringValue valueValue =
> getRequest().getRequestParameters().getParameterValue("value");
>    ....
>  }
> 
> }
> 
> On Wed, Aug 13, 2014 at 1:07 AM, Christian Schröter <
> christian.schroe...@1und1.de> wrote:
> 
>> Hey everyone,
>> 
>> I'm having diffculties to find a solution for a common issue, at least in
>> my opinion ^^
>> Hopefully someone can help me.
>> 
>> I'm using a third party JS libary. This lib fires custom events.
>> 
>> $('#id').on('customEvent', function(event, data) {...});
>> 
>> In Wicket I would like to add a listener for this specific event (like the
>> AjaxEventBehavior) and also retrieving the arguments within the callback
>> function.
>> Is there an easy way to do this?
>> 
>> 
>> Cheers,
>> Christian
>> 
>> 
>> Here is what works so far but I don't think this is the "best" solution.
>> 
>> StringBuffer script = new StringBuffer();
>> script.append("var value = data.value;");
>> 
>> script.append(getCallbackFunctionBody(CallbackParameter.explicit("value")));
>> 
>> response.render(new OnEventHeaderItem("'" + component.getMarkupId() + "'",
>> "customEvent", script.toString()) {
>>    @Override
>>    public CharSequence getCompleteJavaScript() {
>>        StringBuilder result = new StringBuilder();
>>        result.append("Wicket.Event.add(")
>>                .append(getTarget())
>>                .append(", \"")
>>                .append(getEvent())
>>                .append("\", function(event, data) { ")
>>                .append(getJavaScript())
>>                .append(";});");
>>        return result;
>>    }
>> });
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to