RE: Using Expression Language (EL) To Access ActionSupport Class Properties

2009-05-04 Thread Martin Gainty

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(ListString 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 ListString 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
  thRole identifiers/th
/tr
p/
s:iterator value=#it.roleIdentifiers status=rowstatus
  tr
s:if test=#rowstatus.odd == true
  td style=background: greys:property//td
/s:if
s:else
  tds: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
namehasRoles/name
!--coordinate this name with the classname above e.g. ClassNameTag --
tag-classorg.apache.ki.web.tags.HasRolesTag/tag-class
body-contentJSP/body-content
descriptionDisplays body content only if the current user has one of the 
specified roles from a
  comma-separated list of role names.
/description
attribute
  namename/name
  requiredtrue/required
  rtexprvaluetrue/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 

RE: Using Expression Language (EL) To Access ActionSupport Class Properties

2009-05-04 Thread phillips1021

Martin thank you for the reply.

Your idea:

s:set name=roleIds value=foo1,bar1/
jsec:hasAnyRoles name=s:property value=#roleIds //jsec:hasAnyRoles

does not work with the JSecurity hasAnyRoles tag. The Struts 2 property tag
and OGNL expresson do not work when placed as the value for the name
attribute of the above tag.  

Since I could not get a Struts 2 tag or OGNL expression to work for the name
attribute in the JSecurity hasAnyRoles tag, I used  expression language,
which did work.  

I'm trying to determine if using EL to access a property of the
ActionSupport class is OK in Struts 2.

Thanks again for the suggestions.

Bruce

-- 
View this message in context: 
http://www.nabble.com/Using-Expression-Language-%28EL%29-To-Access-ActionSupport-Class-Properties-tp23373477p23375317.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



Re: Using Expression Language (EL) To Access ActionSupport Class Properties

2009-05-04 Thread Musachy Barroso
using EL to access the stack/action is fine.

musachy

On Mon, May 4, 2009 at 3:48 PM, phillips1021 bphill...@ku.edu wrote:

 Martin thank you for the reply.

 Your idea:

 s:set name=roleIds value=foo1,bar1/
 jsec:hasAnyRoles name=s:property value=#roleIds //jsec:hasAnyRoles

 does not work with the JSecurity hasAnyRoles tag. The Struts 2 property tag
 and OGNL expresson do not work when placed as the value for the name
 attribute of the above tag.

 Since I could not get a Struts 2 tag or OGNL expression to work for the name
 attribute in the JSecurity hasAnyRoles tag, I used  expression language,
 which did work.

 I'm trying to determine if using EL to access a property of the
 ActionSupport class is OK in Struts 2.

 Thanks again for the suggestions.

 Bruce

 --
 View this message in context: 
 http://www.nabble.com/Using-Expression-Language-%28EL%29-To-Access-ActionSupport-Class-Properties-tp23373477p23375317.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





-- 
Hey you! Would you help me to carry the stone? Pink Floyd

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org