This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: pass results of a struts logic tag to a java method?
 
Similar Threads
problem in logic:iterate
How to make dynamic radio button checked
How to iterate over one List and get a nested property defined in a different List
logic:iterate tag displaying same results??
logic:match , logic:notEqual not working