This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Struts and the fly likes Populating text box from values in Action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Populating text box from values in Action class" Watch "Populating text box from values in Action class" New topic

Populating text box from values in Action class

Shailesh Pillai
Ranch Hand

Joined: Jan 24, 2006
Posts: 78
Hello Ranchers,
I have some values stored in session variables in my Action class.

And as i am forwarded to a JSP Page i would like those values to be displayed in the text box on the page.

<bean:write name="...." /> is an alternative. But how to display the values inside the text box.

Pls do reply.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The solution is to write a JavaBean class that extends ActionForm and associate that form to the Action mappping in your struts-config file. In your Action class, you would then populate the property of this bean with the value you want displayed in the text box. you would then use the Struts custom tag <html:text> to display the text box with the value.

If you don't understand the relationship between a Struts Action, an ActionForm, and a JSP that uses <html:xxx> tags, I'd suggest you take a moment to do one of the tutorials in this link.

Consultant, Sima Solutions
rocket mass heater kickstarter
subject: Populating text box from values in Action class