You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Scott Reed <sr...@avacoda.com> on 2011/07/15 20:01:08 UTC

Controlling head element order with renderHead(IHeaderResponse)

I am adding script and css references on the fly using 
renderHead(IHeaderResponse). However this adds the head elements after 
the Wicket scripts and that interferes with how my scripts and css work. 
When I hardcode my elements before the Wicket elements everything works 
as we need. How can I add my head elements on the fly so they are 
located before the Wicket elements?
  Thanks,
    Scott

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


Re: Controlling head element order with renderHead(IHeaderResponse)

Posted by Scott Reed <sr...@avacoda.com>.
Thanks, Martin.
That example is about the Wicket "header". Will that also work somehow 
for the HTML head? If so, how?
    Scott

On 7/15/2011 2:07 PM, Martin Grigorov wrote:
> You'll need to setup custom response decorator.
> See http://www.wicket-library.com/wicket-examples/resourceaggregation
>
> On Fri, Jul 15, 2011 at 9:01 PM, Scott Reed<sr...@avacoda.com>  wrote:
>> I am adding script and css references on the fly using
>> renderHead(IHeaderResponse). However this adds the head elements after the
>> Wicket scripts and that interferes with how my scripts and css work. When I
>> hardcode my elements before the Wicket elements everything works as we need.
>> How can I add my head elements on the fly so they are located before the
>> Wicket elements?
>>   Thanks,
>>    Scott
>>
>> ---------------------------------------------------------------------
>> 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: Controlling head element order with renderHead(IHeaderResponse)

Posted by Scott Reed <sr...@avacoda.com>.
By hardcoded I mean my HTML file starts with the following head:
<head>
<!-- hardcoded HTML lines -->
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>Sign In</title>
</head>

After I load the page with Ajax it has:

<head>
<!-- lines I'm adding with decorator -->
<link rel="stylesheet" type="text/css" 
href="../../../stylesheets/jquery.mobile-1.0b1/jquery.mobile-1.0b1.css" />
<script type="text/javascript" 
src="../../../stylesheets/jquery-1.6.1/jquery-1.6.1.js"></script>
<script type="text/javascript" 
src="../../../stylesheets/jquery.mobile-1.0b1/jquery.mobile-1.0b1.js"></script> 


<!-- hardcoded HTML lines -->
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>Sign In</title>

<script type="text/javascript" 
src="../resource/org.apache.wicket.markup.html.WicketEventReference/wicket-event-ts1306247910000.js"></script> 

<script type="text/javascript" 
src="../resource/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax-ts1306247910000.js"></script> 

<script type="text/javascript" 
src="../resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug-ts1306247910000.js"></script> 

<script type="text/javascript" id="wicket-ajax-debug-enable">
/*<![CDATA[*/
wicketAjaxDebugEnable=true;
/*]]>*/
</script>
<script type="text/javascript" id="wicket-ajax-base-url">
/*<![CDATA[*/
Wicket.Ajax.baseUrl="wicket/bookmarkable/com.mni.SignInPage?0";
/*]]>*/
</script>
</head>

I'd rather have
<!-- hardcoded HTML lines -->
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>Sign In</title>
be the first thing after <head> followed by the "lines I'm adding with 
decorator".

On 7/18/2011 2:10 PM, Martin Grigorov wrote:
> What exactly is hardcoded ?
> I'm not aware of such documentation but it sounds like a good todo for me.
>
> On Mon, Jul 18, 2011 at 7:35 PM, Scott Reed<sr...@avacoda.com>  wrote:
>> That works quite well, Martin.
>>
>> I can add my on-the-fly contributions at the top of the head. I would like
>> to know how to pin-point the location better so my additions come after the
>> hard-coded HTML meta content-type and title elements. Is there some
>> documentation that might explain more about the whole process of rendering
>> the head?
>>
>>   Thanks,
>>     Scott

Re: Controlling head element order with renderHead(IHeaderResponse)

Posted by Martin Grigorov <mg...@apache.org>.
What exactly is hardcoded ?
I'm not aware of such documentation but it sounds like a good todo for me.

On Mon, Jul 18, 2011 at 7:35 PM, Scott Reed <sr...@avacoda.com> wrote:
> That works quite well, Martin.
>
> I can add my on-the-fly contributions at the top of the head. I would like
> to know how to pin-point the location better so my additions come after the
> hard-coded HTML meta content-type and title elements. Is there some
> documentation that might explain more about the whole process of rendering
> the head?
>
>  Thanks,
>    Scott
>
> On 7/18/2011 3:42 AM, Martin Grigorov wrote:
>>
>> With
>> org.apache.wicket.Application.setHeaderResponseDecorator(IHeaderResponseDecorator)
>> you can setup custom
>> org.apache.wicket.markup.html.IHeaderResponseDecorator.
>> Wicket will call its
>>
>> org.apache.wicket.markup.html.IHeaderResponseDecorator.decorate(IHeaderResponse)
>> when creating IHeaderResponse for each web response. Here you can
>> re-order the header contributions as you wish.
>>
>> See for example
>>
>> org.apache.wicket.resource.filtering.HeaderResponseContainerFilteringHeaderResponse
>> and its specializations.
>>
>> On Fri, Jul 15, 2011 at 10:25 PM, Scott Reed<sr...@avacoda.com>  wrote:
>>>
>>> Looking at that code some more I realize I have no idea what it's doing
>>> and
>>> I'm finding the javadocs and comments pretty opaque. Is there anything
>>> you
>>> can refer me to that will give me the background to understand this? I
>>> have
>>> both Wicket in Action and the Cookbook.
>>>
>>> On 7/15/2011 2:07 PM, Martin Grigorov wrote:
>>>>
>>>> You'll need to setup custom response decorator.
>>>> See http://www.wicket-library.com/wicket-examples/resourceaggregation
>>>>
>>>> On Fri, Jul 15, 2011 at 9:01 PM, Scott Reed<sr...@avacoda.com>    wrote:
>>>>>
>>>>> I am adding script and css references on the fly using
>>>>> renderHead(IHeaderResponse). However this adds the head elements after
>>>>> the
>>>>> Wicket scripts and that interferes with how my scripts and css work.
>>>>> When
>>>>> I
>>>>> hardcode my elements before the Wicket elements everything works as we
>>>>> need.
>>>>> How can I add my head elements on the fly so they are located before
>>>>> the
>>>>> Wicket elements?
>>>>>  Thanks,
>>>>>   Scott
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>
>



-- 
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


Re: Controlling head element order with renderHead(IHeaderResponse)

Posted by Scott Reed <sr...@avacoda.com>.
That works quite well, Martin.

I can add my on-the-fly contributions at the top of the head. I would 
like to know how to pin-point the location better so my additions come 
after the hard-coded HTML meta content-type and title elements. Is there 
some documentation that might explain more about the whole process of 
rendering the head?

   Thanks,
     Scott

On 7/18/2011 3:42 AM, Martin Grigorov wrote:
> With org.apache.wicket.Application.setHeaderResponseDecorator(IHeaderResponseDecorator)
> you can setup custom
> org.apache.wicket.markup.html.IHeaderResponseDecorator.
> Wicket will call its
> org.apache.wicket.markup.html.IHeaderResponseDecorator.decorate(IHeaderResponse)
> when creating IHeaderResponse for each web response. Here you can
> re-order the header contributions as you wish.
>
> See for example
> org.apache.wicket.resource.filtering.HeaderResponseContainerFilteringHeaderResponse
> and its specializations.
>
> On Fri, Jul 15, 2011 at 10:25 PM, Scott Reed<sr...@avacoda.com>  wrote:
>> Looking at that code some more I realize I have no idea what it's doing and
>> I'm finding the javadocs and comments pretty opaque. Is there anything you
>> can refer me to that will give me the background to understand this? I have
>> both Wicket in Action and the Cookbook.
>>
>> On 7/15/2011 2:07 PM, Martin Grigorov wrote:
>>> You'll need to setup custom response decorator.
>>> See http://www.wicket-library.com/wicket-examples/resourceaggregation
>>>
>>> On Fri, Jul 15, 2011 at 9:01 PM, Scott Reed<sr...@avacoda.com>    wrote:
>>>> I am adding script and css references on the fly using
>>>> renderHead(IHeaderResponse). However this adds the head elements after
>>>> the
>>>> Wicket scripts and that interferes with how my scripts and css work. When
>>>> I
>>>> hardcode my elements before the Wicket elements everything works as we
>>>> need.
>>>> How can I add my head elements on the fly so they are located before the
>>>> Wicket elements?
>>>>   Thanks,
>>>>    Scott
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: Controlling head element order with renderHead(IHeaderResponse)

Posted by Martin Grigorov <mg...@apache.org>.
With org.apache.wicket.Application.setHeaderResponseDecorator(IHeaderResponseDecorator)
you can setup custom
org.apache.wicket.markup.html.IHeaderResponseDecorator.
Wicket will call its
org.apache.wicket.markup.html.IHeaderResponseDecorator.decorate(IHeaderResponse)
when creating IHeaderResponse for each web response. Here you can
re-order the header contributions as you wish.

See for example
org.apache.wicket.resource.filtering.HeaderResponseContainerFilteringHeaderResponse
and its specializations.

On Fri, Jul 15, 2011 at 10:25 PM, Scott Reed <sr...@avacoda.com> wrote:
> Looking at that code some more I realize I have no idea what it's doing and
> I'm finding the javadocs and comments pretty opaque. Is there anything you
> can refer me to that will give me the background to understand this? I have
> both Wicket in Action and the Cookbook.
>
> On 7/15/2011 2:07 PM, Martin Grigorov wrote:
>>
>> You'll need to setup custom response decorator.
>> See http://www.wicket-library.com/wicket-examples/resourceaggregation
>>
>> On Fri, Jul 15, 2011 at 9:01 PM, Scott Reed<sr...@avacoda.com>  wrote:
>>>
>>> I am adding script and css references on the fly using
>>> renderHead(IHeaderResponse). However this adds the head elements after
>>> the
>>> Wicket scripts and that interferes with how my scripts and css work. When
>>> I
>>> hardcode my elements before the Wicket elements everything works as we
>>> need.
>>> How can I add my head elements on the fly so they are located before the
>>> Wicket elements?
>>>  Thanks,
>>>   Scott
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>



-- 
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


Re: Controlling head element order with renderHead(IHeaderResponse)

Posted by Scott Reed <sr...@avacoda.com>.
Looking at that code some more I realize I have no idea what it's doing 
and I'm finding the javadocs and comments pretty opaque. Is there 
anything you can refer me to that will give me the background to 
understand this? I have both Wicket in Action and the Cookbook.

On 7/15/2011 2:07 PM, Martin Grigorov wrote:
> You'll need to setup custom response decorator.
> See http://www.wicket-library.com/wicket-examples/resourceaggregation
>
> On Fri, Jul 15, 2011 at 9:01 PM, Scott Reed<sr...@avacoda.com>  wrote:
>> I am adding script and css references on the fly using
>> renderHead(IHeaderResponse). However this adds the head elements after the
>> Wicket scripts and that interferes with how my scripts and css work. When I
>> hardcode my elements before the Wicket elements everything works as we need.
>> How can I add my head elements on the fly so they are located before the
>> Wicket elements?
>>   Thanks,
>>    Scott
>>
>> ---------------------------------------------------------------------
>> 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: Controlling head element order with renderHead(IHeaderResponse)

Posted by Martin Grigorov <mg...@apache.org>.
You'll need to setup custom response decorator.
See http://www.wicket-library.com/wicket-examples/resourceaggregation

On Fri, Jul 15, 2011 at 9:01 PM, Scott Reed <sr...@avacoda.com> wrote:
> I am adding script and css references on the fly using
> renderHead(IHeaderResponse). However this adds the head elements after the
> Wicket scripts and that interferes with how my scripts and css work. When I
> hardcode my elements before the Wicket elements everything works as we need.
> How can I add my head elements on the fly so they are located before the
> Wicket elements?
>  Thanks,
>   Scott
>
> ---------------------------------------------------------------------
> 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