• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 pushing bean with indexed properties problem

 
Pavel Kazlou
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic