aspose file tools
The moose likes Struts and the fly likes How to set value in html:text using bean:write Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "How to set value in html:text using bean:write" Watch "How to set value in html:text using bean:write" New topic
Author

How to set value in html:text using bean:write

Usera User
Greenhorn

Joined: Jul 13, 2005
Posts: 21
I try to set the value in <html:text> using the <bean:write>, but it doesn't work.

<html:text property="code" size="60" maxlength="60" value="<bean:write
name='countryForm' property='countryview.code'/>"/>

And then I try to use <bean efine> to set the variable and using the jsp code to set the value in <html:text>.
<bean efine id="codev" name="countryForm"
property="countryview.code" />
<html:text property="code" size="20" maxlength="15"
value="<%=codev.toString()%>"/>

It works but when the code is null, it throws an exception.

Have any good method to set the value in <html:text> ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The whole point of using an <html:text> tag as opposed to <input type="text"> is so that it will be populated with the value in the form bean. If you just code: <html:text property="countryView.code" maxlength="15" /> Struts will populate the value when the page is renedered. It will also transfer the value from the html parameters to the form bean when the form is submitted.


Merrill
Consultant, Sima Solutions
Usera User
Greenhorn

Joined: Jul 13, 2005
Posts: 21
Thanks Merrill Higginson reply.

When using property="countryView.code", will struts render to the text field with name countryView.code ? When I want to retrieve the updated value on the code field in the backend action class, Is it I need to use (DynaActionForm)form).get("countryView.code") rather than (DynaActionForm)form).get("code") ? And do I need to create another validation on field countryView.code ?

Virtually, I want to use <html:text property="code" ....> in the update page same as the insert page so that I retrieve and validate the same "code" field.

Can I use the JSTL to set the value? What tag I can use and how to make my page can use the JSTL tag ? Because the countryForm is the form bean defined in strut-config file, how to access the countryForm attribute from JSTL ? Thanks
[ July 15, 2005: Message edited by: Calvin Wong ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to set value in html:text using bean:write
 
Similar Threads
Struts <html:text ... issue.
how to populate a bean in a form?
help:bean:write value from bean
Disable a text field after it's first use.. JSP + Struts
How to set maxlength property dynamically in Struts html:text tag?