File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Access map value through property of a nested input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Access map value through property of a nested input" Watch "Access map value through property of a nested input" New topic
Author

Access map value through property of a nested input

Herbert Lenoir
Greenhorn

Joined: Jan 23, 2013
Posts: 3
Hi,

I am using Struts 1.2.9.

Within the property attribute of a html:text (http://struts.apache.org/tags-html), is there a way to access a property of a POJO defined as a value of a Map in the actionForm?

Example of POJO:

I create it from the action:

The ActionForm aims to be generic.

There is a jsp (myPojo.jsp) associated to the POJO that I can call from the main page:


Is there a way to access "myProperty" from "myPojo.jsp"?

The following code…

…is working but only if I define the corresponding "getter" in GenericForm:

My main issue is to ensure that GenericForm remains generic (no getFoo method).

I thought about a way to dynamically declare the "getters" in "registerPojo" (reflection?) but I don’t know how to do that.

Or maybe is there a syntax I didn’t think about yet?


Thank you, even just for the time you spent reading this.
Herbert Lenoir
Greenhorn

Joined: Jan 23, 2013
Posts: 3
I tried to understand the getNestedProperty of PropertyUtilsBean.java and it seems that the two following syntax should be correct:
I will try again and see what I get. (Though it may take a few hours.)
Herbert Lenoir
Greenhorn

Joined: Jan 23, 2013
Posts: 3
It’s working with the following syntax: I didn’t test the other. I must have been confused two weeks ago when I gave up on the problem after three days of trying.

Problem solved. Thanks the community for being there, I may not have found the solution without writing all those posts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access map value through property of a nested input