• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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> ?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Usera User
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic