Question

I have a JSP question for you that I've been googling... I am using a title tag to display a long sentence on hover. However I want to put the sentence in a bean message and therefore set the title property equal to a bean message for example: Define message in struts-resources as…. My.hover_description = “blah blah blah and more blah”

JSP code:

<TD>
<html:button title= "<bean:message key=" My.hover_description "/> "
</html:button>
</TD>

I also tried but I think it’s just taking my quote as literal text rather than code:

<TD>
<html:button title= '<bean:message key=" My.hover_description "/>'
</html:button>
</TD>

So I’m wondering if I have to escape the quotes like so /” /” at the beginning and end of title definition or is there another way to escape the characters?

Was it helpful?

Solution 2

TD>
<input type="button" title='<bean:messagekey="My.hover_description"/>'
class="myClass" value='My Button'>
</TD>

This is the easy way...

OTHER TIPS

You can't use a JSP tag to declare the value of an attribute on another JSP tag because it doesn't execute the tag in the attribute declaration first. You can use a JSP tag to declare the value of an attribute on a standard HTML tag because the JSP tag is executed by the server, but the HTML isn't interpreted until it reaches the browser (i.e. there's no conflict in execution order).

You'll need to store the text into a variable first, then use it, something like this:

<c:set var="buttonTitle"><bean:message key="My.hover_description"/></c:set>
<html:button title="${buttonTitle}"...>...</html:button>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top