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

bean:message in bean:define tag

 
Shailesh Modi
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using the code snippet given below to define a variable for which the value is coming from property file by key 'home.mouseover.runbutton.caption.
But when i try to display ths jsp containing this snippet , i get java script error as struts doesn't compile "<bean:message key=home.mouseover.runbutton.caption/>" and assign this string literal as it is to runcapt variable.

Please let me know what can be done to assign the actual value in property file to runcapt variable.
jsp page
=====
<bean efine id="runcapt" value="<bean:message key=home.mouseover.runbutton.caption/>"/>
++++++++++++++++++++++++++++++++++++++++++++++++++++++
property file
==========
home.mouseover.runbutton.caption = Run Search
Thanks in advance
 
Karthik Guru
Ranch Hand
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Am not a struts expert but can you try this?
 
Sean Gildea
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but that throws...

"Define tag can contain only one of name attribute, value attribute, or body content"
 
Aash Patel
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shailesh - I don't think you need to embed your bean message tag inside a bean define tag. This is how I do it:

<bean:message bundle="moreResources" key="required.field"/>

where bundle name is what you specify in your struts-config.xml as below:

<message-resources key="moreResources" parameter="MoreApplicationResources" />

where parameter name is the name of your properties file. In this case, my properties file is called MoreApplicationResources.properties

Make sense?
 
Aash Patel
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry - I misread the define variable part. In any case, you can try my suggestion to at least display the value. That way you know if your jsp is getting it from the properties file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic