You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (Commented) (JIRA)" <de...@myfaces.apache.org> on 2011/10/11 22:49:12 UTC

[jira] [Commented] (MYFACES-3106) Resources not loaded when using a dynamic ui:inlclude and rendered via ajax

    [ https://issues.apache.org/jira/browse/MYFACES-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13125377#comment-13125377 ] 

Leonardo Uribe commented on MYFACES-3106:
-----------------------------------------

I tried the demo and at first time I thought it was a bug. Use <ui:include src="#{guiMB.viewID}> causes new resources to be loaded on the page. Obviously in this case we have resources equivalent to:

<h:outputStylesheet target="head" .... >

When the action is executed, only the content is rendered. But even using the standard f:ajax render="@all", the style links are not loaded, but the scripts are executed. Really it is a problem in HTML and browser support itself. Once the page is loaded, there is no way to update the <head> section using javascript. I tried to fix this from server side, but it is useless, because there is no way to fix the client side part.

In AjaxResponse.js you can found the following comments:

                        case this.P_VIEWHEAD:
                            //we cannot replace the head, almost no browser allows this, some of them throw errors
                            //others simply ignore it or replace it and destroy the dom that way!


            /**
             * replaces a current head theoretically,
             * pratically only the scripts are evaled anew since nothing else
             * can be changed.
             *
             * @param request the current request
             * @param context the ajax context
             * @param newData the data to be processed
             *
             * @return an xml representation of the page for further processing if possible
             */
            _replaceHead: function(request, context, newData) {

The only workaround in ensure all necessary css and js files are loaded on <head> section, and again since ui:include src="#{...}" works on build view time, the algorithm just don't know the views returned by such expression. So, at the end the only alternative is let that to the developer. The same problem will happen with all tags that affects dynamically the view like c:if or c:when.

Other alternatives are:

- Use a component that renders just one component from a child set like myfaces commons mc:renderOne
- Force a GET or a full POST, instead ajax.

Since unfortunately this is a dead end, I'll close this one as invalid, because we can't advance more at this point.



                
> Resources not loaded when using a dynamic ui:inlclude and rendered via ajax
> ---------------------------------------------------------------------------
>
>                 Key: MYFACES-3106
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3106
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.0.4
>         Environment: Windows 7, JBoss AS 6, Richfaces 4.0.0 Final, JSF2
>            Reporter: Luciano Deriu
>         Attachments: Test.war
>
>
> I'm migrating my project from JSF 1.2 to JSF2 and I was using a <ui:include src="#{guiMB.viewID}" /> tag wrapped in a <a4j:outputPanel> tag (from RichFaces) and rendering the a4j:outputPanel via ajax. However in JSF2 this doesn't load the resources for the page i'm including. 
> So anything i include dynamically like this doesn't have any of the styling or javascript that should be loaded with it. 
> I have created a test project which demonstrates the issue so i'll attach for you to replicate the issue.

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