*
The moose likes Struts and the fly likes change font size in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "change font size in struts" Watch "change font size in struts" New topic
Author

change font size in struts

YanJun Tong
Greenhorn

Joined: Jun 11, 2003
Posts: 27
Hi, Could anybody tell me how to change the font size of the <html:text/>tag?
I tried this <font size=18><html:text property="name"/></font>
But it does not seem to work.
Please help me!!!
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

I suggest using a CSS to define display characteristics like font and size. Then use the style and styleClass attributes of the Struts html tags.


Junilu - [How to Ask Questions] [How to Answer Questions]
YanJun Tong
Greenhorn

Joined: Jun 11, 2003
Posts: 27
Hi thanks for your reply.This approach does work in <html:text/>tag. However I found it doesnot work in <html:select/>tag.My code is as follows:
<html:select property="handed" styleClass="12pt"><html ption value="Left" styleClass="12pt">Left</html ption><html ption value="Right" styleClass="12pt">Right</html ption><html ption value="Ambidextrous" styleClass="12pt">Ambidextrous</html ption></html:select>
The font size in option box does not change.
Thanks
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

Your attribute values are probably what's wrong. Nothing to do with Struts. A quick search with Google turned upthis article which shows the proper way to specify the style.
[ August 13, 2004: Message edited by: Junilu Lacar ]
YanJun Tong
Greenhorn

Joined: Jun 11, 2003
Posts: 27
Hi I do not think your approach works. anyway it is struts not normal HTML.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

Originally posted by YanJun Tong:
Hi I do not think your approach works. anyway it is struts not normal HTML.


Ok, you don't think it works but did you actually read the article I cited and try specifying the styleClass attribute as

styleClass="font-size: 12pt"

It doesn't matter if you use Struts or normal HTML: this has nothing to do with how the response (which is HTML either way) is rendered in your browser. The issue is the way you are specifying the value for the style attribute. The way you are doing it is simply incorrect.

styleClass="12pt"

BTW, I just tried it and it does work if you do it the way I show above. :roll:
YanJun Tong
Greenhorn

Joined: Jun 11, 2003
Posts: 27
Thanks for your reply.
I tried it again as follows:
<html:select property="gender" styleClass="font-size: 12pt"><html ption value="Male" styleClass="font-size: 12pt">Male</html ption><html ption value="Female">Female</html ption></html:select>
However it still does not seem to work. I also tried it in the <html:text/> tag, unfortunately it does not work either.

By the way in my approach styleClass="pt12", pt12 is the class name in my css file.

Thanks
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

If you use "font-size: 12pt" you need the style attribute, not styleClass.


A good workman is known by his tools.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

OK, my bad. Marc is right, you should use the style attribute instead of styleClass in your Struts tag. The styleClass attribute renders a "class" attribute in the response, not "style" as I thought.

You only need to specify the style or styleClass in the html:select tag. It would also be easier if you post the style class definition that you are using so we can try it out because this seems to work fine for me in IE (although I think that "12pt" is a bad name: what if you want to change it again in the future? Then the 12pt style class would be actually rendering 6pt, for example):



Yes, I know, it is HTML but your JSP will get rendered pretty much the same way.
[ August 17, 2004: Message edited by: Junilu Lacar ]
YanJun Tong
Greenhorn

Joined: Jun 11, 2003
Posts: 27
Thank Junilu and Marc. Marc's approach does work!

Thank you very much
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Junilu deserves 99% of the credit.

I'm glad it works.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

Tong, glad you got it working

Marc, You're too modest...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: change font size in struts
 
Similar Threads
struts tag problem ?
Problem with html:text
Data Display problem in JSP.
How to add search in a jsp
using Multiple submit buttons.