File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
Don't get me started about those stupid light bulbs.
 
subject: getting 2D array view in jsp from actionform properties
 
Similar Threads
ActionForm contains ArrayList
Finding number of a rows in a resultset...
How to convert Char array to two dimensional string
remove duplicates from an array
Element Array: Text-boxes 2D Array - How to...