You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vams <vm...@charter.net> on 2004/08/18 08:35:53 UTC
Extending a component.
Hi all,
I been messing around w/ Tapestry for a few weeks now, and I just can't wrap
my mind around it. Anyway, can anyone tell or push me in the right direction
on how to extend a component?
To be specific, I want to extend the Conditional component so that it takes in
a type of Object. Then calls a boolean method that uses assigned Object to
determine whether or not to render the enclosed html like the normal
Conditional does.
Or better yet, is there anyway to pass in a parameter to the calling method?
Like how can I access:
public class MyClass{
...
public boolean myMethod(Object data){
...
}
...
}
I am really sorry if this is so basic that it angers you, but I just can't
seem to connect the dots.
Thank you,
Vamsi Mudrageda
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Extending a component.
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Aug 18, 2004, at 11:24 AM, Vams wrote:
> Thank you for the quick reply, unfortunately, I don't know exactly how
> to use
> your advice to my specific task. Let me explain my specific
> situation. I
> want to give a specialized menu based on current user privileges.
Given what I've seen of your goal, I think a lightweight custom
"conditional" component would benefit you...
> So I set up a private class of Privileges and made public final
> objects of it.
> Like Privilege.ROOT... The Privilege class has a static method that
> takes in
> a Privilege and the user's clearance and returns if said clearance has
> the
> Privilege.
>
> In my visit class, I added
> public boolean hasClearance(Privilege privilege)
>
> So, each section of the menu sees if that user's clearance has a
> specific
> Privilege and only renders if so.
>
> I had originally just used
> "ognl:page.visit.hasClearance(org.path.to.package.Privilege.ROOT)" in a
> conditional, and although it made logical sense, tapestry or ognl
> didn't like
> the whole org.path.... part.
>
> So now that you know the whole story, could you please be kind enough
> to give
> me your advice again?
Jimmi gave you the syntax to get at statics, so that should help. But
it would be much cleaner to say:
<if jwcid="@HasPrivilege"
privilege="ognl:@org.path.to.package.Privilege.ROOT">
...
</if>
or perhaps even privilege="ROOT" and let the custom @HasPrivilege
component do the lookup reflectively. I opt for the least amount of
explicit coding as possible, personally.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Extending a component.
Posted by Vams <vm...@charter.net>.
Eric,
Thank you for the quick reply, unfortunately, I don't know exactly how to use
your advice to my specific task. Let me explain my specific situation. I
want to give a specialized menu based on current user privileges.
So I set up a private class of Privileges and made public final objects of it.
Like Privilege.ROOT... The Privilege class has a static method that takes in
a Privilege and the user's clearance and returns if said clearance has the
Privilege.
In my visit class, I added
public boolean hasClearance(Privilege privilege)
So, each section of the menu sees if that user's clearance has a specific
Privilege and only renders if so.
I had originally just used
"ognl:page.visit.hasClearance(org.path.to.package.Privilege.ROOT)" in a
conditional, and although it made logical sense, tapestry or ognl didn't like
the whole org.path.... part.
So now that you know the whole story, could you please be kind enough to give
me your advice again?
Thank you.
Vamsi Mudrageda
> We should look to aggregation first, rather than extension. Often that
> solves the problem cleaner. I'll demonstrate...
>
> > To be specific, I want to extend the Conditional component so that it
> > takes in
> > a type of Object. Then calls a boolean method that uses assigned
> > Object to
> > determine whether or not to render the enclosed html like the normal
> > Conditional does.
> >
> > Or better yet, is there anyway to pass in a parameter to the calling
> > method?
> > Like how can I access:
> >
> > public class MyClass{
> > ...
> > public boolean myMethod(Object data){
> > ...
> > }
> > ...
> > }
> >
>
> MyCondition.jwc (snippet):
>
> <parameter name="myobj" type="com.whatever.MyClass" required="yes"/>
>
> MyCondition.html (complete):
>
> <if jwcid="@Condition" condition="ognl:myobj.myMethod">
> <span jwcid="@RenderBody"/>
> </if>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
How to use property file with
Posted by damar thapa <da...@yahoo.com>.
Hi all,
I am trying to send individual page title to Border component (from Home, Credo, Legal to Border, in tutorial application!), using .properties file and <message-binding. I have few newbie questions:
(1) I create Home.properties, Legal.properties etc... files with relevant key/value, and put in WEB-INF directory. Am I corrent?
(2) What is the format of .properties key/values in the file?
(3) Do I have to specify some where in .page file regarding the properties file?
Any pointers to relevant documentation/tips would be highly appreciated.
Damar
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Extending a component.
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Aug 18, 2004, at 2:35 AM, Vams wrote:
> I been messing around w/ Tapestry for a few weeks now, and I just
> can't wrap
> my mind around it. Anyway, can anyone tell or push me in the right
> direction
> on how to extend a component?
We should look to aggregation first, rather than extension. Often that
solves the problem cleaner. I'll demonstrate...
> To be specific, I want to extend the Conditional component so that it
> takes in
> a type of Object. Then calls a boolean method that uses assigned
> Object to
> determine whether or not to render the enclosed html like the normal
> Conditional does.
>
> Or better yet, is there anyway to pass in a parameter to the calling
> method?
> Like how can I access:
>
> public class MyClass{
> ...
> public boolean myMethod(Object data){
> ...
> }
> ...
> }
>
> I am really sorry if this is so basic that it angers you, but I just
> can't
> seem to connect the dots.
MyCondition.jwc (snippet):
<parameter name="myobj" type="com.whatever.MyClass" required="yes"/>
MyCondition.html (complete):
<if jwcid="@Condition" condition="ognl:myobj.myMethod">
<span jwcid="@RenderBody"/>
</if>
Disclaimer: I'm typing this in my e-mail editor off the cuff, so I may
have a typo. Also note I like to use the made-up <if> tag when I use
@Condition.
Hope that helps. At the very least, I hope it helps show that
extending a component is generally not what folks really should do.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org