• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

html:multibox

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
iam new to struts

i cant retrieve values from database using html:multibox

error is :

org.apache.jasper.JasperException: Exception in JSP: /jsp/Check.jsp:19

16: </head>
17: <body>
18: <html:form action="Check" method="post">
19: <logic:iterate id="item" property="check" name="checkForm">
20: <html:multibox property="check" name="checkForm">
21: <bean:write name="item"/>
22: </html:multibox>

javax.servlet.ServletException: No getter method for property: "check" of bean: "checkForm"

this is my jsp page:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>

<%@ page import="jobportal.beans.Check"%>
<%@ page import="jobportal.struts.actionform.CheckForm"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Check</title>
</head>
<body>
<html:form action="Check" method="post">
<logic:iterate id="item" property="check" name="checkForm">
<html:multibox property="check" name="checkForm">
<bean:write name="item"/>
</html:multibox>
<bean:write name="item"/>
</logic:iterate>

<
</html:form>

my form bean:

package jobportal.struts.actionform;
import jobportal.beans.*;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class CheckForm extends ActionForm {
private String employeeStatus;

public String getEmployeeStatus() {
return employeeStatus;
}

public void setEmployeeStatus(String employeeStatus) {
this.employeeStatus = employeeStatus;
}

}
my dao is :
public ArrayList getCheck(HttpServletRequest request,String path,String uName) throws Exception
{
SQLExecuter sqlExe = new SQLExecuter(this.path,JobPortalConstants.DATA_SOURCE_KEY);
ArrayList arraylist=null;
try
{

java.sql.ResultSet rs = sqlExe.executeSql2("GetCheck", new String[0]);
arraylist=new ArrayList();
while(rs.next())
{
System.out.println("gdsd");
String employeeStatus=rs.getString(1);
Check check =new Check();
check.setEmployeeStatus(employeeStatus);
arraylist.add(check);


}
sqlExe.closeConnection();
} catch (Exception e) {
System.out.println("CheckActionsexception"+e);
sqlExe.closeConnection();
throw e;
}

return arraylist ;
}
}

my action class is:
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException {
ActionMessages msgs = new ActionMessages();
//String target = "failure2";
ActionErrors errors = new ActionErrors();
try{

String path = this.getServlet().getServletContext()
.getRealPath("/");

String uName="kizar";
System.out.println("name"+uName);
CheckForm checkForm=(CheckForm)form;
CheckActions checkactions=new CheckActions(checkForm,uName);
ArrayList list=checkactions.getCheck(request, path, uName);
request.setAttribute("check", list);


} catch (Exception e) {
System.out.println("actionPage"+e);
java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
e.printStackTrace(pw);
logger.fatal(sw.toString());
} finally {
}
return mapping.findForward("check");
}

can any one solve my problem
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following line in your JSP:

Is telling Struts to look for a property named check in the checkForm bean. However, your ActionForm bean has no check property, and that's why you're getting the error. Rather than placing the list in the ActionForm bean, you set it as an attribute in the request. In that case your logic:iterate statement should look like this:

You still need to add a check property of type String[] to your ActionForm with a corresponding getter and setter to receive the values submitted to the form when boxes are checked.
[ May 30, 2007: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, can anyone let me now the difference between html:checkbox and html:multibox??
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jothi Shankar Kumar Sankararaj:
By the way, can anyone let me now the difference between html:checkbox and html:multibox??


Since this question has no real relevance to the original thread, it is preferable to start a new thread rather than "hijacking" this one.

However, the answer is pretty simple: Use html:checkbox when the checkbox represents a boolean value and is a single entity. Example: Is patient inusured? (check for yes).

Use html:multibox when the user can select one or more values from a set of related values. When the form is submitted, each check box represents a separate value but all have the same name and hence will be stored in the same ActionForm property which will be of type String[]. Example: from the list, check the symptoms the patient has: cough, sneeze, bad breath, stomach ache, fever, etc.
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic