You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sigmar Muuga <me...@gmail.com> on 2010/03/21 19:53:24 UTC

Dynamic javascript generation

Hello,
I have to generate some javascript on the server side and then include it
into my page.
Which is the best way to do this with current stable wicket release?

A the moment I am thinking about extending WebResource....

Sigmar

Re: Dynamic javascript generation

Posted by Sigmar Muuga <me...@gmail.com>.
But I got my problem solved with response.renderJavascript("
second", "firstUniqueID");

AbstractBehaviour didnt help me out...

Thanks!


On Mon, Mar 22, 2010 at 8:54 AM, Sigmar Muuga <me...@gmail.com> wrote:

> It cannot be done like this, I got the error:
>
> WicketMessage: Cannot modify component hierarchy after render phase has started (page version cant change then anymore)
>
>
>
> On Sun, Mar 21, 2010 at 10:38 PM, Stefan Lindner <li...@visionet.de>wrote:
>
>> Add them in the needed order
>>
>>        response.renderJavascript("first", "firstUniqueID");
>>        response.renderJavascript("second", "firstUniqueID");
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Sigmar Muuga [mailto:meediake@gmail.com]
>> Gesendet: Sonntag, 21. März 2010 21:36
>> An: users@wicket.apache.org
>> Betreff: Re: Dynamic javascript generation
>>
>> My <script> tags are all in specific order, so how can I put this script
>> right after some certain script tag there?
>>
>> Sigmar
>>
>> On Sun, Mar 21, 2010 at 10:31 PM, Stefan Lindner <lindner@visionet.de
>> >wrote:
>>
>> > Ok, try this
>> >
>> >        add(    new AbstractBehavior() {
>> >                        @Override
>> >                        public void renderHead(IHeaderResponse response)
>> {
>> >                                super.renderHead(response);
>> >                                response.renderJavascript("<some
>> dynamically
>> > generated JS>", "<uniqueID>");
>> >                        }
>> >                }
>> >        );
>> >
>> > Every time the component (to that the AbstractBehaivor is added) is
>> redrawn
>> > (eg. Initally or after an AjaxUpodate) the dynamically generated
>> javascript
>> > is renderedinto <HEAD>.
>> > If you want to make sure that it is not rendered twice from another
>> > component with thie AbstractBehavior, just add some "uniqueID" in the
>> > renderJavascript call.
>> >
>> >
>> >
>> > -----Ursprüngliche Nachricht-----
>> > Von: Sigmar Muuga [mailto:meediake@gmail.com]
>> > Gesendet: Sonntag, 21. März 2010 21:22
>> > An: users@wicket.apache.org
>> > Betreff: Re: Dynamic javascript generation
>> >
>> > I need to include this dynamic js in my header with <script> tag like
>> this
>> > in gmail:
>> >
>> > <script src="?view=page&amp;name=browser&amp;ver=zpwhtygjntrz
>> > <view-source:
>> > https://mail.google.com/mail/?view=page&name=browser&ver=zpwhtygjntrz
>> > >"></script>
>> >
>> >
>> > Some behaviour of that script depends on my session data on server side.
>> > I think that its not very complicated
>> > But I dont want to hardcode it to my html page, because urls and paths
>> my
>> > changes. Dealing with resources provides more reliable configuration
>> etc..
>> >
>> > Sigmar
>> >
>> >
>> > On Sun, Mar 21, 2010 at 9:19 PM, Stefan Lindner <li...@visionet.de>
>> > wrote:
>> >
>> > > Generate some Javasript in response to e.g. a button klick?
>> > > Or generate JavaScript when the page is rendered?
>> > >
>> > > -----Ursprüngliche Nachricht-----
>> > > Von: Sigmar Muuga [mailto:meediake@gmail.com]
>> > > Gesendet: Sonntag, 21. März 2010 19:53
>> > > An: users@wicket.apache.org
>> > > Betreff: Dynamic javascript generation
>> > >
>> > > Hello,
>> > > I have to generate some javascript on the server side and then include
>> it
>> > > into my page.
>> > > Which is the best way to do this with current stable wicket release?
>> > >
>> > > A the moment I am thinking about extending WebResource....
>> > >
>> > > Sigmar
>> > >
>> >
>>
>
>

Re: Dynamic javascript generation

Posted by Sigmar Muuga <me...@gmail.com>.
It cannot be done like this, I got the error:

WicketMessage: Cannot modify component hierarchy after render phase
has started (page version cant change then anymore)



On Sun, Mar 21, 2010 at 10:38 PM, Stefan Lindner <li...@visionet.de>wrote:

> Add them in the needed order
>
>        response.renderJavascript("first", "firstUniqueID");
>        response.renderJavascript("second", "firstUniqueID");
>
> -----Ursprüngliche Nachricht-----
> Von: Sigmar Muuga [mailto:meediake@gmail.com]
> Gesendet: Sonntag, 21. März 2010 21:36
> An: users@wicket.apache.org
> Betreff: Re: Dynamic javascript generation
>
> My <script> tags are all in specific order, so how can I put this script
> right after some certain script tag there?
>
> Sigmar
>
> On Sun, Mar 21, 2010 at 10:31 PM, Stefan Lindner <lindner@visionet.de
> >wrote:
>
> > Ok, try this
> >
> >        add(    new AbstractBehavior() {
> >                        @Override
> >                        public void renderHead(IHeaderResponse response) {
> >                                super.renderHead(response);
> >                                response.renderJavascript("<some
> dynamically
> > generated JS>", "<uniqueID>");
> >                        }
> >                }
> >        );
> >
> > Every time the component (to that the AbstractBehaivor is added) is
> redrawn
> > (eg. Initally or after an AjaxUpodate) the dynamically generated
> javascript
> > is renderedinto <HEAD>.
> > If you want to make sure that it is not rendered twice from another
> > component with thie AbstractBehavior, just add some "uniqueID" in the
> > renderJavascript call.
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Sigmar Muuga [mailto:meediake@gmail.com]
> > Gesendet: Sonntag, 21. März 2010 21:22
> > An: users@wicket.apache.org
> > Betreff: Re: Dynamic javascript generation
> >
> > I need to include this dynamic js in my header with <script> tag like
> this
> > in gmail:
> >
> > <script src="?view=page&amp;name=browser&amp;ver=zpwhtygjntrz
> > <view-source:
> > https://mail.google.com/mail/?view=page&name=browser&ver=zpwhtygjntrz
> > >"></script>
> >
> >
> > Some behaviour of that script depends on my session data on server side.
> > I think that its not very complicated
> > But I dont want to hardcode it to my html page, because urls and paths my
> > changes. Dealing with resources provides more reliable configuration
> etc..
> >
> > Sigmar
> >
> >
> > On Sun, Mar 21, 2010 at 9:19 PM, Stefan Lindner <li...@visionet.de>
> > wrote:
> >
> > > Generate some Javasript in response to e.g. a button klick?
> > > Or generate JavaScript when the page is rendered?
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Sigmar Muuga [mailto:meediake@gmail.com]
> > > Gesendet: Sonntag, 21. März 2010 19:53
> > > An: users@wicket.apache.org
> > > Betreff: Dynamic javascript generation
> > >
> > > Hello,
> > > I have to generate some javascript on the server side and then include
> it
> > > into my page.
> > > Which is the best way to do this with current stable wicket release?
> > >
> > > A the moment I am thinking about extending WebResource....
> > >
> > > Sigmar
> > >
> >
>

RE: Dynamic javascript generation

Posted by Stefan Lindner <li...@visionet.de>.
Add them in the needed order

	response.renderJavascript("first", "firstUniqueID");
	response.renderJavascript("second", "firstUniqueID");

-----Ursprüngliche Nachricht-----
Von: Sigmar Muuga [mailto:meediake@gmail.com] 
Gesendet: Sonntag, 21. März 2010 21:36
An: users@wicket.apache.org
Betreff: Re: Dynamic javascript generation

My <script> tags are all in specific order, so how can I put this script
right after some certain script tag there?

Sigmar

On Sun, Mar 21, 2010 at 10:31 PM, Stefan Lindner <li...@visionet.de>wrote:

> Ok, try this
>
>        add(    new AbstractBehavior() {
>                        @Override
>                        public void renderHead(IHeaderResponse response) {
>                                super.renderHead(response);
>                                response.renderJavascript("<some dynamically
> generated JS>", "<uniqueID>");
>                        }
>                }
>        );
>
> Every time the component (to that the AbstractBehaivor is added) is redrawn
> (eg. Initally or after an AjaxUpodate) the dynamically generated javascript
> is renderedinto <HEAD>.
> If you want to make sure that it is not rendered twice from another
> component with thie AbstractBehavior, just add some "uniqueID" in the
> renderJavascript call.
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Sigmar Muuga [mailto:meediake@gmail.com]
> Gesendet: Sonntag, 21. März 2010 21:22
> An: users@wicket.apache.org
> Betreff: Re: Dynamic javascript generation
>
> I need to include this dynamic js in my header with <script> tag like this
> in gmail:
>
> <script src="?view=page&amp;name=browser&amp;ver=zpwhtygjntrz
> <view-source:
> https://mail.google.com/mail/?view=page&name=browser&ver=zpwhtygjntrz
> >"></script>
>
>
> Some behaviour of that script depends on my session data on server side.
> I think that its not very complicated
> But I dont want to hardcode it to my html page, because urls and paths my
> changes. Dealing with resources provides more reliable configuration etc..
>
> Sigmar
>
>
> On Sun, Mar 21, 2010 at 9:19 PM, Stefan Lindner <li...@visionet.de>
> wrote:
>
> > Generate some Javasript in response to e.g. a button klick?
> > Or generate JavaScript when the page is rendered?
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Sigmar Muuga [mailto:meediake@gmail.com]
> > Gesendet: Sonntag, 21. März 2010 19:53
> > An: users@wicket.apache.org
> > Betreff: Dynamic javascript generation
> >
> > Hello,
> > I have to generate some javascript on the server side and then include it
> > into my page.
> > Which is the best way to do this with current stable wicket release?
> >
> > A the moment I am thinking about extending WebResource....
> >
> > Sigmar
> >
>

Re: Dynamic javascript generation

Posted by Sigmar Muuga <me...@gmail.com>.
My <script> tags are all in specific order, so how can I put this script
right after some certain script tag there?

Sigmar

On Sun, Mar 21, 2010 at 10:31 PM, Stefan Lindner <li...@visionet.de>wrote:

> Ok, try this
>
>        add(    new AbstractBehavior() {
>                        @Override
>                        public void renderHead(IHeaderResponse response) {
>                                super.renderHead(response);
>                                response.renderJavascript("<some dynamically
> generated JS>", "<uniqueID>");
>                        }
>                }
>        );
>
> Every time the component (to that the AbstractBehaivor is added) is redrawn
> (eg. Initally or after an AjaxUpodate) the dynamically generated javascript
> is renderedinto <HEAD>.
> If you want to make sure that it is not rendered twice from another
> component with thie AbstractBehavior, just add some "uniqueID" in the
> renderJavascript call.
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Sigmar Muuga [mailto:meediake@gmail.com]
> Gesendet: Sonntag, 21. März 2010 21:22
> An: users@wicket.apache.org
> Betreff: Re: Dynamic javascript generation
>
> I need to include this dynamic js in my header with <script> tag like this
> in gmail:
>
> <script src="?view=page&amp;name=browser&amp;ver=zpwhtygjntrz
> <view-source:
> https://mail.google.com/mail/?view=page&name=browser&ver=zpwhtygjntrz
> >"></script>
>
>
> Some behaviour of that script depends on my session data on server side.
> I think that its not very complicated
> But I dont want to hardcode it to my html page, because urls and paths my
> changes. Dealing with resources provides more reliable configuration etc..
>
> Sigmar
>
>
> On Sun, Mar 21, 2010 at 9:19 PM, Stefan Lindner <li...@visionet.de>
> wrote:
>
> > Generate some Javasript in response to e.g. a button klick?
> > Or generate JavaScript when the page is rendered?
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Sigmar Muuga [mailto:meediake@gmail.com]
> > Gesendet: Sonntag, 21. März 2010 19:53
> > An: users@wicket.apache.org
> > Betreff: Dynamic javascript generation
> >
> > Hello,
> > I have to generate some javascript on the server side and then include it
> > into my page.
> > Which is the best way to do this with current stable wicket release?
> >
> > A the moment I am thinking about extending WebResource....
> >
> > Sigmar
> >
>

AW: Dynamic javascript generation

Posted by Stefan Lindner <li...@visionet.de>.
Ok, try this

	add(	new AbstractBehavior() {
			@Override
			public void renderHead(IHeaderResponse response) {
				super.renderHead(response);
				response.renderJavascript("<some dynamically generated JS>", "<uniqueID>");
			}
		}
	);

Every time the component (to that the AbstractBehaivor is added) is redrawn (eg. Initally or after an AjaxUpodate) the dynamically generated javascript is renderedinto <HEAD>.
If you want to make sure that it is not rendered twice from another component with thie AbstractBehavior, just add some "uniqueID" in the renderJavascript call.



-----Ursprüngliche Nachricht-----
Von: Sigmar Muuga [mailto:meediake@gmail.com] 
Gesendet: Sonntag, 21. März 2010 21:22
An: users@wicket.apache.org
Betreff: Re: Dynamic javascript generation

I need to include this dynamic js in my header with <script> tag like this
in gmail:

<script src="?view=page&amp;name=browser&amp;ver=zpwhtygjntrz
<view-source:https://mail.google.com/mail/?view=page&name=browser&ver=zpwhtygjntrz>"></script>


Some behaviour of that script depends on my session data on server side.
I think that its not very complicated
But I dont want to hardcode it to my html page, because urls and paths my
changes. Dealing with resources provides more reliable configuration etc..

Sigmar


On Sun, Mar 21, 2010 at 9:19 PM, Stefan Lindner <li...@visionet.de> wrote:

> Generate some Javasript in response to e.g. a button klick?
> Or generate JavaScript when the page is rendered?
>
> -----Ursprüngliche Nachricht-----
> Von: Sigmar Muuga [mailto:meediake@gmail.com]
> Gesendet: Sonntag, 21. März 2010 19:53
> An: users@wicket.apache.org
> Betreff: Dynamic javascript generation
>
> Hello,
> I have to generate some javascript on the server side and then include it
> into my page.
> Which is the best way to do this with current stable wicket release?
>
> A the moment I am thinking about extending WebResource....
>
> Sigmar
>

Re: Dynamic javascript generation

Posted by Sigmar Muuga <me...@gmail.com>.
I need to include this dynamic js in my header with <script> tag like this
in gmail:

<script src="?view=page&amp;name=browser&amp;ver=zpwhtygjntrz
<view-source:https://mail.google.com/mail/?view=page&name=browser&ver=zpwhtygjntrz>"></script>


Some behaviour of that script depends on my session data on server side.
I think that its not very complicated
But I dont want to hardcode it to my html page, because urls and paths my
changes. Dealing with resources provides more reliable configuration etc..

Sigmar


On Sun, Mar 21, 2010 at 9:19 PM, Stefan Lindner <li...@visionet.de> wrote:

> Generate some Javasript in response to e.g. a button klick?
> Or generate JavaScript when the page is rendered?
>
> -----Ursprüngliche Nachricht-----
> Von: Sigmar Muuga [mailto:meediake@gmail.com]
> Gesendet: Sonntag, 21. März 2010 19:53
> An: users@wicket.apache.org
> Betreff: Dynamic javascript generation
>
> Hello,
> I have to generate some javascript on the server side and then include it
> into my page.
> Which is the best way to do this with current stable wicket release?
>
> A the moment I am thinking about extending WebResource....
>
> Sigmar
>

RE: Dynamic javascript generation

Posted by Stefan Lindner <li...@visionet.de>.
Generate some Javasript in response to e.g. a button klick?
Or generate JavaScript when the page is rendered?

-----Ursprüngliche Nachricht-----
Von: Sigmar Muuga [mailto:meediake@gmail.com] 
Gesendet: Sonntag, 21. März 2010 19:53
An: users@wicket.apache.org
Betreff: Dynamic javascript generation

Hello,
I have to generate some javascript on the server side and then include it
into my page.
Which is the best way to do this with current stable wicket release?

A the moment I am thinking about extending WebResource....

Sigmar