• Post Reply Bookmark Topic Watch Topic
  • New Topic

Assigning the custom tag's output to a java variable

 
Raji ram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using a custom tag for doing internationalization.
I want to pass a language specific string to one of my library methods used by the JSP page.
Is it possible to assign the output of the custom tag to a java variable so that this variable can be used to pass to the method.
My code is like this:
This is my custom tag
<i18n:message key="main.subhead"/>
Is there a way to assign the output of this to a String
something like this??
<% String s = "<i18n:message key="main.subhead"/> ";%>
Ofcourse this doesn't work.
Any other way to do this?
Thanks,
Raji.
 
Damian Harvey
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a bit long winded but you could try something like :
<c:set var="s" scope="session">
<i18n:message key="main.subhead"/>
</c:set>
<% String s = (String)session.getAttribute("s"); %>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd not set it into the session since it wouldn't need to stay around for any length of time. Page scope would do nicely.
But.... why are you trying to do this in the first place? Seems kind of odd. Perhaps if you let us know what the ultimate use of "s" is, someone can come up with an alternate suggestion.
bear
 
Raji ram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my requirement:
I have a JSP page where I would want to validate one of the values that comes from the backend.
There is a library method available(third party library that I canot change) that would validate my data and print a error message if it is a invalid data. This method takes the error message as one of the parameters.
And I want to give language specific message to this method.
This is why I want to assign the output of my custom tag which would give a language specific message to a variable so that I can pass this variable as a parameter to my method.
Thanks for listening. Please let me know if you have any suggestions.
Regards,
Raji.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!