I could maybe share the code sometime (meaning contribute it), but I
just created a custom renderer for my images, that I change the source
tag to a "blank.gif" file and then put the URL in the css filter
property on component render. Makes all images work. It wouldn't help
tobago out as I did it as an extension to graphicImage. But it really
isn't hard to do. This would be a script independant fix and there is
no annoying flicker that you would have with javascript or "behavior"
fixes.
Here is the code:
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException
{
String url;
String style;
HtmlGraphicImage gimg = null;
if (component instanceof HtmlGraphicImage)
{
gimg = (HtmlGraphicImage)component;
url = gimg.getUrl();
style = gimg.getStyle();
}
else
{
url = (String)component.getAttributes().get(JSFAttr.URL_ATTR);
style = (String)component.getAttributes().get(HTML.STYLE_ATTR);
}
if (url.toLowerCase().endsWith(".png") &&
Functions.isInternetExplorer())
{
if (style == null)
style = "";
style += " filter:progid:DXImageTransform.Microsoft." +
"AlphaImageLoader(src='" + Functions.getResourceUrl(url) +
"', sizingMethod='image');";
url = "/images/blank.gif";
if (gimg != null)
{
gimg.setUrl(url);
gimg.setStyle(style);
}
else
{
component.getAttributes().put(JSFAttr.URL_ATTR, url);
component.getAttributes().put(HTML.STYLE_ATTR, style);
}
}
super.encodeBegin(context, component);
}
Here is the relevant functions code:
public static boolean isInternetExplorer()
{
String ua = getUserAgent();
return (ua != null && ua.contains("MSIE"));
}
private static String getUserAgent()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
String ua = (String)facesContext.getExternalContext()
.getRequestHeaderMap().get("User-Agent");
return ua;
}
On 5/21/06, John <[EMAIL PROTECTED]> wrote:
Could this be the forceId issue? I have another Javascript on the page
that I'm sure it is the issue.
How do you forceId with Tobago?
-----Original Message-----
From: Volker Weber [mailto:[EMAIL PROTECTED]
Sent: Sunday, May 21, 2006 12:06 PM
To: MyFaces Discussion
Subject: Re: Does anyone have the IE png fix working with
Tobago/myFaces?
If the f:verbatim not works, pleas send me one of your images, i can try
it out tomorrow.
see the footer how to build my email.
John wrote:
> Not within menuItems but they are the image of a ToolBarCommand...
>
> -----Original Message-----
> From: Volker Weber [mailto:[EMAIL PROTECTED]
> Sent: Sunday, May 21, 2006 11:40 AM
> To: MyFaces Discussion
> Subject: Re: Does anyone have the IE png fix working with
> Tobago/myFaces?
>
> Hi John,
>
> the tobago onload functions did not change any class or style
> attributes.
>
> but the menu is created via onload, so if your images are inside
> menuItems this can't work.
>
> you can try to enclose the original script code inside of f:verbatim
> tags.
>
>
> Regards,
> Volker
>
> John wrote:
>
>> Volker,
>>
>>Thanks - but it doesn't cause the pngs to work.
>>One thing I noticed, was (when viewing the rendered pages source), is
>>that the call to the pngfix in the onload is before a lot of the
>>Tobago onLoad functions. Since the pngfix works by rewriting code and
>>applying spans, is it possible that its changes are being overwritten
>>by the Tobabgo onLoad js functions?
>>
>>John
>>
>>-----Original Message-----
>>From: Volker Weber [mailto:[EMAIL PROTECTED]
>>Sent: Sunday, May 21, 2006 2:09 AM
>>To: MyFaces Discussion
>>Subject: Re: Does anyone have the IE png fix working with
>>Tobago/myFaces?
>>
>>Hi John,
>>
>>wrote my first mail to fast, youre already use t:script :-).
>>
>>as i wrote in th first mail the body of t:script is rendered inside
>>hrml script tags, and
>>
>><!--[if lt IE 7.]>
>><script defer type="text/javascript" src="js/pngfix.js"></script>
>><![endif]-->
>>
>>is no valid javascript :-(.
>>
>>try this:
>>
>>
>><t:script onload="applyIePngFix();">
>>
>>function applyIePngFix() {
>>
>> // maybe better IE recognition needed if (!window.all) {
>> return;
>> }
>>
>> var arVersion = navigator.appVersion.split("MSIE")
>> var version = parseFloat(arVersion[1])
>>
>> if (version < 7.0) {
>> return;
>> }
>>
>> if ((version >= 5.5) && (document.body.filters)) {
>> for(var i=0; i<document.images.length; i++)
>> {
>> var img = document.images[i]
>> var imgName = img.src.toUpperCase()
>> if (imgName.substring(imgName.length-3, imgName.length) ==
>
> "PNG")
>
>> {
>> var imgID = (img.id) ? "id='" + img.id + "' " : ""
>> var imgClass = (img.className)
>> ? "class='" + img.className + "' " : ""
>> var imgTitle = (img.title)
>> ? "title='" + img.title + "' " : "title='" + img.alt + "'
>
> "
>
>> var imgStyle = "display:inline-block;" + img.style.cssText
>> if (img.align == "left") imgStyle = "float:left;" + imgStyle
>> if (img.align == "right") imgStyle = "float:right;" +
>
> imgStyle
>
>> if (img.parentElement.href) imgStyle
>> = "cursor:hand;" + imgStyle
>> var strNewHTML = "<span " + imgID + imgClass + imgTitle
>> + " style=\"" + "width:" + img.width + "px; height:"
>> + img.height + "px;" + imgStyle + ";"
>> +
>
> "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
>
>> + "(src=\'" + img.src
>> + "\', sizingMethod='scale');\"></span>"
>> img.outerHTML = strNewHTML
>> i = i-1
>> }
>> }
>> }
>>}
>>
>></t:script>
>>
>>
>>I cant test, because i'm working on linux, but this should do.
>>
>>you can also put the code into a file e.g. js/pngfix2.js and use it
>>like
>>
>><t:script onload="applyIePngFix();" file="js/pngfix2.js"/>
>>
>>
>>Regards,
>> Volker
>>
>>
>>John wrote:
>>
>>
>>>http://homepage.ntlworld.com/bobosola/index.htm
>>>
>>>I included the js file using <t:script>
>>>
>>><t:script>
>>><!--[if lt IE 7.]>
>>><script defer type="text/javascript" src="js/pngfix.js"></script>
>>><![endif]--> </t:script>
>>>
>>>And I see that in the page source of the rendered page But no -
>>>transparent pngs.
>>>
>>>Thanks,
>>>John
>>>
>>>-----Original Message-----
>>>From: Philippe Hennes (JIRA) [mailto:[EMAIL PROTECTED]
>>>Sent: Thursday, May 18, 2006 6:49 AM
>>>To: John
>>>Subject: [jira] Commented: (TOBAGO-69) t:image does not support a png
>>>image with a transparent background - displays background as mid-grey
>>>
>>> [
>>>http://issues.apache.org/jira/browse/TOBAGO-69?page=comments#action_1
>>>2
>>>41
>>>2344 ]
>>>
>>>Philippe Hennes commented on TOBAGO-69:
>>>---------------------------------------
>>>
>>>There is a bug regarding png images in IE. IE ist not capable of
>>>displaying 8bit png's with alpha transparency without an proprietary
>>>filter [1].
>>>As a workaround you can use 24bit png images or gif's.
>>>
>>>Alternativly you can change the grey background by assigning a new
>>>background color:
>>>Photoshop: Just select the mask color option, and set the color
>>>picker
>>
>>
>>>to the color of the background the picture is intended to sit on.
>>>Gimp: In Gimp you can check "save background color" in the png export
>>>dialog.
>>>
>>>[1]
>>>http://msdn.microsoft.com/workshop/author/filter/reference/filters/al
>>>p
>>>ha
>>>imageloader.asp
>>>
>>>
>>>
>>>
>>>>t:image does not support a png image with a transparent background -
>>>>displays background as mid-grey
>>>>--------------------------------------------------------------------
>>>>-
>>>>-
>>>>------------------------------
>>>>
>>>> Key: TOBAGO-69
>>>> URL: http://issues.apache.org/jira/browse/TOBAGO-69
>>>> Project: MyFaces Tobago
>>>> Type: Bug
>>>
>>>
>>>> Versions: 1.0.7
>>>>Environment: Tomcat 5.15 - IE
>>>> Reporter: John Allan
>>>> Priority: Minor
>>>
>>>
>>>>Pretty much summed up in the summary.
>>>
>>>
>>>--
>>>This message is automatically generated by JIRA.
>>>-
>>>If you think it was sent incorrectly contact one of the
>>
>>administrators:
>>
>>
>>> http://issues.apache.org/jira/secure/Administrators.jspa
>>>-
>>>For more information on JIRA, see:
>>> http://www.atlassian.com/software/jira
>>>
>>>
>>>
>>
>>
>>--
>>Don't answer to From: address!
>>Mail to this account are droped if not recieved via mailinglist.
>>To contact me direct create the mail address by concatenating my
>>forename to my senders domain.
>>
>
>
> --
> Don't answer to From: address!
> Mail to this account are droped if not recieved via mailinglist.
> To contact me direct create the mail address by concatenating my
> forename to my senders domain.
>
--
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by concatenating my
forename to my senders domain.