I had a similar problem and considered Martin's approach, but ended up
creating a <div wicket:id="myVar" class="myVar">var value</div> on my
page and accessed it from JS file using $("div.myVar").text() or
something like that.

The advantage of <div> approach is that you can test it statically
without deploying the webapp and your JS file can be safely cached by
the browser improving load time.

Alec

On Fri, Nov 16, 2012 at 7:58 AM, Ernesto Reinaldo Barreiro
<reier...@gmail.com> wrote:
> You can do something like
>
> On your panel
>
>  public void renderHead(final IHeaderResponse response) {
>     PackagedTextTemplate template = new PackagedTextTemplate(MyPanel.class,
> "test.js");
>     Map<String, Object> vars = new MiniMap<String, Object>(1);
>     vars.put("val1", "MyValue");
>     response.renderOnDomReadyJavascript(template.asString(vars));
>   }
>
> ====================test.js=====================
>
> var bla = '${val1}';
>
>
> On Fri, Nov 16, 2012 at 3:51 PM, delta458 <delta...@hotmail.com> wrote:
>
>> @Ernest I just need to write some variables to the .js file
>> like
>>
>> var price;
>> var user;
>>
>> @MartinGrigorov so what should I do to make this work? How can I set my
>> resource to the classpath? and what should I call to make it work?
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Relative-Path-and-Resource-loading-in-wicket-tp4653930p4653945.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>

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

Reply via email to