the default mechanism for passing information back and forth is string for more complex datatypes you're going to have to build the interface yourself assuming this is the method
protected boolean[] hasRoles(List<String> roleIdentifiers, AuthorizationInfo info)<!-- I have no idea whats inside of AuthorizationInfo so you'll populate it --> <s:bean name="package.MyAuthorizationInfo" var="counter"> <s:param name="foo" value="BAR" /> The value of foo is : <s:property value="foo"/>, when inside the bean tag <br /> </s:bean> <!--config class to the bean that contains the List<String> of role-identifiers --> <s:bean name="package.ClassThatHasRoles" var="it"> <s:param name="Role1" value="'ChiefLackey'"/> <s:param name="Role2" value="'AssistantToChiefLackey'"/> </s:bean> <p/> <table border="0" cellspacing="0" cellpadding="1"> <tr> <th>Role identifiers</th> </tr> <p/> <s:iterator value="#it.roleIdentifiers" status="rowstatus"> <tr> <s:if test="#rowstatus.odd == true"> <td style="background: grey"><s:property/></td> </s:if> <s:else> <td><s:property/></td> </s:else> </tr> </s:iterator> <jsec:hasAnyRoles name="<s:property value="#it.roleIdentifiers" />,<s:property value="#counter" />" ></jsec:hasAnyRoles> </table> you will have to config the /META-INF/ki.tld <tag> <name>hasRoles</name> <!--coordinate this name with the classname above e.g. ClassNameTag --> <tag-class>org.apache.ki.web.tags.HasRolesTag</tag-class> <body-content>JSP</body-content> <description>Displays body content only if the current user has one of the specified roles from a comma-separated list of role names. </description> <attribute> <name>name</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> alternative to make own tag is to use an existing tag that will concatenate string values <s:set name="roleIds" value="foo1,bar1"/> <jsec:hasAnyRoles name="<s:property value="#roleIds" /></jsec:hasAnyRoles> Martin ______________________________________________ Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents. Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Mon, 4 May 2009 11:00:36 -0700 > From: bphill...@ku.edu > To: user@struts.apache.org > Subject: Using Expression Language (EL) To Access ActionSupport Class > Properties > > > We are building a new web application that uses both JSecurity > (http://cwiki.apache.org/confluence/display/KI/Index, now known as Ki) and > Struts 2 (version 2.1.6). > > In many of the JSPs for this application, we need to provide a dynamic > String value to the JSecurity tag library's hasAnyRoles tag. This tag's > format is: > > <jsec:hasAnyRoles name="Staff,Admin"> > ...content to include if current user has one of the roles specified in the > name attribute... > </jsec:hasAnyRoles> > > Of course instead of hard-coding the values for the name attribute we want > to have the the attribute's value rendered dynamically using Struts 2. > > First we tried using: > > <jsec:hasAnyRoles name="<s:property value='roles' />" ></jsec:hasAnyRoles> > > But that did not work even though we have a public method named getRoles in > the action support class that renders this jsp page. > > So just for a test we tried using expression language (EL): > > <jsec:hasAnyRoles name="${roles}" ></jsec:hasAnyRoles> > > And the above worked just fine. > > I didn't know you could access properties of the ActionSupport class using > Expression Language. > > I researched the ability to use Expression Language (EL) to access > properties of the ActionSupport class in the Struts 2 documentation at > http://struts.apache.org and in this mailing list. I didn't find much about > the capability to use EL to access properties of the ActionSupport class. > The documentation clearly states NOT to use EL in attributes for Struts 2 > tags, but it's not clear on using EL to access ActionSupport class > properties outside of the Struts 2 tags. > > Since we are building a new web application that will be around for some > time and would like to be able to upgrade to future versions of Struts 2, > we'd like to know if the ability to access ActionSupport class properties > using EL is a built-in and a supported feature of Struts 2? > > > Below is some test code to detail how this works: > > ActionSupport class: > > import com.opensymphony.xwork2.ActionSupport; > > public class TestActionSupport extends ActionSupport { > > private static final long serialVersionUID = 1L; > > public String execute() throws Exception { > > return SUCCESS; > > } > > public String getRoles() { > > return "Staff,Admin"; > > } > > } > > JSP View rendered when above class returns SUCCESS: > > <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> > <%@ taglib prefix="s" uri="/struts-tags" %> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <html> > <head> > > <title>Test of Struts 2 and EL</title> > > </head> > > <body> > <h3>Test of Struts 2 and EL Results Page</h3> > <p>Roles via expression language: ${roles}</p> > <p>Roles via Struts 2 property tag: <s:property value='roles' /></p> > </body> > </html> > > Does Struts 2 turn the ActionSupport class itself turned into a bean object > that is placed in request scope? Is that how the Expression Language > ${roles} is able to execute correctly? > > Thanks for any information provided that helps us understand the use of EL > to access the ActionSupport class properties. > > Bruce > > -- > View this message in context: > http://www.nabble.com/Using-Expression-Language-%28EL%29-To-Access-ActionSupport-Class-Properties-tp23373477p23373477.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _________________________________________________________________ Hotmail® has a new way to see what's up with your friends. http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009