hashmaps and hash tables in JSPs
HI, I have a hastable or Hashmap of permissions that I want to use in my JSP pages to determine what info is displayed to the user. For instance I want to have the following logic if permissionsHashMap has key Manage Countires then display this if permissionsHashMap has key Manage Logins then display this etc Is there a way to do this with the struts logic tags? thanks Jordan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hashmaps and hash tables in JSPs
logic:notEmpty name=session property=permissionsHashMap(Manage Countries) ... User has the Manage Countries permission /logic:notEmpty Or with JSTL c:if test=${permissionsHashMap['Manage Countries']} ... User has the Manage Countries permission /c:if -Original Message- From: Jordan Thomas [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 9:02 AM To: Struts User List Subject: hashmaps and hash tables in JSPs HI, I have a hastable or Hashmap of permissions that I want to use in my JSP pages to determine what info is displayed to the user. For instance I want to have the following logic if permissionsHashMap has key Manage Countires then display this if permissionsHashMap has key Manage Logins then display this etc Is there a way to do this with the struts logic tags? thanks Jordan - 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: hashmaps and hash tables in JSPs
You might looks at useing roles to acomplish this external to the JSP, AKA leave to logic out of the view, but otherwise a Hashmap can be checked as a map backed property like so.. logic:present name='permissionsHashMap' property='Manage Countires' although I don't know how it will handle spaces in the property names.. On Mon, 3 Feb 2003 15:02:02 +0100 Jordan Thomas [EMAIL PROTECTED] wrote: HI, I have a hastable or Hashmap of permissions that I want to use in my JSP pages to determine what info is displayed to the user. For instance I want to have the following logic if permissionsHashMap has key Manage Countires then display this if permissionsHashMap has key Manage Logins then display this etc Is there a way to do this with the struts logic tags? thanks Jordan - 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: hashmaps and hash tables in JSPs
if permissionsHashMap has key Manage Countires then display this if permissionsHashMap has key Manage Logins then display this In the interests of hiding the implementation (hashmap) from the presentation, would it perhaps be a better strategy to maybe expose a value object full of booleans, and then just have traditional true/false logic, like this? logic:equal bean=Permissions property=manageCountries value=true display this... /logic:equal and so on? That way you've only really exposed minimal business logic, enough to tell your presentation layer what to display. If you expose a hashMap and then later put it into an array or vector or something, you're in trouble. If you wanted to you could take that one step more and create your own Permissions custom tag that might act like this: security:Permission op=manageCountries ...display this... /security:Permission Which completely hides everything, allowing you to even look up permissions on the fly if you really wanted to. Duane etc Is there a way to do this with the struts logic tags? thanks Jordan - 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: hashmaps and hash tables in JSPs
Woops, that logic:notEmpty example isn't right! Not sure how you'd do it with logic:notEmpty without the permissionsHashMap being a property of another bean, say permissionsBean. In that case it would look like this: logic:notEmpty name=permissionsBean property=permissionsHashMap(Manage Countries) ... User has the Manage Countries permission /logic:notEmpty -Original Message- From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 9:19 AM To: Struts Users Mailing List Subject: RE: hashmaps and hash tables in JSPs logic:notEmpty name=session property=permissionsHashMap(Manage Countries) ... User has the Manage Countries permission /logic:notEmpty Or with JSTL c:if test=${permissionsHashMap['Manage Countries']} ... User has the Manage Countries permission /c:if -Original Message- From: Jordan Thomas [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 9:02 AM To: Struts User List Subject: hashmaps and hash tables in JSPs HI, I have a hastable or Hashmap of permissions that I want to use in my JSP pages to determine what info is displayed to the user. For instance I want to have the following logic if permissionsHashMap has key Manage Countires then display this if permissionsHashMap has key Manage Logins then display this etc Is there a way to do this with the struts logic tags? thanks Jordan - 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]
Re: hashmaps and hash tables in JSPs
you can access hashmap values by name without the map(val) notation.. this helps alot if you don't want to wrap the mapback property in a bean. for example.. logic:present name='wraperBean' property='map(val)' can be done with the same map but without the wrapper bean like.. logic:present name='map' property='val' I'm not sure if it's suppoed to work with way but it does, at least in 1.1b2 Matt, On Mon, 3 Feb 2003 09:34:30 -0500 Jerome Jacobsen [EMAIL PROTECTED] wrote: Woops, that logic:notEmpty example isn't right! Not sure how you'd do it with logic:notEmpty without the permissionsHashMap being a property of another bean, say permissionsBean. In that case it would look like this: logic:notEmpty name=permissionsBean property=permissionsHashMap(Manage Countries) ... User has the Manage Countries permission /logic:notEmpty -Original Message- From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 9:19 AM To: Struts Users Mailing List Subject: RE: hashmaps and hash tables in JSPs logic:notEmpty name=session property=permissionsHashMap(Manage Countries) ... User has the Manage Countries permission /logic:notEmpty Or with JSTL c:if test=${permissionsHashMap['Manage Countries']} ... User has the Manage Countries permission /c:if -Original Message- From: Jordan Thomas [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 9:02 AM To: Struts User List Subject: hashmaps and hash tables in JSPs HI, I have a hastable or Hashmap of permissions that I want to use in my JSP pages to determine what info is displayed to the user. For instance I want to have the following logic if permissionsHashMap has key Manage Countires then display this if permissionsHashMap has key Manage Logins then display this etc Is there a way to do this with the struts logic tags? thanks Jordan - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]