You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "m.ugues" <m....@gmail.com> on 2011/08/23 18:25:49 UTC

Attach multiple javascript file to a page

Hallo all.
I'm new to this mailing list.

I'm joking with wicket 1.4.18.
I have this simple problem: I'm trying to attach 2 js files on my page in
this way:

class MyPage extends WebPage {
	add(new StyleSheetReference("ui-lightness", getClass(),
"css/ui-lightness/jquery-ui-1.8.16.custom.css"));

	add(new JavaScriptReference("indexController1", getClass(),
"js/indexController1.js"));
	add(new JavaScriptReference("indexController", getClass(),
"js/indexController.js"));

An the relative html

<head>
 				
		<link wicket:id="ui-lightness"/>		
		<script wicket:id="indexController1"/>
		<script wicket:id="indexController"/>

The javascript file contain 2 alert:

indexController --> alert("Cippa");
indexController1 --> alert("Cippa1");

When I execute this page the problem is that the html seems to be rendered
correctly as you can see:
<head>
 				
		<link wicket:id="ui-lightness" rel="stylesheet" type="text/css"
href="resources/com.example.app.MyPage/css/ui-lightness/jquery-ui-1.8.16.custom.css"/>		
		
		<script wicket:id="indexController1" type="text/javascript"
src="resources/com.example.app.MyPage/js/indexController1.js"/>
		<script wicket:id="indexController" type="text/javascript"
src="resources/com.example.app.MyPage/js/indexController.js"/>

But the behaviour is strange: it's executed only the first javascript, ever.
If I change the order same problem.

Where am I wrong?

Kind regards
Massimo

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Attach-multiple-javascript-file-to-a-page-tp3763258p3763258.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Attach multiple javascript file to a page

Posted by "m.ugues" <m....@gmail.com>.
I tried before, same behaviour.

Where could be the problem?
Maybe I should link my javascript and css directly in my html page, but I
read  https://cwiki.apache.org/WICKET/including-css-resources.html here  
that the best practice is linking them (js and css) server-side.

Massimo

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Attach-multiple-javascript-file-to-a-page-tp3763258p3764628.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Attach multiple javascript file to a page

Posted by Martin Grigorov <mg...@apache.org>.
Try with console.log() instead of alert()

On Tue, Aug 23, 2011 at 7:25 PM, m.ugues <m....@gmail.com> wrote:
> Hallo all.
> I'm new to this mailing list.
>
> I'm joking with wicket 1.4.18.
> I have this simple problem: I'm trying to attach 2 js files on my page in
> this way:
>
> class MyPage extends WebPage {
>        add(new StyleSheetReference("ui-lightness", getClass(),
> "css/ui-lightness/jquery-ui-1.8.16.custom.css"));
>
>        add(new JavaScriptReference("indexController1", getClass(),
> "js/indexController1.js"));
>        add(new JavaScriptReference("indexController", getClass(),
> "js/indexController.js"));
>
> An the relative html
>
> <head>
>
>                <link wicket:id="ui-lightness"/>
>                <script wicket:id="indexController1"/>
>                <script wicket:id="indexController"/>
>
> The javascript file contain 2 alert:
>
> indexController --> alert("Cippa");
> indexController1 --> alert("Cippa1");
>
> When I execute this page the problem is that the html seems to be rendered
> correctly as you can see:
> <head>
>
>                <link wicket:id="ui-lightness" rel="stylesheet" type="text/css"
> href="resources/com.example.app.MyPage/css/ui-lightness/jquery-ui-1.8.16.custom.css"/>
>
>                <script wicket:id="indexController1" type="text/javascript"
> src="resources/com.example.app.MyPage/js/indexController1.js"/>
>                <script wicket:id="indexController" type="text/javascript"
> src="resources/com.example.app.MyPage/js/indexController.js"/>
>
> But the behaviour is strange: it's executed only the first javascript, ever.
> If I change the order same problem.
>
> Where am I wrong?
>
> Kind regards
> Massimo
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Attach-multiple-javascript-file-to-a-page-tp3763258p3763258.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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