aspose file tools*
The moose likes Struts and the fly likes struts 2 pushing bean with indexed properties problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 pushing bean with indexed properties problem" Watch "struts 2 pushing bean with indexed properties problem" New topic
Author

struts 2 pushing bean with indexed properties problem

Pavel Kazlou
Ranch Hand

Joined: Sep 07, 2009
Posts: 33
Hi.
During the development I faced a very strange struts 2 behavior. Here is the simplified example of the problem.
In my action class I define a collection or a map of beans that have indexed properties:

Then in my jsp I try to access the properties of beans in two ways - using the whole path and using push tag (I try to do this for both Map (beans) and List (beanList)) :

As the result, when using push tag indexed property is not displayed while simple property is displayed:


I've thought that push tag makes no difference when accessing properties, just shortening the path.
Is it a bug in struts 2 that prevents indexed property from displaying or I'm doing something wrong?
The example may seem a bit synthetic but in my real application it brings me some troubles because I can't replace those indexed properties with some collection - there is some logic behind them.
I tried the example on both struts 2.0.14 and 2.1.8 - the results are the same.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The first thing I'd try is to try and use the indexed notation ("()" instead of "[]") for the indexData properties. Using the "[]" notation tells OGNL it's going to be a map or a list, which it isn't.

If that doesn't work, I'd have to dig into it.
Pavel Kazlou
Ranch Hand

Joined: Sep 07, 2009
Posts: 33
David, thanks for the reply.
Here is my attempt

...and the result

So, as you see "()" doesn't work at all. Also, note that when using "[]" I was able to display indexed property when using the whole path "beans[1].indexData[1]".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 2 pushing bean with indexed properties problem