Re: adding wicket generated link to javascript

2014-09-03 Thread Martin Grigorov
Hi,

On Wed, Sep 3, 2014 at 11:15 PM, Jason Novotny 
wrote:

> Hi,
>
> My designer gave me code where HTML is created in javascript as part of a
> jquery dataTable:
>
> 
> $(document).ready(function() {
> $('#datatable').dataTable( {
> 
> $('.clientinvoices .dropholder').html('
**'); > .. > > > > And I need that button to be a wicket button, is there a way to pass it a > generated link, etc? What would be the best way to deal with this? > One way is to generate this code with Wicket and make it invisible (display: none). Then the JS code should just make it visible (jQuery.show()). Another way is, as Pierre explained, to use Ajax behavior. In some #renderHead() method do: response.render(OnDomReadyHeaderItem.forScript("window.resetUrl = '"+ajaxBehavior.getCallbackUrl()+"';")) Later in the JS code you can use jQuery#ajax() or Wicket.Ajax.get() and make use of window.resetUrl as an endpoint. > > Thanks, Jason > >

Re: adding wicket generated link to javascript

2014-09-03 Thread Pierre Goupil
Good evening,

You can use a Behavior:

- subclass AbstractDefaultAjaxBehavior,
- in the overriden renderHead(final Component component, final
IHeaderResponse response) use template interpolation to pass the URL to the
JS: template.interpolate(variables);
- in the JS, use the Wicket client-side API to do a call to server:
Wicket.Ajax.get({"u":"the/url/to/the/link", "e": "click", "c":"linkId"});  (
https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax)
- and lastly, in the Behavior overridden respond(final AjaxRequestTarget
target) do whatever component manipulation you need and play with the
AjaxRequestTarget.

So: in your JS, you have to find the right place to use the
Wicket.Ajax.get() call and you can pass any value from server, not just the
Behavior URL.

Sorry, I was unable to find a link explaining more template interpolation,
but if you like, I can provide you with some code.

HTH,

Pierre




On Wed, Sep 3, 2014 at 10:15 PM, Jason Novotny 
wrote:

> Hi,
>
> My designer gave me code where HTML is created in javascript as part of a
> jquery dataTable:
>
> 
> $(document).ready(function() {
> $('#datatable').dataTable( {
> 
> $('.clientinvoices .dropholder').html('
**'); > .. > > > > And I need that button to be a wicket button, is there a way to pass it a > generated link, etc? What would be the best way to deal with this? > > Thanks, Jason > > -- La vie est source de joie, la mort est source de paix, seule la transition est difficile.

adding wicket generated link to javascript

2014-09-03 Thread Jason Novotny

Hi,

My designer gave me code where HTML is created in javascript as part of 
a jquery dataTable:



$(document).ready(function() {
$('#datatable').dataTable( {

$('.clientinvoices .dropholder').html('
class="opener">
**');
..



And I need that button to be a wicket button, is there a way to pass it 
a generated link, etc? What would be the best way to deal with this?


Thanks, Jason