You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Raley <jo...@moonlight.com> on 2001/02/13 01:55:56 UTC

"Eval" tag?

Hi,

Is there a tag (in struts or elsewhere) that will evaluate its body into
a String that can be squirreled away for later use?

Thanks,
John


Re: "Eval" tag?

Posted by John Raley <jo...@moonlight.com>.
Thanks for the pointer.  I don't quite follow why useBean is necessary in
your example.

I wrote my own tag for this.  It's very simple - it's just a body tag that
does: pageContext.setAttribute(id, getBodyContent().getString()).  It's
useful in those cases where you want to nest tags but can't.  Instead of:

<x:tag1 attr1='<x:tag2/>'/>

you do:
<y:eval id='anId'><x:tag2/></y:eval>
<x:tag1 attr1='<%= (String) pageContext.findAttribute("anId") %>'/>

Providing a TEI class would shorten this a lot, but I haven't gotten around
to it yet...

Pierre Delisle wrote:

> John Raley wrote:
>
> > Is there a tag (in struts or elsewhere) that will evaluate its body into
> > a String that can be squirreled away for later use?
>
> John,
>
> I'm just finishing implementing a tag library that may help you out.
> I shall submit it to jakarta-taglibs by the beginning of next week.
>
> My tentative name for the tag library is "IOAdapter".
> Its goal is to provide a generic mechanism by which a variety of
> input sources can be copied to a variety of output sinks, with
> an optional transformation applied on the input source before
> it is copied over.
>
> In your case, it would look something like the following:
>
>   <jsp:useBean id="tmp" class="java.lang.String"/>
>   <x:ioa outBean="tmp">
>     ... content ...
>   </x:ioa>
>
> If an "in" argument is not specified in the 'ioa' tag, input
> comes by default from the tag's body content.
>
> Would that fit your requirements?
>
>     -- Pierre


Re: "Eval" tag?

Posted by Incze Lajos <in...@mail.matav.hu>.
John Raley wrote:

> Is there a tag (in struts or elsewhere) that will evaluate its body into
> a String that can be squirreled away for later use?

> John,

Actually "template:put" makes something you want. If you place content
in the put element's body, you can recover it with a template:get element
by it's name. In the body you can use many known constructs (bean:* etc)
to setup your content.                                            incze

Re: "Eval" tag?

Posted by Pierre Delisle <pi...@sun.com>.

John Raley wrote:

> Is there a tag (in struts or elsewhere) that will evaluate its body into
> a String that can be squirreled away for later use?

John,

I'm just finishing implementing a tag library that may help you out.
I shall submit it to jakarta-taglibs by the beginning of next week.

My tentative name for the tag library is "IOAdapter".
Its goal is to provide a generic mechanism by which a variety of 
input sources can be copied to a variety of output sinks, with
an optional transformation applied on the input source before
it is copied over.

In your case, it would look something like the following:

  <jsp:useBean id="tmp" class="java.lang.String"/>
  <x:ioa outBean="tmp">
    ... content ...
  </x:ioa>

If an "in" argument is not specified in the 'ioa' tag, input 
comes by default from the tag's body content.

Would that fit your requirements?

    -- Pierre