aspose file tools*
The moose likes Struts and the fly likes Problem with nested:iterate tag on Struts 1.2 with Websphere 5.1.2 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 » Frameworks » Struts
Bookmark "Problem with nested:iterate tag on Struts 1.2 with Websphere 5.1.2" Watch "Problem with nested:iterate tag on Struts 1.2 with Websphere 5.1.2" New topic
Author

Problem with nested:iterate tag on Struts 1.2 with Websphere 5.1.2

Ben Liu
Greenhorn

Joined: Feb 01, 2005
Posts: 8
Hi,

I'm having a problem with a web application that I'm developing. I'm using nested objects with Struts, JSTL and WASD 5.1.2

My code works fine in WASD 5.0, but breaks in WASD 5.1.2. The error says that it can't find a getter method for a property.

This is an indexed property.

My ActionForm is as follows:

Public class MyActionForm extends ActionForm {
private IndexedProperty MVBreakdowns; // a class that wraps around a HashMap

public Collection getMVBreakdowns() {
// returns as an ArrayList
}

public MarketValueBreakdown getMVBreakdowns(int i) {
// return the ith MarketValueBreakdown object
}

public void setMVBreakdowns(int i, MarketValueBreakdown breakdown) {
// sets the ith MarketValueBreakdown
}

My JSP is as follows:



...


I also tried using JSTL tags:




Both have similar issues with WASD 5.1.2, but works fine with WASD 5.0

Is this a known issue with Websphere?

is there a work around that does not include using straight JSP scriptlets?

Thanks in advance!
-Ben
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I had a similar problem when porting from Java 1.3 to 1.4. The problem is that for some reason the reflection API doesn't seem to handle overloaded methods in quite the same way it used to. I ended up just naming my indexed getter differently than my collection getter. In your case, change the name of the indexed getter to getMVBreakdown(int i), and it should work.


Merrill
Consultant, Sima Solutions
Ben Liu
Greenhorn

Joined: Feb 01, 2005
Posts: 8
Thanks. I confirmed that it is an overloaded method issue.

My JSP, however, is as follows:

<nested:iterate property="MVBrakdowns">
<nested:write property="MVBreakdowns.sectionId" />
</nested:iterate>

This needs both the Collection getMVBreakdowns() and the MarketValueBreakdown getMVBreakdowns(int i) methods to be named the same.

Is there another alternative or workaround for this?

I don't think WAS 5.1.2 is a JSP 2.0 container or else I could do something as follows:

<c:forEach items="${form.MVBreakdowns}" var="mvbreakdown" varStatus="breakdownStatus" >
<html:text property="MVBreakdowns[${breakdownStatus.index}].sectionId" />
</c:forEach>

I still want to avoid JSP scriptlets, but it seems that might be the best route.

Thanks in advance!
-Ben
Ben Liu
Greenhorn

Joined: Feb 01, 2005
Posts: 8
Real problem:

Indexed properties should be expressed as follows:

public class MyForm extends ActionForm {

public Object[] getIndexedProperty() {
}

public void setIndexedProperty(int i, Object property) {
}
}

// the following causes problems for JDK 1.4:
public Collection getIndexedProperty() {
}

public Object getIndexedProperty(int i) {
}

public void setIndexedProperty(int i, Object property) {
}

JSP as follows:

<nested:iterate property="indexedProperty" >
<nested:hidden property="subProperty" />
</nested:iterate>

Regards and thanks for the help,
-Ben
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with nested:iterate tag on Struts 1.2 with Websphere 5.1.2