You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Jason H. Kim" <ja...@qett.com> on 2001/02/21 20:45:31 UTC

RE: submitting form containing an object with indexed property - BUG IN STRUTS???

I don't think it's really about indexed property. I cahnged scope in
struts-config for this for to session, and it works fine. - but this is not
desirable cause i am using one form bean for multiple forms and maintaining
session bean will be a nightmare..

I understand struts creating a new formbean cause the one it got in the form
was in request scope, however, it should still be populated properly. - but
it's not..

Is it a bug in struts??

Thank you.

Jason H. Kim
Quatrix Emerging Technology Team
Phone: 314-993-5858 EXT: 137

-----Original Message-----
From: Jason H. Kim [mailto:jasonk@qett.com]
Sent: Wednesday, February 21, 2001 11:54 AM
To: Struts-User Mail Group
Subject: submitting form containing an object with indexed property


I am trying to submit an ActionForm instance upon submission of a form. But
I think it's sending each properties as request parameter and not the whole
object. The object that subsequent Action receives is a newly constructed
(the one created by ActionForm form = new ActionForm()) one. Following is
the jasper.log:

JspEngine --> /TaskBasedComment.jsp</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 	     ServletPath:
/TaskBasedComment.jsp</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 	        PathInfo:
null</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 	        RealPath:
/www/time-dev/webapps/time/TaskBasedComment.jsp</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 	      RequestURI:
/TaskBasedComment.jsp</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 	     QueryString:
null</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 	  Request Params: </JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 		 fridayHour[1] =
0.0</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 		 saturdayHour[2] =
0.0</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 		 wednesdayHour[0] =
0.0</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 		 sundayHour[2] =
0.0</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 		 fridayHour[4] =
0.0</JASPER_LOG>
<JASPER_LOG> Wed Feb 21 11:40:14 CST 2001 		 thursdayHour[0] =
0.0</JASPER_LOG>
...



The form "displayed" the object just fine, using index properties and such,
but failed to "submit" the object. I looked at my configuration file and my
jsp source and i can't find anything..


Following is my struts-config.xml:
  <form-beans>
    <form-bean
      name="com.qett.time.bean.timeformbean"
      type="com.qett.time.bean.TimeFormBean" />
  </form-beans>
  <action-mappings>
	<action    path="/hourinput"
               type="com.qett.time.servlet.HourInputAction"
               name="com.qett.time.bean.timeformbean"
              scope="request"
			  input="TaskBasedTime.jsp"
           validate="true">
      <forward name="success"                path="/TaskBasedComment.jsp"/>
    </action>
  </action-mappings>

and following is my jsp page.. it gets the bean
com.qett.time.bean.timeformbean as a request parameter from previously
executed Action - The form is pre-populated.



<html:form action="/hourinput.do">

<table align="center" class="BoxWithHeader" width="700">
	<tr>
		<td colspan="9" align="center">
<table width="100%" cellpadding="0" cellspacing="0">

	<%
		int i;
		for (i = 0; i<time.getArraySize(); i++) {
			String styleClass = "ReportRowOdd";
			if ((i % 2)==0) {
				styleClass = "ReportRowEven";
			}
			String prop0 = "projectToTaskMap[" + i + "]";
			String prop1 = "indexName["+i+"]";
			String prop2 = "sundayHour["+i+"]";
			String prop3 = "mondayHour["+i+"]";
			String prop4 = "tuesdayHour["+i+"]";
			String prop5 = "wednesdayHour["+i+"]";
			String prop6 = "thursdayHour["+i+"]";
			String prop7 = "fridayHour["+i+"]";
			String prop8 = "saturdayHour["+i+"]";
			String prop9 = "SPTotalTime["+i+"]";
	%>
<!-- In the following write tags, name field should match that of the Bean
specified in struts-config.xml -->
	<tr>
		<td width="140" align="center" class=<%= styleClass %>><bean:write
name="com.qett.time.bean.timeformbean" property="<%= prop1 %>" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop2 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop3 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop4 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop5 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop6 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop7 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><html:text
name="com.qett.time.bean.timeformbean" property="<%= prop8 %>" size="3"
maxlength="4" /></td>
		<td width="70" align="center" class=<%= styleClass %>><bean:write
name="com.qett.time.bean.timeformbean" property="<%= prop9 %>" /></td>

	</tr>
	<% } %>
</table>
		</td>
	</tr>
</table><p>
<% time.setIsProject(false); %>
<div align="center"><html:submit value="Next"></div>
</html:form>



Again, the properties are displayed just fine.. but sent every textbox as
seperate request parameters rather than properies associated with one
formBean.

Thank you very much in advance. If you have worked on indexed formbean and
struts form, please help.


Thank you.

Jason H. Kim