You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ro...@bowtech.com on 2003/08/11 15:59:21 UTC
Trouble populating form
Not able to get attributes from ActionForm into html form
//in action form
MemberDetailsEditForm returnForm = new MemberDetailsEditForm();
MemberVO vo = (MemberVO) results.iterator().next();
returnForm.setFirstName(vo.getFirstName());
returnForm.setLastName(vo.getLastName());
request.setAttribute("results", returnForm);
<%-- in jsp --%>
<%= request.getAttribute("results") %>
<%-- shows results is there as a MemberDetailsEditForm - subclass of
ActionForm ---%>
<bean:define id="member" property="results"
type="com.bowtech.web.forms.MemberDetailsEditForm" />
<html:form name="member" method="post" action="member_edit.do"
type="com.bowtech.web.forms.MemberDetailsEditForm" >
<bean:write id="member" property="firstName"/>
<%-- **********************
does not write firstName
********************* --%>
How do I get it to write firstName
Also how would I do this in a html:text tag ??
Something like <html:text property="firstName" value="<%=
member.getFirstName %>">
</html:form>
Thanks
Ross
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Trouble populating form
Posted by Paul Thomas <pa...@tmsl.demon.co.uk>.
On 11/08/2003 14:59 ross@bowtech.com wrote:
> Not able to get attributes from ActionForm into html form
>
>
> //in action form
>
> MemberDetailsEditForm returnForm = new MemberDetailsEditForm();
> MemberVO vo = (MemberVO) results.iterator().next();
>
> returnForm.setFirstName(vo.getFirstName());
> returnForm.setLastName(vo.getLastName());
>
> request.setAttribute("results", returnForm);
~~~~~~~~~ is this the same as the name
attribute in
your struts config for the post
action???
because if it isn't (or if the name is right but you didn't specify
request scope in struts config) then Struts will ignore it and create an
empty form bean then use that.
HTH
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org