Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing indexed bean property

 
J. Cartwright
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

given a bean that contains the following accessor:

public int[] getFrameSize(String frame) {
return((int[])frameSizes.get(frame));
}

I've set an instance of the bean as a request attribute under the key "tng".

I'm trying to get one of the indexed values from that instance into the JSP page. I'd prefer a JSTL solution, but failing that attempted the Struts bean tag

<bean:write name="tng" scope="request" property="frameSize(topFrame)[1]"/>

I'm getting a value like "[I@1af78ce" which I presume represents the int[]. However, I'd like to have the second element of the array.

Can anyone help me with this?

Thanks!

-- john
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

given a bean that contains the following accessor:

public int[] getFrameSize(String frame) {


Since the method signature requires a parameter, this is not a property accessor. And as such, inaccessbile from any mechanism requiring bean accessors, JSTL or otherwise.

You'll need to refactor your code to use true bean accessors if you want to use any JSP actions, Struts actions or EL/JSTL expressions to access the values.
[ September 14, 2005: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!