The strange thing is - I do have a <head> in my markup!

And it appears to render to the head section ok most of the time even
though it displays the message.

It really only fails, in a functional way, when I call
response.renderString twice within the renderHead method:

void renderHead
{
        super.renderHead(response);

        // Canonical URL
        String canonicalUrl = getCanonicalUrl();
        if ( !StringUtils.isEmpty(canonicalUrl) )
                response.renderString("<link rel=\"canonical\" href=\""
+ canonicalUrl + "\" />");  // If this line is not executed then head
render works but still displays message.

        // GoogleTrackingCode
        WebsiteMgr websiteMgr = getWebsiteMgr();

        if (websiteMgr != null)
        {
                String trackingHeadCode = websiteMgr.getEndBodyCode();
        
        if ( !StringUtils.isEmpty(trackingHeadCode))
            response.renderString(trackingHeadCode);
        }
}

>-----Original Message-----
>From: Martin Grigorov [mailto:[email protected]]
>Sent: Monday, 2 April 2012 4:58 PM
>To: [email protected]
>Subject: Re: Writing to header causes 'not yet working' code to be
executed
>
>Hi,
>
>Can you create a quickstart ?
>There is a special IMarkupFilter that creates <head> automatically if
you
>don't have one in your page markup. For some reason it seems it didn't
>work.
>
>On Sun, Apr 1, 2012 at 11:16 PM, Chris Colman
><[email protected]>wrote:
>
>> ** **
>>
>> I've overridden renderHead to write to the header of the page but I
get a
>> strange error message that I have not been able to work out. It
executes
>> some code that has a 'not implemented' comment:****
>>
>> ** **
>>
>> The code is in WebPage:****
>>
>> ** **
>>
>>             /******
>>
>>              * Validate that each component which wanted to
contribute to
>> the header section actually was****
>>
>>              * able to do so.****
>>
>>              */****
>>
>>             private void validateHeaders()****
>>
>>             {****
>>
>>                         // search for HtmlHeaderContainer in the
first
>> level of children or deeper****
>>
>>                         // if there are transparent resolvers
used****
>>
>>                         HtmlHeaderContainer header =
visitChildren(new
>> IVisitor<Component, HtmlHeaderContainer>()****
>>
>>                         {****
>>
>>                                     public void component(final
Component
>> component, final IVisit<HtmlHeaderContainer> visit)****
>>
>>                                     {****
>>
>>                                                 if (component
instanceof
>> HtmlHeaderContainer)****
>>
>>                                                 {****
>>
>>
visit.stop((
>> HtmlHeaderContainer)component);****
>>
>>                                                 }****
>>
>>                                                 else if (component
>> instanceof TransparentWebMarkupContainer == false)****
>>
>>                                                 {****
>>
>>
>> visit.dontGoDeeper();****
>>
>>                                                 }****
>>
>>                                     }****
>>
>>                         });****
>>
>> ** **
>>
>>                         if (header == null)****
>>
>>                         {****
>>
>>                                     // the markup must at least
contain a
>> <body> tag for wicket to automatically****
>>
>>                                     // create a HtmlHeaderContainer.
Log
>> an error if no header container****
>>
>>                                     // was created but any of the
>> components or behaviors want to contribute****
>>
>>                                     // something to the header.****
>>
>>                                     header = new HtmlHeaderContainer(
>> HtmlHeaderSectionHandler.HEADER_ID);****
>>
>>                                     add(header);****
>>
>> ** **
>>
>>                                     Response orgResponse =
>getRequestCycle
>> ().getResponse();****
>>
>>                                     try****
>>
>>                                     {****
>>
>>                                                 final
>StringResponseresponse = new
>> StringResponse();****
>>
>>                                                 getRequestCycle().
>> setResponse(response);****
>>
>> ** **
>>
>>                                                 // Render all header
>> sections of all components on the page****
>>
>>
>> AbstractHeaderRenderStrategy.get().renderHeader(header,
getPage());****
>>
>>                                                 response.close();****
>>
>> ** **
>>
>>                                                 if
>(response.getBuffer().length()
>> > 0)****
>>
>>                                                 {****
>>
>>                                                             // @TODO
it
>> is not yet working properly. JDo to fix it****
>>
>>
log.error(
>>
>"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^
>^^^^^^^^^^^^^^^");
>> ****
>>
>>
>log.error("You
>> probably forgot to add a <body> or <head> tag to your markup since no
>> Header Container was \n" +****
>>
>>
"
>> found but components were found which want to write to the <head>
>> section.\n" +****
>>
>>
>> response.getBuffer());****
>>
>>
log.error(
>>
>"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^
>^^^^^^^^^^^^^^^");
>> ****
>>
>>                                                 }****
>>
>>                                     }****
>>
>>                                     catch (Exception e)****
>>
>>                                     {****
>>
>>                                                 // just swallow this
>> exception, there isn't much we can do about.****
>>
>>
log.error("header/body
>> check throws exception", e);****
>>
>>                                     }****
>>
>>                                     finally****
>>
>>                                     {****
>>
>>
this.remove(header);****
>>
>>                                                 getRequestCycle().
>> setResponse(orgResponse);****
>>
>>                                     }****
>>
>>                         }****
>>
>>             }****
>>
>> ** **
>>
>> Yours sincerely,****
>>
>> ** **
>>
>> Chris Colman****
>>
>>  ****
>>
>> Pagebloom Team Leader,****
>>
>> Step Ahead Software
>>
>> ****
>>
>> pagebloom - your business & your website growing together****
>>
>> ** **
>>
>> **Sydney**: (+61 2) 9656 1278     ****Canberra****: (+61 2) 6100 2120
>> ****
>>
>> Email: [email protected] <//[email protected]>****
>>
>> Website:****
>>
>> http://www.pagebloom.com****
>>
>> http://develop.stepaheadsoftware.com****
>>
>>  ****
>>
>> ** **
>>
>
>
>
>--
>Martin Grigorov
>jWeekend
>Training, Consulting, Development
>http://jWeekend.com <http://jweekend.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to