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 titleTest of Struts 2 and EL/title /head body h3Test of Struts 2 and EL Results Page/h3 pRoles via expression language: ${roles}/p pRoles 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
RE: Using Expression Language (EL) To Access ActionSupport Class Properties
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
RE: Using Expression Language (EL) To Access ActionSupport Class Properties
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
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
S2.1 - struts tags vs jstl expression language
I assumed that I had to use the struts tags. I noticed that my older ${} worked for my objects. Is there a compelling reason to use the longer struts tags instead of JSTL EL? Norris Shelton Software Engineer Sun Certified Java 1.1 Programmer Shelton Consulting, LLC ICQ# 26487421 AIM NorrisEShelton YIM norrisshelton
Re: S2.1 - struts tags vs jstl expression language
Norris Shelton wrote: I assumed that I had to use the struts tags. I noticed that my older ${} worked for my objects. Is there a compelling reason to use the longer struts tags instead of JSTL EL? Typing practice for the angle brackets? The S2 request wrapper will map the EL requests to the OGNL stack. If the value isn't found on the value stack it'll fall back to the normal JEE lookup mechanism. The only reason I can think of (barring performance, which I can't imagine would be significant) would be if there was a name conflict where an S2 action property might mask something in a JEE scope and you want the JEE-scoped value.s Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: S2.1 - struts tags vs jstl expression language
That works. Thanks. From: Dave Newton newton.d...@yahoo.com To: Struts Users Mailing List user@struts.apache.org Sent: Friday, January 16, 2009 3:09:31 PM Subject: Re: S2.1 - struts tags vs jstl expression language Norris Shelton wrote: I assumed that I had to use the struts tags. I noticed that my older ${} worked for my objects. Is there a compelling reason to use the longer struts tags instead of JSTL EL? Typing practice for the angle brackets? The S2 request wrapper will map the EL requests to the OGNL stack. If the value isn't found on the value stack it'll fall back to the normal JEE lookup mechanism. The only reason I can think of (barring performance, which I can't imagine would be significant) would be if there was a name conflict where an S2 action property might mask something in a JEE scope and you want the JEE-scoped value.s Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Help on expression language
Hi, time ago I bookmarked a detailed table reference about EL, but now I lost this bookmark :super: . So, where to find detailed table reference, source code samples or source code implementations about the expression language? Thanks in advance, best regards. -- View this message in context: http://www.nabble.com/Help-on-expression-language-tf4538542.html#a12953443 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help on expression language
Have a look at this friend. http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html On 9/29/07, rigel [EMAIL PROTECTED] wrote: Hi, time ago I bookmarked a detailed table reference about EL, but now I lost this bookmark :super: . So, where to find detailed table reference, source code samples or source code implementations about the expression language? Thanks in advance, best regards. -- View this message in context: http://www.nabble.com/Help-on-expression-language-tf4538542.html#a12953443 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Scott [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
Zoran, what do you want to script in the tags? I would be interested in a small example, only because I often find my use of JSTL is restricted to situations where I am not using taglibs. Which leads me to ask, if you rely on JSTL anyway, surely you use the Standard taglib tags? Adam Zoran Avtarovski on 06/09/07 05:20, wrote: That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language. Pardon me for being blunt but isn't the obvious solution to fix the underlying vulnerability in OGNL rather than crippling JSP and Freemarker use in struts2. This basically forces us to use OGNL, which I think is plain wrong. Z. You can up until Struts 2.0.9. There is a security flaw related to this though and you will no longer be able to do it in Struts 2.0.10. See the following JIRA ticket for more info: https://issues.apache.org/struts/browse/WW-2107 James On Wed Sep 5 11:31 , Néstor Boscán [EMAIL PROTECTED] sent: Hi Is there a way to use the JSTL Expression Language with Struts 2 tags instead of OGNL? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
I am not Zoran but I tried for a few weeks to use OGNL but everytime I tried to type an OGNL expression it took me 3 or 4 attempts to make it do what I wanted. In every case, I was able to get the EL right first time. In the end I settled on the following rules for myself: - in a struts tag, use OGNL - else use EL If I had known that I could use EL in a struts tag, I would have... but - given the start of this thread - I am glad I did not. I use the struts tags exclusively because they are easier to use with than the JSTL tags. I would use EL exclusively (if I could) for the same reason. -- Kevin http://www.junitfactory.com You send us code. We send you tests. For free. On 9/6/07, Adam Hardy [EMAIL PROTECTED] wrote: Zoran, what do you want to script in the tags? I would be interested in a small example, only because I often find my use of JSTL is restricted to situations where I am not using taglibs. Which leads me to ask, if you rely on JSTL anyway, surely you use the Standard taglib tags? Adam Zoran Avtarovski on 06/09/07 05:20, wrote: That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language.
Re: Using JSTL Expression Language with Struts 2 tags
My rule is: don't use the S2 tags unless I have to. Typically, if I need something from the value stack, I use an s:set tag to bring it down into the page scope, and then use JSTL and EL. Or on some pages I can use JSF tags and get rid of the problem completely. Having said that, the S2 iterator and if/else tags have a far superior syntax to the JSTL equivalents. I like many things in S2, but the S2 tag libs and OGNL aren't among them. The use of the OGNL library would be tolerable if the S2 tag syntax were set to some single standard instead of using a little of at least 3 standards. (And I haven't even tried JSP 2.1 syntax yet). As it stands, this is a TERRIBLE shortcoming in S2. - Ray Clough - Original Message - From: Kevin Lawrence To: Struts Users Mailing List Subject: Re: Using JSTL Expression Language with Struts 2 tags Date: Thu, 6 Sep 2007 13:37:39 -0700 I am not Zoran but I tried for a few weeks to use OGNL but everytime I tried to type an OGNL expression it took me 3 or 4 attempts to make it do what I wanted. In every case, I was able to get the EL right first time. In the end I settled on the following rules for myself: - in a struts tag, use OGNL - else use EL If I had known that I could use EL in a struts tag, I would have... but - given the start of this thread - I am glad I did not. I use the struts tags exclusively because they are easier to use with than the JSTL tags. I would use EL exclusively (if I could) for the same reason. -- Kevin http://www.junitfactory.com You send us code. We send you tests. For free. On 9/6/07, Adam Hardy wrote: Zoran, what do you want to script in the tags? I would be interested in a small example, only because I often find my use of JSTL is restricted to situations where I am not using taglibs. Which leads me to ask, if you rely on JSTL anyway, surely you use the Standard taglib tags? Adam Zoran Avtarovski on 06/09/07 05:20, wrote: That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language. - Ray Clough [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
Chris Pratt on 07/09/07 00:45, wrote: On 9/6/07, Adam Hardy [EMAIL PROTECTED] wrote: Is OGNL a standard as well as JSTL? Depends what you mean by a standard? It comes standard with Struts 2, but it was not defined by some standards organization. Sorry, for the bad question. I'll check it OGNL tomorrow. I wanted to ask something else but couldn't figure out how to put it. What I meant instead, JSTL is a specification from Sun, implemented by Jakarta. I have no idea about OGNL. Before I go diving into S2 tags and OGNL, I need to get a brief overview of OGNL, and also of whatever it is that Glassfish are doing which Jakarta Taglibs recommend on their website. Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
On 9/6/07, Adam Hardy [EMAIL PROTECTED] wrote: Is OGNL a standard as well as JSTL? Depends what you mean by a standard? It comes standard with Struts 2, but it was not defined by some standards organization. (*Chris*) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
NO! - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Subject: Re: Using JSTL Expression Language with Struts 2 tags Date: Fri, 07 Sep 2007 00:42:11 +0100 Is OGNL a standard as well as JSTL? Ray Clough on 06/09/07 23:43, wrote: My rule is: don't use the S2 tags unless I have to. Typically, if I need something from the value stack, I use an s:set tag to bring it down into the page scope, and then use JSTL and EL. Or on some pages I can use JSF tags and get rid of the problem completely. Having said that, the S2 iterator and if/else tags have a far superior syntax to the JSTL equivalents. I like many things in S2, but the S2 tag libs and OGNL aren't among them. The use of the OGNL library would be tolerable if the S2 tag syntax were set to some single standard instead of using a little of at least 3 standards. (And I haven't even tried JSP 2.1 syntax yet). As it stands, this is a TERRIBLE shortcoming in S2. - Ray Clough - Original Message - From: Kevin Lawrence To: Struts Users Mailing List Subject: Re: Using JSTL Expression Language with Struts 2 tags Date: Thu, 6 Sep 2007 13:37:39 -0700 I am not Zoran but I tried for a few weeks to use OGNL but everytime I tried to type an OGNL expression it took me 3 or 4 attempts to make it do what I wanted. In every case, I was able to get the EL right first time. In the end I settled on the following rules for myself: - in a struts tag, use OGNL - else use EL If I had known that I could use EL in a struts tag, I would have... but - given the start of this thread - I am glad I did not. I use the struts tags exclusively because they are easier to use with than the JSTL tags. I would use EL exclusively (if I could) for the same reason. -- Kevin http://www.junitfactory.com You send us code. We send you tests. For free. On 9/6/07, Adam Hardy wrote: Zoran, what do you want to script in the tags? I would be interested in a small example, only because I often find my use of JSTL is restricted to situations where I am not using taglibs. Which leads me to ask, if you rely on JSTL anyway, surely you use the Standard taglib tags? Adam Zoran Avtarovski on 06/09/07 05:20, wrote: That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Ray Clough [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
Sorry about the delay, APEC holiday (don't ask). I'm not doing any fancy scripting just simple stuff like using jsp el in the s:if and s:property tags. I know that I could use the OGNL equivalents and in some situations do, but it's more a matter of standards. Our team maintain and develop websites using a number of technologies including struts1, struts2, custom java and .NET which we have implemented or inherited. On the java side we have spent considerable effort to consolidate the technologies we use so that we can avoid stretching ourselves too thin. Productivity is improved as we are using technologies we are familiar with without having to think how is this done using this particular technology We decided on JSTL, JSP EL and velocity for the display technologies as these covered every project we were working on. And we thought we were covered on the struts2 front. Don't misinterpret what I am saying, I am not saying JSP EL is better than OGNL. In fact OGNL clearly has significant advantages. But, and it's a big hairy one, OGNL can't easily be introduced into legacy apps we maintain. I'm not saying don't have OGNL, but rather let us have a choice. I find it difficult to believe that there isn't a simple solution to this problem. The upshot is that we will probably move away from using S2 tags where we can and only use the S2 form tags. Z. Zoran, what do you want to script in the tags? I would be interested in a small example, only because I often find my use of JSTL is restricted to situations where I am not using taglibs. Which leads me to ask, if you rely on JSTL anyway, surely you use the Standard taglib tags? Adam Zoran Avtarovski on 06/09/07 05:20, wrote: That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language. Pardon me for being blunt but isn't the obvious solution to fix the underlying vulnerability in OGNL rather than crippling JSP and Freemarker use in struts2. This basically forces us to use OGNL, which I think is plain wrong. Z. You can up until Struts 2.0.9. There is a security flaw related to this though and you will no longer be able to do it in Struts 2.0.10. See the following JIRA ticket for more info: https://issues.apache.org/struts/browse/WW-2107 James On Wed Sep 5 11:31 , Néstor Boscán [EMAIL PROTECTED] sent: Hi Is there a way to use the JSTL Expression Language with Struts 2 tags instead of OGNL? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
Is OGNL a standard as well as JSTL? Ray Clough on 06/09/07 23:43, wrote: My rule is: don't use the S2 tags unless I have to. Typically, if I need something from the value stack, I use an s:set tag to bring it down into the page scope, and then use JSTL and EL. Or on some pages I can use JSF tags and get rid of the problem completely. Having said that, the S2 iterator and if/else tags have a far superior syntax to the JSTL equivalents. I like many things in S2, but the S2 tag libs and OGNL aren't among them. The use of the OGNL library would be tolerable if the S2 tag syntax were set to some single standard instead of using a little of at least 3 standards. (And I haven't even tried JSP 2.1 syntax yet). As it stands, this is a TERRIBLE shortcoming in S2. - Ray Clough - Original Message - From: Kevin Lawrence To: Struts Users Mailing List Subject: Re: Using JSTL Expression Language with Struts 2 tags Date: Thu, 6 Sep 2007 13:37:39 -0700 I am not Zoran but I tried for a few weeks to use OGNL but everytime I tried to type an OGNL expression it took me 3 or 4 attempts to make it do what I wanted. In every case, I was able to get the EL right first time. In the end I settled on the following rules for myself: - in a struts tag, use OGNL - else use EL If I had known that I could use EL in a struts tag, I would have... but - given the start of this thread - I am glad I did not. I use the struts tags exclusively because they are easier to use with than the JSTL tags. I would use EL exclusively (if I could) for the same reason. -- Kevin http://www.junitfactory.com You send us code. We send you tests. For free. On 9/6/07, Adam Hardy wrote: Zoran, what do you want to script in the tags? I would be interested in a small example, only because I often find my use of JSTL is restricted to situations where I am not using taglibs. Which leads me to ask, if you rely on JSTL anyway, surely you use the Standard taglib tags? Adam Zoran Avtarovski on 06/09/07 05:20, wrote: That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using JSTL Expression Language with Struts 2 tags
Hi Is there a way to use the JSTL Expression Language with Struts 2 tags instead of OGNL? Regards, Néstor Boscán
Re: Using JSTL Expression Language with Struts 2 tags
You can up until Struts 2.0.9. There is a security flaw related to this though and you will no longer be able to do it in Struts 2.0.10. See the following JIRA ticket for more info: https://issues.apache.org/struts/browse/WW-2107 James On Wed Sep 5 11:31 , Néstor Boscán [EMAIL PROTECTED] sent: Hi Is there a way to use the JSTL Expression Language with Struts 2 tags instead of OGNL? Regards, Néstor Boscán - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using JSTL Expression Language with Struts 2 tags
That just sounds ridiculous. Because of the possibility of end users injecting malicious OGNL we won't be able to use JSP expression language. Pardon me for being blunt but isn't the obvious solution to fix the underlying vulnerability in OGNL rather than crippling JSP and Freemarker use in struts2. This basically forces us to use OGNL, which I think is plain wrong. Z. You can up until Struts 2.0.9. There is a security flaw related to this though and you will no longer be able to do it in Struts 2.0.10. See the following JIRA ticket for more info: https://issues.apache.org/struts/browse/WW-2107 James On Wed Sep 5 11:31 , Néstor Boscán [EMAIL PROTECTED] sent: Hi Is there a way to use the JSTL Expression Language with Struts 2 tags instead of OGNL? Regards, Néstor Boscán - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Expression Language
On 3/23/06, David M Sledge [EMAIL PROTECTED] wrote: Do EL expressions only evaluate to String and primitive types? I have code similar to the following in my jsp. logic:iterate name=uriList id=uri write:iterate name= uriValueMap property=${uri}/ snip/ I will assume thats bean:write. /logic:iterate Where uriList is an object of type java.util.List only containing java.net.URI objects, and where uriValueMap has only java.net.URI objects as keys and has for values objects with the property someProperty. As a result, I end up getting the following exception: javax.servlet.ServletException: Invalid argument looking up property: http://namespace-uri.org.someProperty; of bean: uriValueMap Is there any way to preserved the java.net.URI type as a lookup key? snap/ Probably not using bean:write. I prefer JSTL counterparts for the tags above. This will work: c:forEach items=${uriList} var=uri c:out value=${uriValueMap[uri]} / /c:forEach c:out may not be needed. -Rahul Thanks, David M. Sledge Analyst/Programmer Specialist LTER Network Office Dept. of Biology, MSC03 2020 1 University of New Mexico Albuquerque, NM 87131-0001 505-277-0666 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Expression Language
Do EL expressions only evaluate to String and primitive types? I have code similar to the following in my jsp. logic:iterate name=uriList id=uri write:iterate name= uriValueMap property=${uri}/ /logic:iterate Where uriList is an object of type java.util.List only containing java.net.URI objects, and where uriValueMap has only java.net.URI objects as keys and has for values objects with the property someProperty. As a result, I end up getting the following exception: javax.servlet.ServletException: Invalid argument looking up property: http://namespace-uri.org.someProperty; of bean: uriValueMap Is there any way to preserved the java.net.URI type as a lookup key? Thanks, David M. Sledge Analyst/Programmer Specialist LTER Network Office Dept. of Biology, MSC03 2020 1 University of New Mexico Albuquerque, NM 87131-0001 505-277-0666 [EMAIL PROTECTED]
newbie guestion: JSTL Expression language
I want to use JSTL to check the role of the user (it can be one of many) I'm new to JSTL so even the simplest things gives me problems: I've set the role using request.setAttribute(role , role); This tag: c:out value=${role}/ Prints out the role fine While the following statements are newer true: c:if test=${role}==editor The role is editor /c:if c:if test=${role}=='editor' The role is editor /c:if Where do I go wrong? Morten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: newbie guestion: JSTL Expression language
Morten Andersen wrote: I want to use JSTL to check the role of the user (it can be one of many) I'm new to JSTL so even the simplest things gives me problems: I've set the role using request.setAttribute(role , role); This tag: c:out value=${role}/ Prints out the role fine While the following statements are newer true: c:if test=${role}==editor The role is editor /c:if c:if test=${role}=='editor' The role is editor /c:if Where do I go wrong? test is wrong :-) It should be test=${role eq 'editor'} if you want to compare with strings or test=${role eq editor} if you have variable editor in page/request/session scope with value you want to check against - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: newbie guestion: JSTL Expression language
On 3/16/06, Morten Andersen [EMAIL PROTECTED] wrote: I want to use JSTL to check the role of the user (it can be one of many) I'm new to JSTL so even the simplest things gives me problems: I've set the role using request.setAttribute(role , role); This tag: c:out value=${role}/ Prints out the role fine While the following statements are newer true: c:if test=${role}==editor snip/ Expression must be contained in ${ and } in its entirety i.e. ${role eq 'editor'} The role is editor /c:if c:if test=${role}=='editor' snap/ ${role ne 'editor'} -Rahul The role is editor /c:if Where do I go wrong? Morten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: newbie guestion: JSTL Expression language
The text as is from JSP 2.0 Spec Point 1. EL expression An element in a JSP page representing an expression to be parsed and evaluated via the JSP Expression Language. Syntactically it is delimited by the ${ and } characters. Point 2. JSP.2.3.5.5 Relational Operators The relational operators are: == and eq != and ne and lt and gt = and le = and ge Point 3 JSP.2.3.5.7 A {==,!=,eq,ne} B If A==B, apply operator If A is null or B is null return false for == or eq, true for != or ne. If A or B is BigDecimal, coerce both A and B to BigDecimal and then: If operator is == or eq, return A.equals( B ) If operator is != or ne, return !A.equals( B ) If A or B is Float or Double coerce both A and B to Double, apply operator ... Your code c:if test=${role}==editor The role is editor /c:if c:if test=${role}=='editor' The role is editor /c:if So from point 1 and point 2 c:if test=${role=='editor'} (See the expression is with in ${} point 1) The role is editor /c:if will work . See Point 2 bulleted points . == and eq and Point 3 how the relational operator is evaluated. You can look for more information in the spec. So c:if test=${role=='editor'} The role is editor /c:if is same as c:if test=${role eq 'editor'} The role is editor /c:if Thanks, Vijay Venkataraman Rahul Akolkar wrote: On 3/16/06, Morten Andersen [EMAIL PROTECTED] wrote: I want to use JSTL to check the role of the user (it can be one of many) I'm new to JSTL so even the simplest things gives me problems: I've set the role using request.setAttribute(role , role); This tag: c:out value=${role}/ Prints out the role fine While the following statements are newer true: c:if test=${role}==editor snip/ Expression must be contained in ${ and } in its entirety i.e. ${role eq 'editor'} The role is editor /c:if c:if test=${role}=='editor' snap/ ${role ne 'editor'} -Rahul The role is editor /c:if Where do I go wrong? Morten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --DISCLAIMER-- This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.
Re: Off Topic Expression Language question
is it always the same object (class) and the same method you are calling? In this case I'd suggest you write a three-line custom tag for it. If you have to do it more often, maybe a tag using reflection api would be an answer. I you write one, let me know, I may need one too :-) regards Leon On 2/23/06, Jim Collins [EMAIL PROTECTED] wrote: Hi All, Appologies for the off topic posting. Does anyone Know how I can access a bean property that takes a parameter using EL. For example if in a bean I have define a name property with public String getName(){return name;} I can access this with EL ${mybean.name} But suppose in my bean the method signature is: public String getName(String someParam){return name;} How would I access this in EL and pass a value in for the parameter? Any ideas would be appreciated. Thanks Jim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Off Topic Expression Language question
Hi Leon, Thanks for the reply. I refactored my bean so that the method no longer takes a String parameter which is as per the bean spec. I might have a look at your suggestion to see if that would have worked. Regards Jim - Original Message - From: Leon Rosenberg [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Thursday, February 23, 2006 2:26 PM Subject: Re: Off Topic Expression Language question is it always the same object (class) and the same method you are calling? In this case I'd suggest you write a three-line custom tag for it. If you have to do it more often, maybe a tag using reflection api would be an answer. I you write one, let me know, I may need one too :-) regards Leon On 2/23/06, Jim Collins [EMAIL PROTECTED] wrote: Hi All, Appologies for the off topic posting. Does anyone Know how I can access a bean property that takes a parameter using EL. For example if in a bean I have define a name property with public String getName(){return name;} I can access this with EL ${mybean.name} But suppose in my bean the method signature is: public String getName(String someParam){return name;} How would I access this in EL and pass a value in for the parameter? Any ideas would be appreciated. Thanks Jim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Off Topic Expression Language question
Hi All, Appologies for the off topic posting. Does anyone Know how I can access a bean property that takes a parameter using EL. For example if in a bean I have define a name property with public String getName(){return name;} I can access this with EL ${mybean.name} But suppose in my bean the method signature is: public String getName(String someParam){return name;} How would I access this in EL and pass a value in for the parameter? Any ideas would be appreciated. Thanks Jim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Newbie Q - Struts expression language taglibs
Hi All, From where can I download struts el tag libraries. I downloaded jakarta-struts-1.2.4.zip, but it does not contain struts-html-el tag libraries Thanks, Ibha - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie Q - Struts expression language taglibs
Take a look into the contrib/struts-el/lib folder ! Nico. Ibha Gandhi a écrit : Hi All, From where can I download struts el tag libraries. I downloaded jakarta-struts-1.2.4.zip, but it does not contain struts-html-el tag libraries Thanks, Ibha - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Newbie Q - Struts expression language taglibs
Ok. Now I know it was in the contrib directory. Thanks, Ibha -Original Message- From: Ibha Gandhi [mailto:[EMAIL PROTECTED] Sent: Friday, June 03, 2005 5:22 PM To: 'Struts Users Mailing List' Subject: Newbie Q - Struts expression language taglibs Hi All, From where can I download struts el tag libraries. I downloaded jakarta-struts-1.2.4.zip, but it does not contain struts-html-el tag libraries Thanks, Ibha - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
standard-1.1.1 expression language not working
Hi to everyone! I have already used taglibs before but I am having some trouble making jstl core 1.1.1 taglib to evaluate expression languages on Tomcat 5.0.27. I have all of the required libraries on WEB-INF/lib/ (jstl, standard, jdbc_2_0_stdext, xalan and xerces). Tomcat does not give any missing taglib handler... so I supposed it finds all of the necessary classes. I am also using Struts and Struts-el taglibs and they are working correctly. Am I missing something? my jsp file: %@ taglib uri=/WEB-INF/tld/struts-html-el.tld prefix=html % %@ taglib uri=/WEB-INF/tld/struts-logic.tld prefix=logic % %@ taglib uri=/WEB-INF/tld/struts-bean.tld prefix=bean % %@ taglib uri=http://java.sun.com/jsp/jstl/fmt; prefix=fmt % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % %@ taglib uri=/WEB-INF/tld/struts-tiles.tld prefix=tiles % %@ taglib uri=/WEB-INF/tld/struts-tiles-el.tld prefix=tiles-el % ... c:set var='a'1/c:setc:out value='${a}'/ (the output is ${a}) ... my web.xml, taglib declaration: taglib taglib-uri/WEB-INF/tld/struts-html.tld/taglib-uri taglib-location/WEB-INF/tld/struts-html.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-html-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-html-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-logic.tld/taglib-uri taglib-location/WEB-INF/tld/struts-logic.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-logic-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-logic-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-bean.tld/taglib-uri taglib-location/WEB-INF/tld/struts-bean.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-bean-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-bean-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-tiles.tld/taglib-uri taglib-location/WEB-INF/tld/struts-tiles.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-tiles-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-tiles-el.tld/taglib-location /taglib taglib taglib-urihttp://java.sun.com/jsp/jstl/fmt/taglib-uri taglib-location/WEB-INF/tld/fmt-1.1.1.tld/taglib-location /taglib taglib taglib-urihttp://java.sun.com/jsp/jstl/core/taglib-uri taglib-location/WEB-INF/tld/c-1.1.1.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/displaytag-el-12.tld/taglib-uri taglib-location/WEB-INF/tld/displaytag-el-12.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/displaytag-12.tld/taglib-uri taglib-location/WEB-INF/tld/displaytag-12.tld/taglib-location /taglib - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: standard-1.1.1 expression language not working
I don't think you're using the set tag properly. Try: c:set var='a' value=1/c:out value='${a}'/ hope it helps, Anna Kerekes From: Pedro Salgado [mailto:[EMAIL PROTECTED] Sent: Mon 20/09/2004 1:15 PM To: Struts Users List Subject: standard-1.1.1 expression language not working Hi to everyone! I have already used taglibs before but I am having some trouble making jstl core 1.1.1 taglib to evaluate expression languages on Tomcat 5.0.27. I have all of the required libraries on WEB-INF/lib/ (jstl, standard, jdbc_2_0_stdext, xalan and xerces). Tomcat does not give any missing taglib handler... so I supposed it finds all of the necessary classes. I am also using Struts and Struts-el taglibs and they are working correctly. Am I missing something? my jsp file: %@ taglib uri=/WEB-INF/tld/struts-html-el.tld prefix=html % %@ taglib uri=/WEB-INF/tld/struts-logic.tld prefix=logic % %@ taglib uri=/WEB-INF/tld/struts-bean.tld prefix=bean % %@ taglib uri=http://java.sun.com/jsp/jstl/fmt; prefix=fmt % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % %@ taglib uri=/WEB-INF/tld/struts-tiles.tld prefix=tiles % %@ taglib uri=/WEB-INF/tld/struts-tiles-el.tld prefix=tiles-el % ... c:set var='a'1/c:setc:out value='${a}'/ (the output is ${a}) ... my web.xml, taglib declaration: taglib taglib-uri/WEB-INF/tld/struts-html.tld/taglib-uri taglib-location/WEB-INF/tld/struts-html.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-html-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-html-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-logic.tld/taglib-uri taglib-location/WEB-INF/tld/struts-logic.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-logic-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-logic-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-bean.tld/taglib-uri taglib-location/WEB-INF/tld/struts-bean.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-bean-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-bean-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-tiles.tld/taglib-uri taglib-location/WEB-INF/tld/struts-tiles.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-tiles-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-tiles-el.tld/taglib-location /taglib taglib taglib-urihttp://java.sun.com/jsp/jstl/fmt/taglib-uri taglib-location/WEB-INF/tld/fmt-1.1.1.tld/taglib-location /taglib taglib taglib-urihttp://java.sun.com/jsp/jstl/core/taglib-uri taglib-location/WEB-INF/tld/c-1.1.1.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/displaytag-el-12.tld/taglib-uri taglib-location/WEB-INF/tld/displaytag-el-12.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/displaytag-12.tld/taglib-uri taglib-location/WEB-INF/tld/displaytag-12.tld/taglib-location /taglib - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Map backed ActionForm, and jstl expression language
Hi Bill, Many thanks for your response, I think I got bogged down the email... It was also late for me, so couldn't put the problem succinctly, but after a few hours sleep it became clearer... What I was trying to do was retrieve a value from the map-backed hash map to get a default value for a drop down list (a html:select tag use), and the property name of the dropdown to be retrieved is taken from another bean... In essence the jsp becomes, td align=left width=25% height=25font class=table bean:define id=ht property=hmOfLists name=dao/ logic:iterate id=element name=ht bean:define id=filterName property=key name=element/ % String props = value( + pageContext.getAttribute(filterName) + ); % html:select property=%= props % html:optionsCollection name=element property=value/ /html:select /logic:iterate /td where dropdown label/values are stored in array lists that are in turn stored in a hashmap contained in the bean dao. The FormBean contains a hashmap that is accessed via setValue/getValue methods. This dynamically produces dropdowns at runtime, with default parameters defined by the mapbacked action form. I was trying to use jstl stuff for dynamically setting the props string and failing... Hope it didn't make your night much later. Rgds, John -Original Message- From: Bill Siggelkow [mailto:[EMAIL PROTECTED] Sent: 02 July 2004 04:49 To: [EMAIL PROTECTED] Subject: Re: Map backed ActionForm, and jstl expression language John, I apologize -- it' late and I am tired but I was having a little trouble following your post ... however, if you have a map-backed form (property) that you want to expose to JSTL you will need to expose the Map itself in a getter. Map getValuesMap() { return values; } Then you can access the values by key in JSTL as c:out value=${myForm.valuesMap.theKey}/ ... translates to myForm.getValuesMap().get(theKey); or the key can be dynamic ... c:set var=keyVal value=foo/ c:out value=${myForm.valuesMap[keyVal]}/ ... translates to myForm.getValuesMap().get(foo); HTH ... Bill Siggelkow John Martin wrote: Hi all, Any help on the following problem would be most appreciated. What i am trying to do is produce a report of data in tabular form with filters that will reduce the report set. There can be 100's of different reports but by passing in a report id to a database the query, filters, columns and row values can be determined. So i use a map backed action form for the filter property and there values, this contains the methods public void setValue(String key, Object value) { values.put(key, value); } public Object getValue(String key) { return values.get(key); } For example, i want the first filter to have a value of 1, so i setValue(filter1,1) and the second filter to be value 2 (setValue(filter1,1)). Now i populate another bean with the filter labels and values, that gets stored in the request. These are filter lists are stored as array lists in a hashmap with the the key, being the filter property, in this case filter1 and filter2. So in the jsp i write c:forEach items=${dao.hmOfLists} var=list c:set var=props value=${list.key}/ c:set var=values value=${list.value}/ html-el:select property=${props} value= html:options collection=values property=value labelProperty=label/ /html-el:select /c:forEach this gets me the all the filters that have been stored in the hashmap from the object dao via the property hmOfLists, with the key in the hashmap being the filter property. However, i want to set the defaults on the filters via the map backed action form, but if i write html-el:select property=${props} , i get an error of No getter method available for property filter2..etc. So i try an access the value, in the html-el:select using the expression value=${testForm.props}, but this shouldn't (and doesn't work) as label is actually the variable props from the hashmap, not the property props from the testForm. How i can i make it use the var props instead of the string literal, in order to determine the property to retrieve from the map based action form ? Thanks, John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Map backed ActionForm, and jstl expression language
Hi all, Any help on the following problem would be most appreciated. What i am trying to do is produce a report of data in tabular form with filters that will reduce the report set. There can be 100's of different reports but by passing in a report id to a database the query, filters, columns and row values can be determined. So i use a map backed action form for the filter property and there values, this contains the methods public void setValue(String key, Object value) { values.put(key, value); } public Object getValue(String key) { return values.get(key); } For example, i want the first filter to have a value of 1, so i setValue(filter1,1) and the second filter to be value 2 (setValue(filter1,1)). Now i populate another bean with the filter labels and values, that gets stored in the request. These are filter lists are stored as array lists in a hashmap with the the key, being the filter property, in this case filter1 and filter2. So in the jsp i write c:forEach items=${dao.hmOfLists} var=list c:set var=props value=${list.key}/ c:set var=values value=${list.value}/ html-el:select property=${props} value= html:options collection=values property=value labelProperty=label/ /html-el:select /c:forEach this gets me the all the filters that have been stored in the hashmap from the object dao via the property hmOfLists, with the key in the hashmap being the filter property. However, i want to set the defaults on the filters via the map backed action form, but if i write html-el:select property=${props} , i get an error of No getter method available for property filter2..etc. So i try an access the value, in the html-el:select using the expression value=${testForm.props}, but this shouldn't (and doesn't work) as label is actually the variable props from the hashmap, not the property props from the testForm. How i can i make it use the var props instead of the string literal, in order to determine the property to retrieve from the map based action form ? Thanks, John
Re: Map backed ActionForm, and jstl expression language
John, I apologize -- it' late and I am tired but I was having a little trouble following your post ... however, if you have a map-backed form (property) that you want to expose to JSTL you will need to expose the Map itself in a getter. Map getValuesMap() { return values; } Then you can access the values by key in JSTL as c:out value=${myForm.valuesMap.theKey}/ ... translates to myForm.getValuesMap().get(theKey); or the key can be dynamic ... c:set var=keyVal value=foo/ c:out value=${myForm.valuesMap[keyVal]}/ ... translates to myForm.getValuesMap().get(foo); HTH ... Bill Siggelkow John Martin wrote: Hi all, Any help on the following problem would be most appreciated. What i am trying to do is produce a report of data in tabular form with filters that will reduce the report set. There can be 100's of different reports but by passing in a report id to a database the query, filters, columns and row values can be determined. So i use a map backed action form for the filter property and there values, this contains the methods public void setValue(String key, Object value) { values.put(key, value); } public Object getValue(String key) { return values.get(key); } For example, i want the first filter to have a value of 1, so i setValue(filter1,1) and the second filter to be value 2 (setValue(filter1,1)). Now i populate another bean with the filter labels and values, that gets stored in the request. These are filter lists are stored as array lists in a hashmap with the the key, being the filter property, in this case filter1 and filter2. So in the jsp i write c:forEach items=${dao.hmOfLists} var=list c:set var=props value=${list.key}/ c:set var=values value=${list.value}/ html-el:select property=${props} value= html:options collection=values property=value labelProperty=label/ /html-el:select /c:forEach this gets me the all the filters that have been stored in the hashmap from the object dao via the property hmOfLists, with the key in the hashmap being the filter property. However, i want to set the defaults on the filters via the map backed action form, but if i write html-el:select property=${props} , i get an error of No getter method available for property filter2..etc. So i try an access the value, in the html-el:select using the expression value=${testForm.props}, but this shouldn't (and doesn't work) as label is actually the variable props from the hashmap, not the property props from the testForm. How i can i make it use the var props instead of the string literal, in order to determine the property to retrieve from the map based action form ? Thanks, John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]