• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Issue with ERXResponseRewriter.addStylesheetResourceInHead()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with ERXResponseRewriter.addStylesheetResourceInHead()


  • Subject: Re: Issue with ERXResponseRewriter.addStylesheetResourceInHead()
  • From: Alexis Tual <email@hidden>
  • Date: Mon, 19 Sep 2011 11:08:44 +0200

Hi,

I've juste faced the exact same issue, your fix works for me if I remove the condition ERXAjaxApplication.isAjaxReplacement(context.request()).
I had to also modify the _javascript_ function AOD.loadCss to create a <link href="" in the head section :

loadCSS: function(css) {
        var link=document.createElement("link");
        link.setAttribute("rel", "stylesheet");
        link.setAttribute("type", "text/css");
        link.setAttribute("href", css);
        if (typeof link!="undefined") {
            document.getElementsByTagName("head")[0].appendChild(link);
        }
}

The previous code was loading the content of the css file inline into the head section (<style type="text/css">....</style>) which was breaking the references to images.

I'm also surprised nobody else seems to encounter this problem. I will fill a Jira.

Regards,

Alex

Le 24 août 2010 à 10:33, Bogdan Zlatanov a écrit :

Hi all,


Yesterday, I noticed a problem with ERXResponseRewriter.addStyleSheetResourceInHead(WOResponse response, WOContext context, String framework, String fileName, String media) method, while working a project. Details follow with some sample code for illustration:

Let's say I have two components, called Main and MyComponent with the following contents:

Main.html:

<div id="contentContainer">
<webobject name = "MyComponent"/>
</div>

Main.wod:

MyComponent : MyComponent {}



MyComponent.html: 

<webobject name = "MyAjaxUpdateLink"/>

MyComponent.wod:

MyAjaxUpdateLink : AjaxUpdateLink {
action = "">
replaceID = "contentContainer";
}

MyComponent.java:

public WOActionsResult updateStuff() {
         // code that updates stuff here
return null;
}

public void appendToResponse(WOResponse aResponse, WOContext aContext) {
super.appendToResponse(aResponse, aContext);
AjaxUtils.addStyleSheetResourceInHead(aContext, aResponse, "/css/my_component.css");
}


Given the above, the first time Main page is invoked, the my_component.css file is loaded inline, and everything is fine. But when the update link is clicked, the contents of the "contentContainer" div gets replaced, but the inline CSS declaration is not added again, because ERXResponseRewriter thinks the resource is already added. Looking at the ERXResponseRewriter.java I could see the code commented:

// MS: It looks like all the browsers can load CSS inline, so we don't
// even need all this.
// String fallbackStartTag;
// String fallbackEndTag;
// if (ERXAjaxApplication.isAjaxRequest(context.request())) {
// fallbackStartTag = "<script>AOD.loadCSS('";
// fallbackEndTag = "')</script>";
// }
// else {
// fallbackStartTag = null;
// fallbackEndTag = null;
// }
// ERXResponseRewriter.addResourceInHead(response, context, framework,
// fileName, cssStartTag, cssEndTag, fallbackStartTag, fallbackEndTag,
// TagMissingBehavior.SkipAndWarn);


Uncommenting it solved my problem, so I modified it a bit:

String fallbackStartTag = null;
String fallbackEndTag = null;

if (ERXAjaxApplication.isAjaxRequest(context.request()) && ERXProperties.booleanForKeyWithDefault("er.extensions.loadOnDemand", true)) {
if (ERXAjaxApplication.isAjaxReplacement(context.request()) && ERXProperties.booleanForKeyWithDefault("er.extensions.loadOnDemandDuringReplace", false)) {
boolean appendTypeAttribute = ERXProperties.booleanForKeyWithDefault("er.extensions.ERXResponseRewriter._javascript_TypeAttribute", false);
fallbackStartTag = (appendTypeAttribute ? "<script type=\"text/_javascript_\">AOD.loadCSS('" : "<script>AOD.loadCSS('");
fallbackEndTag = "')</script>";
}
}
 
ERXResponseRewriter.addResourceInHead(response, context, framework, fileName, cssStartTag, cssEndTag, fallbackStartTag, fallbackEndTag, TagMissingBehavior.Inline);

while looking at the ERXResponseRewriter.addScriptResourceInHead() method.

I have no idea if anyone else has ever hit this problem, but it seems to me that the commented code is needed after all. I'll file a bug report in Jira later today.


Cheers.


Bogdan Zlatanov,
Tuparev Technologies Bulgaria Ltd.



Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Wonder vs WO app/framework in WOLips
  • Next by Date: Re: Wonder vs WO app/framework in WOLips
  • Previous by thread: Re: WOLips complains about scala WOElement
  • Next by thread: Help on incorporating the WOCommunity Association
  • Index(es):
    • Date
    • Thread