Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with using iterate!

 
Janelle Bullus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is jsp using struts:
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page contentType="text/html; charset=Shift_JIS" %>
<html:html>
<head>
<title>
index
</title>
</head>
<body>
<h1>JBuilder Generated Struts JSP for ActionForm com.detail.actionform.IndexActionForm</h1>
<html:form action="/indexAction.do" method="POST">
<TABLE width="300">
<logic:iterate id="element" name="loginActionForm" property="dataArrayList" scope="session" >
<TR>
<TD><bean:write name="element" property="index"/> </TD>
<TD width="248"><bean:write name="element" property="subject"/></TD>
<TD width="52"><bean:write name="element" property="date"/></TD>
</TR>
<TR>
<TD width="300"><bean:write name="element" property="detail"/></TD>
</TR>
</logic:iterate>
</TABLE>
<html:submit property="submit" value="Submit"/><br>
<html:reset value ="Reset"/>
</html:form>
</body>
</html:html>
the exception is that :
javax.servlet.ServletException: No getter method for property dataArrayList of bean loginActionForm
Can you show me how to do?
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
 
Janelle Bullus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had done, however i still dont know which place is failure.
this is big problem.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does loginActionForm contain a getter for property dataArrayList that returns collection?
 
Janelle Bullus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

bean of IndexAction:
package com.detail.action;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.detail.actionform.IndexActionForm;
import javax.sql.DataSource;
import java.sql.*;
import org.apache.struts.*;
import java.util.ArrayList;
public class IndexAction extends Action {
public ActionForward perform(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
/**@todo: complete the business logic here, this is just a skeleton.*/
IndexActionForm indexActionForm = (IndexActionForm) actionForm;
ActionErrors errors = new ActionErrors();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
ArrayList dataArraylist = new ArrayList();
int i=0;
/* Connect to database */
try {
DataSource dataSource = (DataSource)
servlet.getServletContext().getAttribute(
Action.DATA_SOURCE_KEY);
conn = dataSource.getConnection();
}
catch (Exception e) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.cennection.failed"));
saveErrors(httpServletRequest, errors);
}
/* Get record */
try {
stmt = conn.createStatement();
sql = " SELECT BULLETIN.BULCODE,BULLETIN.BULSUBJECT, " +
" BULLETIN.BULOFFICIAL,BULLETIN.BULDATE " +
" FROM MASCOTBBS.BULLETIN " +
" ORDER BY BULLETIN.BULDATE DESC ";
rs = stmt.executeQuery(sql);
if (rs.next()) {
i++;
IndexActionForm index = new IndexActionForm();
index.setIndex(rs.getInt("BULCODE"));
dataArraylist.add(index);
index.setDataArrayList(dataArraylist);
}
}
catch (Exception e) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.getrecordset.failed"));
saveErrors(httpServletRequest, errors);
}
finally {
/* Close connection */
try {
rs.close();
stmt.close();
conn.close();
}
catch (Exception e) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.closeConnect.failed"));
saveErrors(httpServletRequest, errors);
}
}
return actionMapping.findForward("index");
}
}
bean of IndexActionForm:
package com.detail.actionform;
import org.apache.struts.action.*;
import java.util.*;
import javax.servlet.http.*;
import java.io.*;
public class IndexActionForm extends ActionForm implements Serializable {
private int index;
private java.util.ArrayList dataArrayList;
public java.util.ArrayList getDataArrayList() {
return dataArrayList;
}
public void setDataArrayList(java.util.ArrayList dataArrayList) {
this.dataArrayList = dataArrayList;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
}
can you show me,where i have mistake. waiting for your reply.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to store IndexActionForm is some scope say request.
request.setAttribute("loginActionForm",index );
[ September 30, 2003: Message edited by: Pradeep Bhat ]
 
Janelle Bullus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use IndexActionForm in session.Maybe this is wrong.
thanks for your reply.
sorry, i have to leave now.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
janelle, you have already been asked to change your display name to comply with Ranch standards. Once again, please take a look at the JavaRanch Naming Policy and change your display name to match it.
thanks,
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic