• Post Reply Bookmark Topic Watch Topic
  • New Topic

Nesting ${ ...... ${...} ... }

 
Jason Soper
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, I'm stuck.

I have an application that has a set of messages stored in a properties file. These messages are displayed on a form depending on the 'type' of form. The 'type' is stored in the request.

The properties file has a number of entries for infoBoxMessage.*. I have most of it working properly, for example ${ce.type} is returning 'O' as expected, and ${properties["infoBoxMessage.O"]} returns the text for infoBoxMessage.O in the properties file.

My problem is when I put these two together. I'm currently using:

${properties["infoBoxMessage.${ce.type}"]}

Which (fairly sensibly) returns the property for "infoBoxMessage.${ce.type}" without evaluating the inner ${...} code. How do I get it to do this?

Thanks.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,

Welcome to Java Ranch ..

I think you have to use like



 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Not sure, but give them a try.
 
Jason Soper
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the welcome.

That's not working though .

The properties object is set in the ContextListener using:



Here's a snippet from the properties file:



I'm using ${properties["some.value"]} quite a bit and it's all working fine.

The ce bean is set in the jsp to:

<jsp:useBean id="ce" type="net.scee.sid.groupcalendar.beans.CalendarEntry" scope="request" />

Which is working when I use ${ce.SomeBeanProperty}.

I think the problem I'm having is with the second ${...} nested inside the ["..."] parameter for the first ${...}.

Note,for testing, I've added the property entry:



to the properties file. This is what is being returned with the line:



I'm guessing this is because the JSP engine is picking up the first ${properties[....]} and renders the result, but passes the "infoBoxMessage.${ce.type}" without processing it. I'm trying to work out how to get it to process it.
 
Jason Soper
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:

Not sure, but give them a try.


Thanks for the nudge in the right direction, got it working now, using:

 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason Soper wrote:I'm guessing this is because the JSP engine is picking up the first ${properties[....]} and renders the result, but passes the "infoBoxMessage.${ce.type}" without processing it. I'm trying to work out how to get it to process it.

Anything inside the square bracket is either considered as map key or an array index.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!