The file is in api/trunk, and here's the svn diff.
Index: src/java/javax/faces/component/html/HtmlGraphicImage.java
===================================================================
--- src/java/javax/faces/component/html/HtmlGraphicImage.java
(revision 225332)
+++ src/java/javax/faces/component/html/HtmlGraphicImage.java (working
copy)
@@ -92,7 +92,7 @@
{
if (_height != null) return _height;
ValueBinding vb = getValueBinding("height");
- return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ return vb != null ? vb.getValue(getFacesContext()).toString() :
null;
}
public void setIsmap(boolean ismap)
Thanks.
Bruno Aranda wrote:
You are right with that Richard, if is better to do .toString() than
the cast to String. Can you submit a patch or tell me Class/line so I
can fix this?
Regards,
Bruno
2005/7/26, Richard Wallace <[EMAIL PROTECTED]>:
Here's a related question. The line that is causing me my problems is:
return vb != null ? (String)vb.getValue(getFacesContext()) : null;
Isn't it better to do vb.getValue(getFacesContext()).toString() for
performance reasons anyways? I mean, if it is a String object it will
just do a "return this;" which should be cheaper than a cast from an
Object to a String. It also causes the value to be coerced into a
String. Unless this is strictly forbidden by the standard, it can't see
a reason not to implement it this way.
Thanks,
Rich
Richard Wallace wrote:
Klug, Boris wrote:
Hi!
the problem may be that a your calculation returns an int but the el
statement
has to return an String. So do the calculation in your managed bean
and return
the result as a String.
Thanks for the reply. I had expected that the value would be coerced
into the proper type tho, as in other EL statements. Is this a bug or
the right thing? If this implementation is correct, is there anyway
to convert the calculation to a string? I really don't like the idea
of having to do the calculation in the backing bean cause then my page
designers can't easily vary the size of the image. I could put it in
the faces-config.xml, but that would still require them to restart
their tomcat instance just to make a change to the page layout/display.
Right now I've got a workaround. It's rather messy but it works. I
basically use the plain old <img> tag and do a couple of
<h:outputText> in the attributes to make sure the image path contains
the contextPath and then one to perform and output the calculation in
the height attribute. Like I said, it's rather messy, but it works
and allows the page designers to make better control over the page
layout and display.
Rich
--
Boris Klug
Zitat von Richard Wallace <[EMAIL PROTECTED]>:
Hello everyone,
I'm working on a report that has a bar chart. I thought the easiest
way
to display it would be to use something like:
<h:graphicImage url="/images/visual_bar_1.gif" width="46"
height="#{reportHandler.score * 18}" border="0" />
But that horks with:
java.lang.ClassCastException
at
javax.faces.component.html.HtmlGraphicImage.getHeight(HtmlGraphicImage.java:95)
at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
javax.faces.component._ComponentAttributesMap.getComponentProperty(_C
Can I not set the height to some calculated value?
Thanks,
Rich