You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Chris Colman (Created) (JIRA)" <ji...@apache.org> on 2012/02/14 07:32:59 UTC

[jira] [Created] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Components resolved by an IComponentResolver fail to contribute to header via renderHead
----------------------------------------------------------------------------------------

                 Key: WICKET-4408
                 URL: https://issues.apache.org/jira/browse/WICKET-4408
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.4
         Environment: Happens on all FireFox  Chrome, IE
Windows XP

            Reporter: Chris Colman


If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.

If the same component is added explicitly to its parent then its renderHead method is called.

This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.

Class MyPanel extends Panel
{

/**

 * Write out necessary header markup.

 */

@Override

public void renderHead(IHeaderResponse response)

{

    StringBuffer sb = new StringBuffer();

    

    sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");

    sb.append("<script src=\"/trans-banner.min.js\"></script>");

 

    response.renderString(sb.toString());

} 

}


We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Chris Colman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502900#comment-13502900 ] 

Chris Colman commented on WICKET-4408:
--------------------------------------

Could this work if, instead of outputting header and body into a single output stream, Wicket rendered header and body into two separate streams that are then combined into the final page output stream only after the body has been completely rendered?

That would allow contributions to the header to continue to occur during rendering of the body, rather than forcing closing off of header rendering as soon as body rendering starts.

To avoid dealing with two separate streams this idea could be optimized so that the header output stream remains as the current  output stream but body output goes to a separate stream, only when the body is completely rendered is its output stream buffer then appended to the header (current) output stream.

It seems limiting that components rendered by IComponentResolverS are treated as second class citizens (components) and are effectively disabled in many areas of functionality.
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Igor Vaynberg (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-4408.
-----------------------------------

    Resolution: Won't Fix
      Assignee: Igor Vaynberg

auto components cannot contribute to the header. they are processed at render time, after the header would have already been rendered. resolved components are meant for simple stateless components such as ones handling the wicket:message tags, nothing more.

depending on your usecase, if you need automatically resolved components you may wish to do your own resolving in oninitialize() where markup is available. walk the markup and add components based on it.
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Chris Colman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502911#comment-13502911 ] 

Chris Colman commented on WICKET-4408:
--------------------------------------

While in the early comments in WICKET-2238 explain the reasoning behind why it doesn't work the later comments explain how it could be fixed and then explains that it was in fact fixed in 1.5. Does that mean 6.x has regressed this fix?
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Chris Colman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502916#comment-13502916 ] 

Chris Colman commented on WICKET-4408:
--------------------------------------

So does that mean I should be able to change the way my component resolver works to explicitly add the component rather than just return it and allow an auto add?

Example:

Component resolver:
if ( componentTag.getName().equals( "input" ) ){
markupContainer.add( new TextField( componentTag.getId() ), markupStream );
} 

Pre 1.5 we had to call autoAdd but 1.5 does the auto add for us if we simply returned the created component. I guess if we are performing the add explicitly then the component resolver should return null?
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502907#comment-13502907 ] 

Sven Meier commented on WICKET-4408:
------------------------------------

Resolved components *are* second class citizens. Most importantly they are removed after rendering, see WICKET-2238. This is why you couldn't use an AjaxLink anyway, even if it wrote its javascript event handler into the header: it wouldn't be there any more when the request comes in.
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Chris Colman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502931#comment-13502931 ] 

Chris Colman commented on WICKET-4408:
--------------------------------------

Use case scenario:

We use Wicket to produce many differently branded sites with a wide variety of layouts for clients - the Wicket 'variation' feature is totally awesome for this.

The ability to use the ComponentResolver really let's us take separation of concerns to the next level: It makes it possible for the web graphics guys to configure the markup for different variations in very flexible ways. For example, with the SystemPanel (shows 'log in' link if not logged in or email, profile settings and log off if logged on) the graphics guys can place that at the top of the page or they can embed it within the main menu - or they could even place it in a side bar if they like - it's location is flexible.

With a component resolver solution the Java code doesn't have to change based on where they want to place it so the code is clean, simple and efficient.

Without a component resolver solution the Java code needs to know where they will place it in a particular layout or just add the component in all possible places that the graphics guys *may* want to place it - which produces redundant components and makes for ugly, unmaintainable code - what if they decide to place it in a different component that it has never been placed in before? SystemPanel is only one of many panels that we allow to be dynamically added via this flexible markup feature - we would have to duplicate that ugliness for each of these panels.

Analyzing the markup in #onInitialize:

Would that effectively be double processing the markup?
To allow the flexibility that the component resolver solution gives, i.e. the web designer can place the panel *anywhere*, wouldn't we have to make *every* component analyze it's markup in onInitialize? Wouldn't that mean every component in every page render is analyzed twice? Once by our app and then later by the Wicket framework?
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Sven Meier (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207578#comment-13207578 ] 

Sven Meier commented on WICKET-4408:
------------------------------------

auto-components are added to the component tree not until rendering of markup, this is too late for header contributions.
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502921#comment-13502921 ] 

Sven Meier commented on WICKET-4408:
------------------------------------

No, your component resolver cannot add (non-auto) components during render, it is forbidden to alter the component hierarchy that late.

What you can do is let your component analyse the markup in #onInitialize() and add the required components.
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WICKET-4408) Components resolved by an IComponentResolver fail to contribute to header via renderHead

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502915#comment-13502915 ] 

Sven Meier commented on WICKET-4408:
------------------------------------

Auto components are removed when the component tree is detached.
The ticket is marked fixed because since 1.5 the component can walk the markup upfront before rendering and add required components. Note that these are not auto components.
                
> Components resolved by an IComponentResolver fail to contribute to header via renderHead
> ----------------------------------------------------------------------------------------
>
>                 Key: WICKET-4408
>                 URL: https://issues.apache.org/jira/browse/WICKET-4408
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Happens on all FireFox  Chrome, IE
> Windows XP
>            Reporter: Chris Colman
>            Assignee: Igor Vaynberg
>              Labels: wicket
>
> If a component is resolved via an IComponentResolver implementation then its overridden renderHead method never gets called.
> If the same component is added explicitly to its parent then its renderHead method is called.
> This is critical for us because we have markup variations that may or may not include certain panels. We thus leave the construction/adding of these panels to our IComponentResolver implementation because we can't explicitly add them because not all markup will require all panels.
> Class MyPanel extends Panel
> {
> /**
>  * Write out necessary header markup.
>  */
> @Override
> public void renderHead(IHeaderResponse response)
> {
>     StringBuffer sb = new StringBuffer();
>     
>     sb.append("<script src=\"/jquery.easing.1.3.min.js\"></script>");
>     sb.append("<script src=\"/trans-banner.min.js\"></script>");
>  
>     response.renderString(sb.toString());
> } 
> }
> We aren't using any markup inheritance at the panel level.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira