This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

getting 2D array view in jsp from actionform properties

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common problem in web applications. Check out this thread for some possible approaches.
 
Thanks tiny ad, for helping me escaped\ the terrible comfort of this chair.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!