File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Question on html struts tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Question on html struts tag" Watch "Question on html struts tag" New topic
Author

Question on html struts tag

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

Guys,

Let's say I want to retrieve a value from the database and show that in my jsp using the <html:text> tag. Now what value should I give for the value attribute as I will be populating my bean and I want the value from the bean to be displayed in the textbox.

<html:text property = "name" value="??" />

If I only specify the property without a value, then I know that the value will be taken from the associated bean, but I would like to know what if I give a default value and if there is a value in the database, populate that value and if else use the default value.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Jothi Shankar Kumar Sankararaj:
I would like to know what if I give a default value and if there is a value in the database, populate that value and if else use the default value

Just override ActionForm's reset(...) method and set default values for the properties there. The default will remain until some other process such as an Action calls the setter to set another value.

I've found it's best to leave out the value attribute entirely and just manipulate the ActionForm property if you want to change the value.
[ April 10, 2008: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

That's fine but what would it mean when I specify the value = "john" and I don't do anything in my reset () method? the value will always be john despite the actual value that comes from my database. Clarification?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Just don't use the value attribute at all. Manipulate the ActionForm property instead.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

I was thinking in the same lines. Thanks for the reply!
[ April 11, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on html struts tag