java - I need to use <s: property> inside <s:text> -


i think need use <s: property> inside <s:text>, of course isn't possible.

here's situation: have .jsp needs display varying amount of actionmessages. normally, add actionmessages inside java class this:

action.addactionmessage("this string"); action.addactionmessage("this string"); 

however, don't hardcode message inside java class, define inside property file, this:

java: action.addactionmessage("menu.message1"); action.addactionmessage("menu.message2");  properties: menu.message1 = string menu.message2 = string 

of course, java action class cannot property file, struts tags can. 1 .jsp contains this:

<s:if test="hasactionmessages()"> <s:iterator value="actionmessages">  <div class="loginerrormessage">      <s:text name="<s:property>"/> </div>  </s:iterator> </s:if> 

i use iteration construction can control layout of messages. <s:property/> should return actionmessage itself, choose equal key entry in properties file. if kind of nested work get:

      <s:text name="<s:property/>"/>    ==>   <s:text name="menu.message1"/>    ==>   string 

can use ognl solve this? tried %{} , ${} things don't know name of value/var string of message of valuestack?

thx!

your initial statement wrong

of course, java action class can property file

you need extend actionsupport, can use gettext() method text in resource bundles.

if want go hack (i suggest don't):

<s:iterator value="actionmessages" var="key">     <div class="loginerrormessage">          <s:text name="%{#key}"/>     </div> </s:iterator> 

n.b.

if you're using actionsupport.addactionmessage() can use appropriate tag display action messages automatically - <s:actionmessage />. check if exist or not can put in jsp , forget it.


Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -