aspose file tools*
The moose likes JSP and the fly likes problem with using iterate! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "problem with using iterate!" Watch "problem with using iterate!" New topic
Author

problem with using iterate!

Janelle Bullus
Greenhorn

Joined: Sep 21, 2003
Posts: 12
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

Joined: Feb 27, 2002
Posts: 8919

http://jakarta.apache.org/struts/userGuide/struts-logic.html#iterate


Groovy
Janelle Bullus
Greenhorn

Joined: Sep 21, 2003
Posts: 12
I had done, however i still dont know which place is failure.
this is big problem.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Does loginActionForm contain a getter for property dataArrayList that returns collection?
Janelle Bullus
Greenhorn

Joined: Sep 21, 2003
Posts: 12

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

Joined: Feb 27, 2002
Posts: 8919

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

Joined: Sep 21, 2003
Posts: 12
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

Joined: Jan 10, 2002
Posts: 61434
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: problem with using iterate!