This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes getting 2D array view in jsp from actionform properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "getting 2D array view in jsp from actionform properties" Watch "getting 2D array view in jsp from actionform properties" New topic
Author

getting 2D array view in jsp from actionform properties

jakeer ahmed
Greenhorn

Joined: Jan 17, 2006
Posts: 15
Dear all,
i have 2 action form properties of string type(two selectboxes in my jsp), which represent indexes of two dimentional array . again this array is also 2D string array acion form property. so when ever user changes the values in select boxes , i want an array of text fields (my action form 2D array) appear in jsp dynamically.
i m some wat new to struts,can anybody help me.
thanks in advance.
jakeer ahmed
Greenhorn

Joined: Jan 17, 2006
Posts: 15
I am using the fallowing code

jsp code:
----------------------

<jsp:useBean id="mybean" class="org.bigtec.babe.form.PumpCalibForm" scope="session" />


<td >No.of Flow Points</td>
<html:select style="width:80px;" name="PumpCalibForm" property="flowpoints" onchange="javascript:funcPass('array')">
<option value="0">Select</option>
<logicresent name="PumpCalibForm" property="flowRepeats">
<htmlptions name="PumpCalibForm" property="flowRepeats" />
</logicresent>
</html:select>


<tr><td >No.of Time Points</td>

<html:select style="width:80px;" name="PumpCalibForm" property="timepoints" onchange="javascript:funcPass('array')">
<option value="0">Select</option>
<logicresent name="PumpCalibForm" property="timeRepeats">
<htmlptions name="PumpCalibForm" property="timeRepeats" />
</logicresent>
</html:select>

</tr>


<logicresent name="PumpCalibForm" property="flowratearray" >
<%
int flow=Integer.parseInt(mybean.getFlowpoints());
int timepoints=Integer.parseInt(mybean.getTimepoints());
for(int i=0;i<flow;i++)
for(int j=0;j<timepoints;j++){
%>

<html-el:text name="PumpCalibForm" property="flowratearray[<%=i%>][<%=j%>] />



<%} %>
</logicresent>



My Action class code is:
------------------------------------

else if("array".equals(action)){

int i=Integer.parseInt(pcform.getFlowpoints());
int j=Integer.parseInt(pcform.getTimepoints());

pcform.setFlowratearray(new String[i][j]);


}

By using this code , my JSP view is going wrong.
what is the problem here.
If any solution,i will be greatful.
thanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This is a common problem in web applications. Check out this thread for some possible approaches.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting 2D array view in jsp from actionform properties