I never tried, but try if this works?

height='#{(reportHandler.score * 18)+""}' border='0' />



-----Original Message-----
From: Richard Wallace [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 26, 2005 11:29 AM
To: MyFaces Discussion
Subject: Re: Calculating image height


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

Reply via email to