aspose file tools*
The moose likes Struts and the fly likes Nested Beans Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Nested Beans Problem" Watch "Nested Beans Problem" New topic
Author

Nested Beans Problem

usman zia
Greenhorn

Joined: Dec 09, 2009
Posts: 1
Hi Experts!
I am new to struts framework and was working on a sample application. I have following two classess, Appointment,java and CreateAppointmentForm.java as under :

Appointment.java


public class Appointment {

private String id;
private String apptName;
private String apptDescription;

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}

public String getApptName() {
return apptName;
}
public void setApptName(String apptName) {
this.apptName = apptName;
}

public String getApptDescription() {
return apptDescription;
}
public void setApptDescription(String apptDescription) {
this.apptDescription = apptDescription;
}

}


CreateAppointmentForm.java

public class CreateAppointmentForm extends ValidatorForm
{
private Appointment appointment=null;
private String organization=null;
private String execapptorder=null;


public Appointment getAppointment() {
return appointment;
}

public void setAppointment(Appointment appointment) {
this.appointment = appointment;
}


public String getOrganization() {
return organization;

}

public void setOrganisation(String organisation) {
this.organization = organisation;
System.out.println(organization);
}

public String getExecapptorder() {
return execapptorder;
}

public void setExecapptorder(String execapptorder) {
this.execapptorder = execapptorder;
}
}


i have following definition in struts-config

<form-bean name="CreateAppointmentForm" type="net.custom.struts.ui.form.CreateAppointmentForm">

and following mapping


<action path="/CreateAppointment" type="net.custom.struts.ui.action.CreateAppointmentAction"
name="CreateAppointmentForm" scope="request" validate="false"
input="/pages/appointment/CreateAppointment.jsp">
<forward name="success" path="/welcome.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>


following is the JSP file in which i am trying to access the Appointment object :

<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested"%>

<html:html locale="true">

<body >

<html:form action="/CreateAppointment" method="post" >

<html:errors/>
<div>
<table border="1" width="100%">
<tr>
<td class="PageTitle">
Create Appointment
</td>
</tr>

<tr>
<td height="6px"/>
</tr>
<tr>
<td align="center" colspan="2">
<font size="4">Please Enter the Following Details</font>
</tr>
<tr>
<td align="right">
Name
</td>
<td align="left">
<nested:nest property="CreateAppointmentForm">
<nested:iterate property="appointment">
<nested:write property="apptName" />
</nested:iterate>
</nested:nest>
</td>
</tr>
<tr>
<td align="right">
Address
</td>
<td align="left">
<nested:nest property="CreateAppointmentForm">
<nested:iterate property="appointment">
<nested:write property="apptDescription"/>
</nested:iterate>
</nested:nest>
</td>
</tr>


<tr>
<td align="right">
<html:submit>Save</html:submit>
</td>
<td align="left">
<html:cancel>Cancel</html:cancel>
</td>
</tr>
</table>
</div>


</html:form>
</body>
</html:html>


however, when i click the link to access the page, following exception is thrown :

javax.servlet.jsp.JspException: No getter method for property CreateAppointmentForm.appointment.apptName of bean CreateAppointmentForm
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:176)
org.apache.struts.taglib.nested.html.NestedTextTag.doStartTag(NestedTextTag.java:94)
org.apache.jsp.pages.appointment.CreateAppointment_jsp._jspx_meth_nested_005ftext_005f0(CreateAppointment_jsp.java:320)
org.apache.jsp.pages.appointment.CreateAppointment_jsp._jspx_meth_nested_005fnest_005f1(CreateAppointment_jsp.java:291)
org.apache.jsp.pages.appointment.CreateAppointment_jsp._jspx_meth_nested_005fnest_005f0(CreateAppointment_jsp.java:252)
org.apache.jsp.pages.appointment.CreateAppointment_jsp._jspx_meth_html_005fform_005f0(CreateAppointment_jsp.java:166)
org.apache.jsp.pages.appointment.CreateAppointment_jsp._jspx_meth_html_005fhtml_005f0(CreateAppointment_jsp.java:108)
org.apache.jsp.pages.appointment.CreateAppointment_jsp._jspService(CreateAppointment_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

can anyone please help me out in this as i am unable to resolve the issue.
Best Regards

Usman
 
Don't get me started about those stupid light bulbs.
 
subject: Nested Beans Problem