You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Craig Tataryn <cr...@tataryn.net> on 2009/04/08 02:34:09 UTC

id attribute of Component Tag in renderHead?

Within a component's renderHead method is it possible to get the value  
of the id attribute for the component tag?

For instance, I have:

<div wicket:id="multi" id="boo"></div>

And within renderHead if I use getMarkupId() I get "multi1" back, if I  
use getMarkupId(false) I get null.

The JavaDoc for renderHead indicates:
"either the id attribute set explicitly via a call to  
setMarkupId(String), id attribute defined in the markup, or an  
automatically generated id - in that order"

It doesn't seem to be behaving as described.  Is this a bug?  Or am I  
misinterpreting things?

Thanks,

Craig.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket
twitter: craiger






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


Re: id attribute of Component Tag in renderHead?

Posted by Martin Funk <ma...@googlemail.com>.
look around in the area of HeaderContributor and how it is used in  
JavascriptPackageResource.getHeaderContributor

and keep in mind, when implementing the method renderHead of class  
HeaderContributor, that IHeaderResponse contains a  
method .renderOnDomReadyJavascript(

mf
Am 08.04.2009 um 15:13 schrieb Craig Tataryn:

> On 8-Apr-09, at 3:27 AM, Martijn Dashorst wrote:
>
>> On Wed, Apr 8, 2009 at 4:04 AM, Craig Tataryn <cr...@tataryn.net>  
>> wrote:
>>> but the JavaDoc tells me not to use this
>>> method as it's supposed to be used by Wicket internally only.  And  
>>> they use
>>> capital letters too when telling me this.
>>
>> That is because a kitten gets killed every time you call such  
>> methods. ;-)
>>
>> You can call such methods, but you should be aware that we reserve  
>> the
>> right to remove those methods in a new version, or change the
>> behavior. These methods often also do things inside of Wicket
>> internals that might hinder proper request processing (you might call
>> a method before it is supposed to be called, causing ill effects such
>> as doing expensive things twice or throw NPE's, or a long time after
>> it is supposed to be called and leave a mess).
>>
>> If you need that method, you can call it, but you're on your own :)
>>
>
> Thanks Martijn, is there another way one might be able to get the  
> Markup Component in renderHead?  The one you get from the incoming  
> container is of course the <head> tag.
>
> The scenario I'm using this for must be a common one, I'm using  
> response.renderOnDomReadyJavascript(someJs) within renderHead() and  
> the code within someJs contains some javascript that has  
> document.getElementById(mycomponentId).
>
> Craig.
>
>> Martijn
>>
>> ---------------------------------------------------------------------
>> 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: id attribute of Component Tag in renderHead?

Posted by Craig Tataryn <cr...@tataryn.net>.
On 8-Apr-09, at 3:27 AM, Martijn Dashorst wrote:

> On Wed, Apr 8, 2009 at 4:04 AM, Craig Tataryn <cr...@tataryn.net>  
> wrote:
>> but the JavaDoc tells me not to use this
>> method as it's supposed to be used by Wicket internally only.  And  
>> they use
>> capital letters too when telling me this.
>
> That is because a kitten gets killed every time you call such  
> methods. ;-)
>
> You can call such methods, but you should be aware that we reserve the
> right to remove those methods in a new version, or change the
> behavior. These methods often also do things inside of Wicket
> internals that might hinder proper request processing (you might call
> a method before it is supposed to be called, causing ill effects such
> as doing expensive things twice or throw NPE's, or a long time after
> it is supposed to be called and leave a mess).
>
> If you need that method, you can call it, but you're on your own :)
>

Thanks Martijn, is there another way one might be able to get the  
Markup Component in renderHead?  The one you get from the incoming  
container is of course the <head> tag.

The scenario I'm using this for must be a common one, I'm using  
response.renderOnDomReadyJavascript(someJs) within renderHead() and  
the code within someJs contains some javascript that has  
document.getElementById(mycomponentId).

Craig.

> Martijn
>
> ---------------------------------------------------------------------
> 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: id attribute of Component Tag in renderHead?

Posted by Martijn Dashorst <ma...@gmail.com>.
On Wed, Apr 8, 2009 at 4:04 AM, Craig Tataryn <cr...@tataryn.net> wrote:
> but the JavaDoc tells me not to use this
> method as it's supposed to be used by Wicket internally only.  And they use
> capital letters too when telling me this.

That is because a kitten gets killed every time you call such methods. ;-)

You can call such methods, but you should be aware that we reserve the
right to remove those methods in a new version, or change the
behavior. These methods often also do things inside of Wicket
internals that might hinder proper request processing (you might call
a method before it is supposed to be called, causing ill effects such
as doing expensive things twice or throw NPE's, or a long time after
it is supposed to be called and leave a mess).

If you need that method, you can call it, but you're on your own :)

Martijn

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


Re: id attribute of Component Tag in renderHead?

Posted by Craig Tataryn <cr...@tataryn.net>.
FYI, the only way I can seem to get the id value within renderHead is  
to use Component's getMarkupAttributes(), but the JavaDoc tells me not  
to use this method as it's supposed to be used by Wicket internally  
only.  And they use capital letters too when telling me this.

What to do, what to do...

On 7-Apr-09, at 7:34 PM, Craig Tataryn wrote:

> Within a component's renderHead method is it possible to get the  
> value of the id attribute for the component tag?
>
> For instance, I have:
>
> <div wicket:id="multi" id="boo"></div>
>
> And within renderHead if I use getMarkupId() I get "multi1" back, if  
> I use getMarkupId(false) I get null.
>
> The JavaDoc for renderHead indicates:
> "either the id attribute set explicitly via a call to  
> setMarkupId(String), id attribute defined in the markup, or an  
> automatically generated id - in that order"
>
> It doesn't seem to be behaving as described.  Is this a bug?  Or am  
> I misinterpreting things?
>
> Thanks,
>
> Craig.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket
> twitter: craiger
>
>
>
>
>


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


Re: id attribute of Component Tag in renderHead?

Posted by Craig Tataryn <cr...@tataryn.net>.
On 8-Apr-09, at 10:31 AM, Igor Vaynberg wrote:

> we do not support getting the id from markup. this is because based on
> where your code is it is not always possible - eg you may need it
> before the markup for that component has been loaded or parsed, and we
> may not always know what the markup will be to do a just in time
> markup load. this is why we recommend setting the id from code if you
> need a fixed one.
>

Alright, so what you are saying is when renderHead is processed for my  
component it's not necessarily the case that the markup for component  
has been loaded/parsed?  This is definitely something I need to know  
for sure... for now I guess I can see if it's possible to move my code  
instead into the component's own onload().

Craig.

> -igor
>
> On Tue, Apr 7, 2009 at 5:34 PM, Craig Tataryn <cr...@tataryn.net>  
> wrote:
>> Within a component's renderHead method is it possible to get the  
>> value of
>> the id attribute for the component tag?
>>
>> For instance, I have:
>>
>> <div wicket:id="multi" id="boo"></div>
>>
>> And within renderHead if I use getMarkupId() I get "multi1" back,  
>> if I use
>> getMarkupId(false) I get null.
>>
>> The JavaDoc for renderHead indicates:
>> "either the id attribute set explicitly via a call to  
>> setMarkupId(String),
>> id attribute defined in the markup, or an automatically generated  
>> id - in
>> that order"
>>
>> It doesn't seem to be behaving as described.  Is this a bug?  Or am I
>> misinterpreting things?
>>
>> Thanks,
>>
>> Craig.
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.feedburner.com/TheBasementCoders
>> irc: ThaDon on freenode #basementcoders, ##wicket
>> twitter: craiger
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: id attribute of Component Tag in renderHead?

Posted by Igor Vaynberg <ig...@gmail.com>.
we do not support getting the id from markup. this is because based on
where your code is it is not always possible - eg you may need it
before the markup for that component has been loaded or parsed, and we
may not always know what the markup will be to do a just in time
markup load. this is why we recommend setting the id from code if you
need a fixed one.

-igor

On Tue, Apr 7, 2009 at 5:34 PM, Craig Tataryn <cr...@tataryn.net> wrote:
> Within a component's renderHead method is it possible to get the value of
> the id attribute for the component tag?
>
> For instance, I have:
>
> <div wicket:id="multi" id="boo"></div>
>
> And within renderHead if I use getMarkupId() I get "multi1" back, if I use
> getMarkupId(false) I get null.
>
> The JavaDoc for renderHead indicates:
> "either the id attribute set explicitly via a call to setMarkupId(String),
> id attribute defined in the markup, or an automatically generated id - in
> that order"
>
> It doesn't seem to be behaving as described.  Is this a bug?  Or am I
> misinterpreting things?
>
> Thanks,
>
> Craig.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket
> twitter: craiger
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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