wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Colman" <chr...@stepaheadsoftware.com>
Subject Writing to header causes 'not yet working' code to be executed
Date Sun, 01 Apr 2012 21:16:56 GMT
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 StringResponse
response = 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: chrisc@stepahead.com.au <mailto://chrisc@stepahead.com.au> 
Website:
http://www.pagebloom.com <blocked::http://www.pagebloom.com/> 
http://develop.stepaheadsoftware.com
<blocked::http://develop.stepaheadsoftware.com/> 
 
 

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message