• 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
Issue with ERXResponseRewriter.addStylesheetResourceInHead()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue with ERXResponseRewriter.addStylesheetResourceInHead()


  • Subject: Issue with ERXResponseRewriter.addStylesheetResourceInHead()
  • From: Bogdan Zlatanov <email@hidden>
  • Date: Tue, 24 Aug 2010 11:33:19 +0300

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: ERModernDirectToWeb relationship problem
  • Next by Date: Re: WO and Hadoop
  • Previous by thread: Re: ERModernDirectToWeb relationship problem
  • Next by thread: pageWithName crashes
  • Index(es):
    • Date
    • Thread