You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Stavrianou <ch...@gmail.com> on 2004/10/08 15:44:34 UTC

Properties of Nested Beans

HI all,

I am having a problem with collections of beans nested within beans.

I have found that I can only nested beans and get property names if
the property names are unique across the entire application.

Is this a usual quirk of the way Struts uses reflection?

Are there restrictions on reusing names through form beans and other
beans across the scope of a web-application?

Thanks

C.S.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Properties of Nested Beans

Posted by Chris Stavrianou <ch...@gmail.com>.
I have narrowed the behaviour down somewhat - it appears to be related
to using capital letters in properties.

If I change the name of the LocationID String in the LocationBean from
locationID to LocationID I get the following error:

[ServletException in:/WEB-INF/jsp/admin/location/locselect.jsp] No
getter method for property LocationID of bean result'
javax.servlet.jsp.JspException: No getter method for property
LocationID of bean result at
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968) at
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286)
at org.apache.jsp.WEB_002dINF.jsp.admin.location.locselect_jsp._jspx_meth_bean_write_0(locselect_jsp.java:212)
at org.apache.jsp.WEB_002dINF.jsp.admin.location.locselect_jsp._jspService(locselect_jsp.java:124)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:581)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177) at
org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
at org.apache.jsp.WEB_002dINF.jsp.HBFlayout_jsp._jspx_meth_tiles_insert_1(HBFlayout_jsp.java:165)
at org.apache.jsp.WEB_002dINF.jsp.HBFlayout_jsp._jspService(HBFlayout_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java

See following:

---------------------Location Bean

public class Location implements Serializable {
	
	
	private String	locationName, locationID;
	
	
	public Location (String locationID,String locationName) {
		this.locationID = locationID;
		this.locationName = locationName;
	}

	
	public String getlocationID (){
		return locationID;
	}

	public void setlocationID (String locationID){
		this.locationID = locationID;
	}	

public String getlocationName (){
	return locationName;
}

public void setlocationName (String locationName){
	this.locationName = locationName;
}
	
	
}

----------------------------

ArrayList results = new ArrayList();
	
	String stmt = "select * from location where orgID = ? order by locationName;";

		try {
		    PreparedStatement pstmt = conn.prepareStatement(stmt);
		    pstmt.setInt(1,orgID.intValue());
			ResultSet RS = pstmt.executeQuery();
					
			while (RS.next()){
				results.add(
				new Location(
				RS.getString("LocationID"),
				RS.getString("locationName")
				)
			); }
			form.set("locations",results);

---------------------------JSP

<td>LocationName</td>
</tr>

<logic:iterate id="result"  name="locationList" property="locations">
<tr>
<td><a href='locEdit.do?LocationID=<bean:write name="result"
property="locationID"/>''>Edit</a></td>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Properties of Nested Beans

Posted by Yves Sy <yv...@gmail.com>.
Try keyboardmonkey.com

It has good stuff on nested tags which is what probably need.

-Yves-

On Fri, 08 Oct 2004 11:39:27 -0400, Bill Siggelkow
<bi...@bellsouth.net> wrote:
> There is no such restriction -- please provide some code so we can help
> diagnose your problem.
> 
> -Bill Siggelkow
> 
> 
> 
> Chris Stavrianou wrote:
> > HI all,
> >
> > I am having a problem with collections of beans nested within beans.
> >
> > I have found that I can only nested beans and get property names if
> > the property names are unique across the entire application.
> >
> > Is this a usual quirk of the way Struts uses reflection?
> >
> > Are there restrictions on reusing names through form beans and other
> > beans across the scope of a web-application?
> >
> > Thanks
> >
> > C.S.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
For me to poop on!
http://www.formetopoopon.com
http://www.nbc.com/nbc/Late_Night_with_Conan_O'Brien/video/triumph.shtml

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Properties of Nested Beans

Posted by Bill Siggelkow <bi...@bellsouth.net>.
There is no such restriction -- please provide some code so we can help 
diagnose your problem.

-Bill Siggelkow

Chris Stavrianou wrote:
> HI all,
> 
> I am having a problem with collections of beans nested within beans.
> 
> I have found that I can only nested beans and get property names if
> the property names are unique across the entire application.
> 
> Is this a usual quirk of the way Struts uses reflection?
> 
> Are there restrictions on reusing names through form beans and other
> beans across the scope of a web-application?
> 
> Thanks
> 
> C.S.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org