You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Raymaker, Dora" <do...@xo.com> on 2003/02/20 00:06:07 UTC

newbie: using jsp custom tags in tiles content

Greetings, I am building a front-end UI for a collection of applications
that give customers access to reporting and self-service utilities.  The
java developer has given me taglibs for these utilities.  What I want to
avoid is a monstrous, ever-bloating directory full of dozens of separate jsp
files for each piece of application functionality.  To that end, I have been
experimenting with tiles, and using definitions as forwards, all of which I
have working nicely.

 

My idea is to pass body text for each action in the definitions as plain
xhtml... for example:

 

            <put name="mainBody" value="

                               <p>Here is some body text</p>

                                " />

 

This works great - for the plain old xhtml anyway.  BUT when I include a jsp
custom tag in the value of my body text, the jsp tag renders literally in
the page that's displayed to the viewer instead of being replaced by the
result of the back-end code behind the tag.  

 

So this, for example, in the tiles-def.xml:

 

            <put name="mainBody" value="

                               <p>some text, and then a tag</p>

                               <CustomTag:loginMessage startHTML=\"<p>\"
endHTML=\"</p>\">

                                   <p>some more text</p>

                               </CustomTag:loginMessage>

                               "/>

 

With this in my template:

 

                <tiles:getAsString name="mainBody" />

 

Renders in the browser as this (source):

 

              <p>some text, and then a tag</p>

       <CustomTag:loginMessage startHTML="<p>" endHTML="</p>">
         <p>some more text</p>
       </CustomTag:loginMessage>

 

instead of displaying the return from CustomTag:loginMessage.  At this point
I'm thinking it probably has something to do with the order in which things
are processed, or with how tiles:getAsString works, but I'm not really sure.

 

So my questions are:

            1.  is it possible to include jsp custom tags as values in tiles
definitions like this?  If so, what am I doing wrong?

            2.  if it is not possible, what are the alternatives?  I can't
be the only person who's wanted this kind of functionality...

            3.  is there a better way to do this?

 

I am not a java/struts programmer (I do mostly perl/mason), so any
advice/information would be much appreciated!

 

-ladyD

dora.raymaker@xo.com <ma...@xo.com> 

 


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


Re: newbie: using jsp custom tags in tiles content

Posted by Cedric Dumoulin <ce...@apache.org>.
  Hi,

  The jsp tags are interpreted by the webserver when the jsp page is 
accessed. They are interpreted only if they are physically present in 
the page. When you do something like: <tiles:getAsString ...> or 
<tiles:insert ...> you invoke a tag that fetch some characters in the 
output stream that is sent to the client. The characters aren't 
interpreted by the server, so if they form a tag, it will not be 
interpreted.

     Cedric

  Also check intermixed response below.

Raymaker, Dora wrote:

>Greetings, I am building a front-end UI for a collection of applications
>that give customers access to reporting and self-service utilities.  The
>java developer has given me taglibs for these utilities.  What I want to
>avoid is a monstrous, ever-bloating directory full of dozens of separate jsp
>files for each piece of application functionality.  To that end, I have been
>experimenting with tiles, and using definitions as forwards, all of which I
>have working nicely.
>
> 
>
>My idea is to pass body text for each action in the definitions as plain
>xhtml... for example:
>
> 
>
>            <put name="mainBody" value="
>
>                               <p>Here is some body text</p>
>
>                                " />
>
> 
>
>This works great - for the plain old xhtml anyway.  BUT when I include a jsp
>custom tag in the value of my body text, the jsp tag renders literally in
>the page that's displayed to the viewer instead of being replaced by the
>result of the back-end code behind the tag.  
>
> 
>
>So this, for example, in the tiles-def.xml:
>
> 
>
>            <put name="mainBody" value="
>
>                               <p>some text, and then a tag</p>
>
>                               <CustomTag:loginMessage startHTML=\"<p>\"
>endHTML=\"</p>\">
>
>                                   <p>some more text</p>
>
>                               </CustomTag:loginMessage>
>
>                               "/>
>
> 
>
>With this in my template:
>
> 
>
>                <tiles:getAsString name="mainBody" />
>
> 
>
>Renders in the browser as this (source):
>
> 
>
>              <p>some text, and then a tag</p>
>
>       <CustomTag:loginMessage startHTML="<p>" endHTML="</p>">
>         <p>some more text</p>
>       </CustomTag:loginMessage>
>
> 
>
>instead of displaying the return from CustomTag:loginMessage.  At this point
>I'm thinking it probably has something to do with the order in which things
>are processed, or with how tiles:getAsString works, but I'm not really sure.
>
> 
>
>So my questions are:
>
>            1.  is it possible to include jsp custom tags as values in tiles
>definitions like this?  If so, what am I doing wrong?
>
  No, it is not possible. See the explanation in the header

>
>            2.  if it is not possible, what are the alternatives?  I can't
>be the only person who's wanted this kind of functionality...
>
  Define a jsp file containing the tags. Insert this file instead of 
writing the content directly in the config file. This will not lead to 
so many files.
  Usually you will have one file per existing tiles, and these files can 
be reused several time (like the header, footer, ...)

>
>            3.  is there a better way to do this?
>
> 
>
>I am not a java/struts programmer (I do mostly perl/mason), so any
>advice/information would be much appreciated!
>
> 
>
>-ladyD
>
>dora.raymaker@xo.com <ma...@xo.com> 
>
> 
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>  
>


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