Custom Property Tag

2009-10-06 Thread Mike Baranski
I need to show certain fields to certain users based on permissions
(per-user).  I was going to create a custom s:property tag, which would
access an IUser object on the value stack.  In the tag, it will do:

If (getUser().canAccess('property_name'))
Then
Render the tag/value
Else
Render nothing

I cannot figure out how exactly to get the user object on the value stack,
and which file contains the property tag implementation.  Could someone
suggest where to start?

Thanks,
Mike.



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



Re: Custom Property Tag

2009-10-06 Thread Wes Wannemacher
I did something similar, but I used s:if as an example. Rather than
show or not show in a s:property tag-like setup, i felt like s:if did
the job much better. If you want an example, check out

core/src/main/java/org/apache/struts2/views/jsp/IfTag.java
core/src/main/java/org/apache/struts2/views/freemarker/tags/IfModel.java
core/src/main/java/org/apache/struts2/components/If.java

Then, check out the pom.xml file for a clue how to use the annotations
you'll see in there to generate a TLD file for the tag. Also, the
views/freemarker thing isn't necessary, but if you plan to use
Freemarker, you'll have to create a freemarker template manager (which
is pretty simple, check the source of the bean that the
struts-default.xml defines for an example).

-Wes

On Tue, Oct 6, 2009 at 10:36 AM, Mike Baranski
list-subscripti...@secmgmt.com wrote:
 I need to show certain fields to certain users based on permissions
 (per-user).  I was going to create a custom s:property tag, which would
 access an IUser object on the value stack.  In the tag, it will do:

 If (getUser().canAccess('property_name'))
 Then
 Render the tag/value
 Else
 Render nothing

 I cannot figure out how exactly to get the user object on the value stack,
 and which file contains the property tag implementation.  Could someone
 suggest where to start?

 Thanks,
 Mike.



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





-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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



RE: Custom Property Tag

2009-10-06 Thread Mike Baranski
Thanks Wes!  That's exactly what I needed to get started.

M.

-Original Message-
From: Wes Wannemacher [mailto:w...@wantii.com]
Sent: Tuesday, October 06, 2009 11:33 AM
To: Struts Users Mailing List
Subject: Re: Custom Property Tag

I did something similar, but I used s:if as an example. Rather than
show or not show in a s:property tag-like setup, i felt like s:if did
the job much better. If you want an example, check out

core/src/main/java/org/apache/struts2/views/jsp/IfTag.java
core/src/main/java/org/apache/struts2/views/freemarker/tags/IfModel.java
core/src/main/java/org/apache/struts2/components/If.java

Then, check out the pom.xml file for a clue how to use the annotations
you'll see in there to generate a TLD file for the tag. Also, the
views/freemarker thing isn't necessary, but if you plan to use
Freemarker, you'll have to create a freemarker template manager (which
is pretty simple, check the source of the bean that the
struts-default.xml defines for an example).

-Wes

On Tue, Oct 6, 2009 at 10:36 AM, Mike Baranski
list-subscripti...@secmgmt.com wrote:
 I need to show certain fields to certain users based on permissions
 (per-user).  I was going to create a custom s:property tag, which
would
 access an IUser object on the value stack.  In the tag, it will do:

 If (getUser().canAccess('property_name'))
 Then
 Render the tag/value
 Else
 Render nothing

 I cannot figure out how exactly to get the user object on the value
stack,
 and which file contains the property tag implementation.  Could
someone
 suggest where to start?

 Thanks,
 Mike.



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





--
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


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