You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by GRENET David <da...@renault.com> on 2002/01/22 14:48:03 UTC

'Method call' taglib

Hi everybody,

I just subscribed the list, so please excuse me if what I'm writing has already been discussed.
Using struts, I felt the need for a "bean:write"-like tag that could display not only properties but the result of any method call (with its parameters and all). Where 'bean:write' would allow  :
<bean:write name="user" property="fullName"/> instead of <%=myUserBean.getFullName()%>
,the 'bean:write'-like tag would allow :
<bean:writeMethod name="user" method="isSameAge(user2)"/>  or <bean:writeMethod name="user" method="isAge(42)"/> instead of <%=myUserBean.isSameAge(myOtherUserBean)%> or <%=myUserBean.isAge(42)%>

Thus, I made a very simple version of such a tag where you can give as parameter  : struts-beans (=belonging to one of the 'scope' collections), strings and numbers. My question is : do you plan to have such a tag in a future release ? Do you already have it ? Or is the method call idea just not what beans are for ?

Thanks for your answer(s).

David


Re: 'Method call' taglib

Posted by Ted Husted <hu...@apache.org>.
Struts advocates MVC, but Taglibs (and the JSTL) -- not so much :)

Velocity templates also let you do a lot of things that standard
JavaBeans do not. 

http://husted.com/struts/resources/velstruts.zip



GRENET David wrote:
> 
> You're right, my examples are obviously not MVC-compliant. And I fear that
> so might be my *real* example, the one I needed the writeMethod tag for, far
> too complicated to explain here ;) .
> Seeing there was no 'writeMethod' tag in the JSTL made me suspicious about
> my architecture but I still hoped that was a flaw on your side (I mean the
> jakarta project)... As to my taglib, it doesn't deserve to be hosted (and I
> thought so even when it was still potentially MVC-compliant) : I just wrote
> a simple "beta" version of it, hoping (once again) that you would have a
> real version for me.
> Thanks for your nice answer, anyway.
> 
> David
> 
> ----- Original Message -----
> From: "Ted Husted" <hu...@apache.org>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Tuesday, January 22, 2002 3:17 PM
> Subject: Re: 'Method call' taglib
> 
> > Struts is designed to encourage a MVC-type architecture, and a tag like
> > this goes against the MVC grain :)
> >
> > Generally, the type of facts you are exposing here is something that
> > many people would tend to determined in the Action, and then pass along
> > to the presentation page, ready for output. The presentation page
> > shouldn't really care if the users are the same age or a particular age,
> > but be focussed on what it suppose to be output given the state behind
> > these facts.
> >
> > So the bean might have a property like usersSameAge, where the Action
> > had already compared user and user2. Or userMiddleAge, where the Action
> > had already done the math.
> >
> > If you'd like to have tag like this hosted somewhere, you might consider
> > taking a look at the Jakarta Taglibs subprojects. Most of our bean tags
> > could actually be hosted there, especially now that bean-util is in the
> > Commons.
> >
> > It's also important to keep an eye on the JSTL for future trends, which
> > is also hosted at Taglibs.
> >
> > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > -- Java Web Development with Struts.
> > -- Tel +1 585 737-3463.
> > -- Web http://www.husted.com/struts/
> >
> >
> > GRENET David wrote:
> > >
> > > Hi everybody,
> > >
> > > I just subscribed the list, so please excuse me if what I'm writing has
> already been discussed.
> > > Using struts, I felt the need for a "bean:write"-like tag that could
> display not only properties but the result of any method call (with its
> parameters and all). Where 'bean:write' would allow  :
> > > <bean:write name="user" property="fullName"/> instead of
> <%=myUserBean.getFullName()%>
> > > ,the 'bean:write'-like tag would allow :
> > > <bean:writeMethod name="user" method="isSameAge(user2)"/>  or
> <bean:writeMethod name="user" method="isAge(42)"/> instead of
> <%=myUserBean.isSameAge(myOtherUserBean)%> or <%=myUserBean.isAge(42)%>
> > >
> > > Thus, I made a very simple version of such a tag where you can give as
> parameter  : struts-beans (=belonging to one of the 'scope' collections),
> strings and numbers. My question is : do you plan to have such a tag in a
> future release ? Do you already have it ? Or is the method call idea just
> not what beans are for ?
> > >
> > > Thanks for your answer(s).
> > >
> > > David
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: 'Method call' taglib

Posted by Fernando Esteban Barril Otero <fe...@visionnaire.com.br>.
Just a comment about the JSTL support to method calls. As there is
no explicity information that you could invoke methods, it can be
done. Try:

<%@ taglib prefix="c" uri=http://java.sun.com/jstl/ea/core %>

<c:expr value="$name.toLowerCase()"/>

(assuming that you have a string "name" attribute in scope).

I'm not not saying that method calls should be done, just
showing that can be archieved with JSTL.

Fernando


----- Original Message -----
From: "GRENET David" <da...@renault.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Tuesday, January 22, 2002 1:32 PM
Subject: Re: 'Method call' taglib


> You're right, my examples are obviously not MVC-compliant. And I fear that
> so might be my *real* example, the one I needed the writeMethod tag for,
far
> too complicated to explain here ;) .
> Seeing there was no 'writeMethod' tag in the JSTL made me suspicious about
> my architecture but I still hoped that was a flaw on your side (I mean the
> jakarta project)... As to my taglib, it doesn't deserve to be hosted (and
I
> thought so even when it was still potentially MVC-compliant) : I just
wrote
> a simple "beta" version of it, hoping (once again) that you would have a
> real version for me.
> Thanks for your nice answer, anyway.
>
> David


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: 'Method call' taglib

Posted by GRENET David <da...@renault.com>.
You're right, my examples are obviously not MVC-compliant. And I fear that
so might be my *real* example, the one I needed the writeMethod tag for, far
too complicated to explain here ;) .
Seeing there was no 'writeMethod' tag in the JSTL made me suspicious about
my architecture but I still hoped that was a flaw on your side (I mean the
jakarta project)... As to my taglib, it doesn't deserve to be hosted (and I
thought so even when it was still potentially MVC-compliant) : I just wrote
a simple "beta" version of it, hoping (once again) that you would have a
real version for me.
Thanks for your nice answer, anyway.

David

----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Tuesday, January 22, 2002 3:17 PM
Subject: Re: 'Method call' taglib


> Struts is designed to encourage a MVC-type architecture, and a tag like
> this goes against the MVC grain :)
>
> Generally, the type of facts you are exposing here is something that
> many people would tend to determined in the Action, and then pass along
> to the presentation page, ready for output. The presentation page
> shouldn't really care if the users are the same age or a particular age,
> but be focussed on what it suppose to be output given the state behind
> these facts.
>
> So the bean might have a property like usersSameAge, where the Action
> had already compared user and user2. Or userMiddleAge, where the Action
> had already done the math.
>
> If you'd like to have tag like this hosted somewhere, you might consider
> taking a look at the Jakarta Taglibs subprojects. Most of our bean tags
> could actually be hosted there, especially now that bean-util is in the
> Commons.
>
> It's also important to keep an eye on the JSTL for future trends, which
> is also hosted at Taglibs.
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Java Web Development with Struts.
> -- Tel +1 585 737-3463.
> -- Web http://www.husted.com/struts/
>
>
> GRENET David wrote:
> >
> > Hi everybody,
> >
> > I just subscribed the list, so please excuse me if what I'm writing has
already been discussed.
> > Using struts, I felt the need for a "bean:write"-like tag that could
display not only properties but the result of any method call (with its
parameters and all). Where 'bean:write' would allow  :
> > <bean:write name="user" property="fullName"/> instead of
<%=myUserBean.getFullName()%>
> > ,the 'bean:write'-like tag would allow :
> > <bean:writeMethod name="user" method="isSameAge(user2)"/>  or
<bean:writeMethod name="user" method="isAge(42)"/> instead of
<%=myUserBean.isSameAge(myOtherUserBean)%> or <%=myUserBean.isAge(42)%>
> >
> > Thus, I made a very simple version of such a tag where you can give as
parameter  : struts-beans (=belonging to one of the 'scope' collections),
strings and numbers. My question is : do you plan to have such a tag in a
future release ? Do you already have it ? Or is the method call idea just
not what beans are for ?
> >
> > Thanks for your answer(s).
> >
> > David
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: 'Method call' taglib

Posted by Ted Husted <hu...@apache.org>.
Struts is designed to encourage a MVC-type architecture, and a tag like
this goes against the MVC grain :)

Generally, the type of facts you are exposing here is something that
many people would tend to determined in the Action, and then pass along
to the presentation page, ready for output. The presentation page
shouldn't really care if the users are the same age or a particular age,
but be focussed on what it suppose to be output given the state behind
these facts. 

So the bean might have a property like usersSameAge, where the Action
had already compared user and user2. Or userMiddleAge, where the Action
had already done the math. 

If you'd like to have tag like this hosted somewhere, you might consider
taking a look at the Jakarta Taglibs subprojects. Most of our bean tags
could actually be hosted there, especially now that bean-util is in the
Commons.

It's also important to keep an eye on the JSTL for future trends, which
is also hosted at Taglibs.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


GRENET David wrote:
> 
> Hi everybody,
> 
> I just subscribed the list, so please excuse me if what I'm writing has already been discussed.
> Using struts, I felt the need for a "bean:write"-like tag that could display not only properties but the result of any method call (with its parameters and all). Where 'bean:write' would allow  :
> <bean:write name="user" property="fullName"/> instead of <%=myUserBean.getFullName()%>
> ,the 'bean:write'-like tag would allow :
> <bean:writeMethod name="user" method="isSameAge(user2)"/>  or <bean:writeMethod name="user" method="isAge(42)"/> instead of <%=myUserBean.isSameAge(myOtherUserBean)%> or <%=myUserBean.isAge(42)%>
> 
> Thus, I made a very simple version of such a tag where you can give as parameter  : struts-beans (=belonging to one of the 'scope' collections), strings and numbers. My question is : do you plan to have such a tag in a future release ? Do you already have it ? Or is the method call idea just not what beans are for ?
> 
> Thanks for your answer(s).
> 
> David

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>