Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access map value through property of a nested input

 
Herbert Lenoir
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic