• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pass results of a struts logic tag to a java method?

 
Brett Han
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to pass the results of a struts logic tag to a java method?

For example, say I have the following static method in class Test:


and the following struts tag, refering to a Map called "someMap" in the "SomeForm" class:



This works fine, of course, but what I want is to pass what <bean:write name="_bean" property="value"> evalutes to to my method above. Something like:



Is there any way to do this? I've tried a bunch of possibilities but can't get the jsp to compile.

Thanks.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put scriptlets inside attributes of struts tags, but you can't use struts tags inside scriptlets. However, you can use the beans exposed by the struts logic tag in a scriptlet. In your example, the iterate tag exposes a bean with variable name _bean of type Map.Entry with a getValue() and a getKey() method. So, you could write the following:
<%= Test.foo(_bean.getValue()) %>

For more on this see the following link:

http://struts.apache.org/userGuide/struts-logic.html#iterate
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic