You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ralf Eichinger <ra...@pixotec.de> on 2010/04/19 05:25:21 UTC

Javascript template as linked header contribution?

How to change

add(JavascriptPackageResource.getHeaderContribution(this.getClass(),
  "js/lightbox.js"));

so that variables inside "lightbox.js" are replace on delivery?

I tried something like this:

PackagedTextTemplate jsTemplate = new PackagedTextTemplate(this
				.getClass(), "js/lightbox.js");
TextTemplateSharedResourceFactory resourceReference = new
TextTemplateSharedResourceFactory(jsTemplate, this.getClass());

String webappContext = WebApplication.get().getServletContext()
				.getContextPath();
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("webappContext", webappContext);
TextTemplateLink ref = new TextTemplateLink("", resourceReference,
				parameters);
??? what to do with link ???

or when I try

...
add(TextTemplateHeaderContributor.forJavaScript(jsTemplate, new
Model((Serializable) parameters)));

the content is rendered into head, what I do not want.
I just want a header contribution to a parsed template like this:
<script type="text/javascript" src="..."></script>

Any ideas?


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


Re: Javascript template as linked header contribution?

Posted by Igor Vaynberg <ig...@gmail.com>.
jira issue or this request never happened :)

-igor

On Tue, May 18, 2010 at 12:07 AM, Ralf Eichinger
<ra...@pixotec.de> wrote:
> Finally I made it working after finding this WIKI entry:
> https://cwiki.apache.org/WICKET/dynamically-generate-a-css-stylesheet.html
>
> Just used it the same way for Javascript file.
>
> Igor: This very useful class should be integrated into Wicket core!
> (under org.apache.wicket.markup.html.resources)
>
> Am Montag, den 19.04.2010, 17:52 -0700 schrieb Igor Vaynberg:
>> i meant you have to create the classes...
>>
>> -igor
>>
>> On Mon, Apr 19, 2010 at 4:10 PM, Ralf Eichinger
>> <ra...@pixotec.de> wrote:
>> > Am Montag, den 19.04.2010, 09:08 -0700 schrieb Igor Vaynberg:
>> >> you will have to create a TextTemplateResource to serve such resources
>> >> and a TextTemplateResourceReference to create urls for them.
>> >>
>> >> -igor
>> >
>> > as there are no TextTemplateResource and TextTemplateResourceReference
>> > classes in Wicket 1.4.7, I tried this:
>> >
>> > PackagedTextTemplate jsTemplate = new
>> >  PackagedTextTemplate(this.getClass(), "js/lightbox.js");
>> >
>> > TextTemplateSharedResourceFactory ttsr = new
>> >  TextTemplateSharedResourceFactory(jsTemplate, this.getClass());
>> >
>> > String webappContext = WebApplication.get().getServletContext()
>> >  .getContextPath();
>> >
>> > Map<String, Object> parameters = new HashMap<String, Object>();
>> > parameters.put("webappContext", webappContext);
>> > TextTemplateLink ref = new TextTemplateLink("lightbox", ttsr,
>> >  parameters);
>> > add(ref);
>> >
>> > and in panels html:
>> >
>> > <wicket:head>
>> > <script wicket:id="lightbox" src="#" language="JavaScript"></script>
>> > </wicket:head>
>> >
>> > this resulted in a rendered URL (that looks weired):
>> >
>> > <script wicket:id="lightbox" src="resources/LightBox2Panel/%2fnetcms"
>> > language="JavaScript"></script>
>> >
>> > And this link returns a 404 error...
>> >
>> > So what's wrong?
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Javascript template as linked header contribution?

Posted by Ralf Eichinger <ra...@pixotec.de>.
Finally I made it working after finding this WIKI entry:
https://cwiki.apache.org/WICKET/dynamically-generate-a-css-stylesheet.html

Just used it the same way for Javascript file.

Igor: This very useful class should be integrated into Wicket core!
(under org.apache.wicket.markup.html.resources)

Am Montag, den 19.04.2010, 17:52 -0700 schrieb Igor Vaynberg:
> i meant you have to create the classes...
> 
> -igor
> 
> On Mon, Apr 19, 2010 at 4:10 PM, Ralf Eichinger
> <ra...@pixotec.de> wrote:
> > Am Montag, den 19.04.2010, 09:08 -0700 schrieb Igor Vaynberg:
> >> you will have to create a TextTemplateResource to serve such resources
> >> and a TextTemplateResourceReference to create urls for them.
> >>
> >> -igor
> >
> > as there are no TextTemplateResource and TextTemplateResourceReference
> > classes in Wicket 1.4.7, I tried this:
> >
> > PackagedTextTemplate jsTemplate = new
> >  PackagedTextTemplate(this.getClass(), "js/lightbox.js");
> >
> > TextTemplateSharedResourceFactory ttsr = new
> >  TextTemplateSharedResourceFactory(jsTemplate, this.getClass());
> >
> > String webappContext = WebApplication.get().getServletContext()
> >  .getContextPath();
> >
> > Map<String, Object> parameters = new HashMap<String, Object>();
> > parameters.put("webappContext", webappContext);
> > TextTemplateLink ref = new TextTemplateLink("lightbox", ttsr,
> >  parameters);
> > add(ref);
> >
> > and in panels html:
> >
> > <wicket:head>
> > <script wicket:id="lightbox" src="#" language="JavaScript"></script>
> > </wicket:head>
> >
> > this resulted in a rendered URL (that looks weired):
> >
> > <script wicket:id="lightbox" src="resources/LightBox2Panel/%2fnetcms"
> > language="JavaScript"></script>
> >
> > And this link returns a 404 error...
> >
> > So what's wrong?
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 



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


Re: Javascript template as linked header contribution?

Posted by Igor Vaynberg <ig...@gmail.com>.
i meant you have to create the classes...

-igor

On Mon, Apr 19, 2010 at 4:10 PM, Ralf Eichinger
<ra...@pixotec.de> wrote:
> Am Montag, den 19.04.2010, 09:08 -0700 schrieb Igor Vaynberg:
>> you will have to create a TextTemplateResource to serve such resources
>> and a TextTemplateResourceReference to create urls for them.
>>
>> -igor
>
> as there are no TextTemplateResource and TextTemplateResourceReference
> classes in Wicket 1.4.7, I tried this:
>
> PackagedTextTemplate jsTemplate = new
>  PackagedTextTemplate(this.getClass(), "js/lightbox.js");
>
> TextTemplateSharedResourceFactory ttsr = new
>  TextTemplateSharedResourceFactory(jsTemplate, this.getClass());
>
> String webappContext = WebApplication.get().getServletContext()
>  .getContextPath();
>
> Map<String, Object> parameters = new HashMap<String, Object>();
> parameters.put("webappContext", webappContext);
> TextTemplateLink ref = new TextTemplateLink("lightbox", ttsr,
>  parameters);
> add(ref);
>
> and in panels html:
>
> <wicket:head>
> <script wicket:id="lightbox" src="#" language="JavaScript"></script>
> </wicket:head>
>
> this resulted in a rendered URL (that looks weired):
>
> <script wicket:id="lightbox" src="resources/LightBox2Panel/%2fnetcms"
> language="JavaScript"></script>
>
> And this link returns a 404 error...
>
> So what's wrong?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Javascript template as linked header contribution?

Posted by Ralf Eichinger <ra...@pixotec.de>.
Am Montag, den 19.04.2010, 09:08 -0700 schrieb Igor Vaynberg:
> you will have to create a TextTemplateResource to serve such resources
> and a TextTemplateResourceReference to create urls for them.
> 
> -igor

as there are no TextTemplateResource and TextTemplateResourceReference
classes in Wicket 1.4.7, I tried this:

PackagedTextTemplate jsTemplate = new   
  PackagedTextTemplate(this.getClass(), "js/lightbox.js");

TextTemplateSharedResourceFactory ttsr = new
  TextTemplateSharedResourceFactory(jsTemplate, this.getClass());

String webappContext = WebApplication.get().getServletContext()
  .getContextPath();

Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("webappContext", webappContext);
TextTemplateLink ref = new TextTemplateLink("lightbox", ttsr,
  parameters);
add(ref);

and in panels html:

<wicket:head>
<script wicket:id="lightbox" src="#" language="JavaScript"></script>
</wicket:head>

this resulted in a rendered URL (that looks weired):

<script wicket:id="lightbox" src="resources/LightBox2Panel/%2fnetcms"
language="JavaScript"></script>

And this link returns a 404 error...

So what's wrong?



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


Re: Javascript template as linked header contribution?

Posted by Igor Vaynberg <ig...@gmail.com>.
you will have to create a TextTemplateResource to serve such resources
and a TextTemplateResourceReference to create urls for them.

-igor

On Sun, Apr 18, 2010 at 8:25 PM, Ralf Eichinger
<ra...@pixotec.de> wrote:
> How to change
>
> add(JavascriptPackageResource.getHeaderContribution(this.getClass(),
>  "js/lightbox.js"));
>
> so that variables inside "lightbox.js" are replace on delivery?
>
> I tried something like this:
>
> PackagedTextTemplate jsTemplate = new PackagedTextTemplate(this
>                                .getClass(), "js/lightbox.js");
> TextTemplateSharedResourceFactory resourceReference = new
> TextTemplateSharedResourceFactory(jsTemplate, this.getClass());
>
> String webappContext = WebApplication.get().getServletContext()
>                                .getContextPath();
> Map<String, Object> parameters = new HashMap<String, Object>();
> parameters.put("webappContext", webappContext);
> TextTemplateLink ref = new TextTemplateLink("", resourceReference,
>                                parameters);
> ??? what to do with link ???
>
> or when I try
>
> ...
> add(TextTemplateHeaderContributor.forJavaScript(jsTemplate, new
> Model((Serializable) parameters)));
>
> the content is rendered into head, what I do not want.
> I just want a header contribution to a parsed template like this:
> <script type="text/javascript" src="..."></script>
>
> Any ideas?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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