aspose file tools*
The moose likes Struts and the fly likes pass results of a struts logic tag to a java method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "pass results of a struts logic tag to a java method?" Watch "pass results of a struts logic tag to a java method?" New topic
Author

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

Brett Han
Greenhorn

Joined: May 17, 2005
Posts: 10
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

Joined: Feb 15, 2005
Posts: 4864
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


Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: pass results of a struts logic tag to a java method?