You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by doktora v <do...@gmail.com> on 2007/11/16 21:36:54 UTC

tiles1 - tiles2 migration: insert an action

In tiles1 I used to be able to do:

<tiles:insert page="/someaction.do">
</tiles:insert>

How, if at all, is this possible in in Tiles2, i.e. inserting the
result of an action as a tile?

Re: tiles1 - tiles2 migration: insert an action

Posted by doktora v <do...@gmail.com>.
Got it. Sorry for the confusion, just trying different things here.

On 11/19/07, Antonio Petrelli <an...@gmail.com> wrote:
> Dok I am confused here: do you use Struts 1 or 2?
> If it is another question, please create a new thread. And if it is a Struts
> 2/Tiles 2 plugin issue, please ask the Struts Users Mailing List:
> http://struts.apache.org/mail.html
>
> Antonio
>
> 2007/11/18, doktora v <do...@gmail.com>:
> >
> > I have tried this now with struts2 and tiles2 and it doesn't seem to
> > work either.
> > See the attached war. Take a look at /s2t2/test.action
> >
> > The success of test.action maps to tile test.layout:
> >
> > <definition name="test.layout" template="/testlayout.jsp">
> >   <put-attribute name="menuclass" value="leftmenu"/>
> >   <put-attribute name="bottom" value="/bottom.jsp"/>
> > </definition>
> >
> > Here is testlayout.jsp:
> > ---------------------
> > <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
> > <tiles:importAttribute name="menuclass"/>
> > <html>
> > <body>
> > test layout
> > <hr/>
> > <tiles:insertAttribute name="menuclass"/>
> > <hr/>
> > <tiles:insertTemplate template="/bottom.jsp">
> >   <tiles:putAttribute name="menuclass" value="${menuclass}"/>
> > </tiles:insertTemplate>
> > </body>
> > </html>
> >
> > An now here is what bottom.jsp does, inserting an action as a template:
> > -----------------
> > <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
> > <tiles:importAttribute name="menuclass" ignore="true"/>
> >
> > bottom jsp page
> > <br/>
> > menuclass: <tiles:insertAttribute name="menuclass"/>
> > <hr/>
> > <tiles:insertTemplate template="/test2.action">
> > </tiles:insertTemplate>
> > ----------
> >
> > test2.action works, /s2t2/test2.action produces the text "test2layout jsp
> > page".
> >
> > However, what bottom.jsp renders is
> > "The requested resource (/s2t2/test2.action) is not available"
> > in place of where the action's result should be inserted.
> >
> > Any thoughts? (Sorry for the complicated jsp/tiles, I was testing out
> > a few other things as well.)
> >
> > The war file is available here:
> > http://www.speedyshare.com/399123758.html
> >
> > Dok
> >
> >
> >
> > On 11/18/07, doktora v <do...@gmail.com> wrote:
> > > On 11/18/07, Antonio Petrelli <an...@gmail.com> wrote:
> > > > 2007/11/18, doktora v <do...@gmail.com>:
> > > > > You mean struts1 and tiles2 w/o plugin? How? If I specify the tiles
> > > > > listener in web.xml and don't specify the plugin in
> > struts-config.xml,
> > > > > the tiles are not recognized (I get errors of the sort "path does
> > not
> > > > > begin with /").
> > > >
> > > > You can use it without a plugin:
> > > > 1) by rendering using the Tiles container. See:
> > > > http://tiles.apache.org/tutorial/basic/pages.html
> > > > 2) by using the Tiles dispatcher servlet. See:
> > > > http://tiles.apache.org/tutorial/advanced/utils.html
> > > >
> > > > The drawback is that you cannot use a Tiles definition as a Struts
> > forward.
> > >
> > > Hmm... that doesn't fit my specs unfortunately. Thanks though.
> > >
> > > >
> > > > Antonio
> > > >
> > >
> >
>

Re: tiles1 - tiles2 migration: insert an action

Posted by Antonio Petrelli <an...@gmail.com>.
Dok I am confused here: do you use Struts 1 or 2?
If it is another question, please create a new thread. And if it is a Struts
2/Tiles 2 plugin issue, please ask the Struts Users Mailing List:
http://struts.apache.org/mail.html

Antonio

2007/11/18, doktora v <do...@gmail.com>:
>
> I have tried this now with struts2 and tiles2 and it doesn't seem to
> work either.
> See the attached war. Take a look at /s2t2/test.action
>
> The success of test.action maps to tile test.layout:
>
> <definition name="test.layout" template="/testlayout.jsp">
>   <put-attribute name="menuclass" value="leftmenu"/>
>   <put-attribute name="bottom" value="/bottom.jsp"/>
> </definition>
>
> Here is testlayout.jsp:
> ---------------------
> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
> <tiles:importAttribute name="menuclass"/>
> <html>
> <body>
> test layout
> <hr/>
> <tiles:insertAttribute name="menuclass"/>
> <hr/>
> <tiles:insertTemplate template="/bottom.jsp">
>   <tiles:putAttribute name="menuclass" value="${menuclass}"/>
> </tiles:insertTemplate>
> </body>
> </html>
>
> An now here is what bottom.jsp does, inserting an action as a template:
> -----------------
> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
> <tiles:importAttribute name="menuclass" ignore="true"/>
>
> bottom jsp page
> <br/>
> menuclass: <tiles:insertAttribute name="menuclass"/>
> <hr/>
> <tiles:insertTemplate template="/test2.action">
> </tiles:insertTemplate>
> ----------
>
> test2.action works, /s2t2/test2.action produces the text "test2layout jsp
> page".
>
> However, what bottom.jsp renders is
> "The requested resource (/s2t2/test2.action) is not available"
> in place of where the action's result should be inserted.
>
> Any thoughts? (Sorry for the complicated jsp/tiles, I was testing out
> a few other things as well.)
>
> The war file is available here:
> http://www.speedyshare.com/399123758.html
>
> Dok
>
>
>
> On 11/18/07, doktora v <do...@gmail.com> wrote:
> > On 11/18/07, Antonio Petrelli <an...@gmail.com> wrote:
> > > 2007/11/18, doktora v <do...@gmail.com>:
> > > > You mean struts1 and tiles2 w/o plugin? How? If I specify the tiles
> > > > listener in web.xml and don't specify the plugin in
> struts-config.xml,
> > > > the tiles are not recognized (I get errors of the sort "path does
> not
> > > > begin with /").
> > >
> > > You can use it without a plugin:
> > > 1) by rendering using the Tiles container. See:
> > > http://tiles.apache.org/tutorial/basic/pages.html
> > > 2) by using the Tiles dispatcher servlet. See:
> > > http://tiles.apache.org/tutorial/advanced/utils.html
> > >
> > > The drawback is that you cannot use a Tiles definition as a Struts
> forward.
> >
> > Hmm... that doesn't fit my specs unfortunately. Thanks though.
> >
> > >
> > > Antonio
> > >
> >
>

Re: tiles1 - tiles2 migration: insert an action

Posted by doktora v <do...@gmail.com>.
I have tried this now with struts2 and tiles2 and it doesn't seem to
work either.
See the attached war. Take a look at /s2t2/test.action

The success of test.action maps to tile test.layout:

<definition name="test.layout" template="/testlayout.jsp">
  <put-attribute name="menuclass" value="leftmenu"/>
  <put-attribute name="bottom" value="/bottom.jsp"/>
</definition>

Here is testlayout.jsp:
---------------------
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:importAttribute name="menuclass"/>
<html>
<body>
test layout
<hr/>
<tiles:insertAttribute name="menuclass"/>
<hr/>
<tiles:insertTemplate template="/bottom.jsp">
  <tiles:putAttribute name="menuclass" value="${menuclass}"/>
</tiles:insertTemplate>
</body>
</html>

An now here is what bottom.jsp does, inserting an action as a template:
-----------------
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:importAttribute name="menuclass" ignore="true"/>

bottom jsp page
<br/>
menuclass: <tiles:insertAttribute name="menuclass"/>
<hr/>
<tiles:insertTemplate template="/test2.action">
</tiles:insertTemplate>
----------

test2.action works, /s2t2/test2.action produces the text "test2layout jsp page".

However, what bottom.jsp renders is
"The requested resource (/s2t2/test2.action) is not available"
in place of where the action's result should be inserted.

Any thoughts? (Sorry for the complicated jsp/tiles, I was testing out
a few other things as well.)

The war file is available here:
http://www.speedyshare.com/399123758.html

Dok



On 11/18/07, doktora v <do...@gmail.com> wrote:
> On 11/18/07, Antonio Petrelli <an...@gmail.com> wrote:
> > 2007/11/18, doktora v <do...@gmail.com>:
> > > You mean struts1 and tiles2 w/o plugin? How? If I specify the tiles
> > > listener in web.xml and don't specify the plugin in struts-config.xml,
> > > the tiles are not recognized (I get errors of the sort "path does not
> > > begin with /").
> >
> > You can use it without a plugin:
> > 1) by rendering using the Tiles container. See:
> > http://tiles.apache.org/tutorial/basic/pages.html
> > 2) by using the Tiles dispatcher servlet. See:
> > http://tiles.apache.org/tutorial/advanced/utils.html
> >
> > The drawback is that you cannot use a Tiles definition as a Struts forward.
>
> Hmm... that doesn't fit my specs unfortunately. Thanks though.
>
> >
> > Antonio
> >
>

Re: tiles1 - tiles2 migration: insert an action

Posted by doktora v <do...@gmail.com>.
On 11/18/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/11/18, doktora v <do...@gmail.com>:
> > You mean struts1 and tiles2 w/o plugin? How? If I specify the tiles
> > listener in web.xml and don't specify the plugin in struts-config.xml,
> > the tiles are not recognized (I get errors of the sort "path does not
> > begin with /").
>
> You can use it without a plugin:
> 1) by rendering using the Tiles container. See:
> http://tiles.apache.org/tutorial/basic/pages.html
> 2) by using the Tiles dispatcher servlet. See:
> http://tiles.apache.org/tutorial/advanced/utils.html
>
> The drawback is that you cannot use a Tiles definition as a Struts forward.

Hmm... that doesn't fit my specs unfortunately. Thanks though.

>
> Antonio
>

Re: tiles1 - tiles2 migration: insert an action

Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/18, doktora v <do...@gmail.com>:
> You mean struts1 and tiles2 w/o plugin? How? If I specify the tiles
> listener in web.xml and don't specify the plugin in struts-config.xml,
> the tiles are not recognized (I get errors of the sort "path does not
> begin with /").

You can use it without a plugin:
1) by rendering using the Tiles container. See:
http://tiles.apache.org/tutorial/basic/pages.html
2) by using the Tiles dispatcher servlet. See:
http://tiles.apache.org/tutorial/advanced/utils.html

The drawback is that you cannot use a Tiles definition as a Struts forward.

Antonio

Re: tiles1 - tiles2 migration: insert an action

Posted by doktora v <do...@gmail.com>.
On 11/18/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/11/17, doktora v <do...@gmail.com>:
> > I'm using Struts 1.3.8 with Tiles 2.0.5 and
> > struts-tiles2-1.4.0-SNAPSHOT.jar plugin. Sorry for not mentioning this
> > before.
>
> I suppose that the struts-tiles2 plugin is not compatible with Struts 1.3.8.
> Try to use a snapshot of Struts 1.4.0 (or build it yourself) and see
> if it works.

Good point. Will try that.

> Or, maybe, simple use Tiles 2 without a plugin.

You mean struts1 and tiles2 w/o plugin? How? If I specify the tiles
listener in web.xml and don't specify the plugin in struts-config.xml,
the tiles are not recognized (I get errors of the sort "path does not
begin with /").

>
> Ciao
> Antonio
>

Re: tiles1 - tiles2 migration: insert an action

Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/17, doktora v <do...@gmail.com>:
> I'm using Struts 1.3.8 with Tiles 2.0.5 and
> struts-tiles2-1.4.0-SNAPSHOT.jar plugin. Sorry for not mentioning this
> before.

I suppose that the struts-tiles2 plugin is not compatible with Struts 1.3.8.
Try to use a snapshot of Struts 1.4.0 (or build it yourself) and see
if it works.
Or, maybe, simple use Tiles 2 without a plugin.

Ciao
Antonio

Re: tiles1 - tiles2 migration: insert an action

Posted by doktora v <do...@gmail.com>.
Will post the code. I don't interact with the response writer/output
stream at all. Both actions simply return mapping.getInputForward()
and that's mapped to a tile for the calling action and a jsp for the
action being inserted.

I'm using Struts 1.3.8 with Tiles 2.0.5 and
struts-tiles2-1.4.0-SNAPSHOT.jar plugin. Sorry for not mentioning this
before.

On 11/17/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/11/16, doktora v <do...@gmail.com>:
> > I tried that, but get:
> >
> > SEVERE: Servlet.service() for servlet org.apache.jsp.testlayout_jsp
> > threw exception
> > java.io.IOException: Stream closed
> >         at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:203)
> >         at org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:159)
> >         at org.apache.jsp.testlayout_jsp._jspService(testlayout_jsp.java:82)
>
> Now that is very strange :-O
> Did you close the response writer/output stream?
>
> > and the tile is not inserted but rather the entire result of the
> > action is rendered in my browser.
>
> Do you render the response with a forward? Or do you work directly on
> the HTTP response?
>
> > The action also uses tiles to
> > display its result.
>
> How? Please post the code.
>
> > Should I post my code/setup? It's fairly straightforward and if I call
> > the action  directly it works fine.
>
> Please post the code of your calling action, the action that should
> get inserted by Tiles, Tiles definitions.
>
> One last question: what version of Struts do you use?
>
> Ciao
> Antonio
>

Re: tiles1 - tiles2 migration: insert an action

Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/16, doktora v <do...@gmail.com>:
> I tried that, but get:
>
> SEVERE: Servlet.service() for servlet org.apache.jsp.testlayout_jsp
> threw exception
> java.io.IOException: Stream closed
>         at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:203)
>         at org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:159)
>         at org.apache.jsp.testlayout_jsp._jspService(testlayout_jsp.java:82)

Now that is very strange :-O
Did you close the response writer/output stream?

> and the tile is not inserted but rather the entire result of the
> action is rendered in my browser.

Do you render the response with a forward? Or do you work directly on
the HTTP response?

> The action also uses tiles to
> display its result.

How? Please post the code.

> Should I post my code/setup? It's fairly straightforward and if I call
> the action  directly it works fine.

Please post the code of your calling action, the action that should
get inserted by Tiles, Tiles definitions.

One last question: what version of Struts do you use?

Ciao
Antonio

Re: tiles1 - tiles2 migration: insert an action

Posted by doktora v <do...@gmail.com>.
I tried that, but get:

SEVERE: Servlet.service() for servlet org.apache.jsp.testlayout_jsp
threw exception
java.io.IOException: Stream closed
        at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:203)
        at org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:159)
        at org.apache.jsp.testlayout_jsp._jspService(testlayout_jsp.java:82)
....

and the tile is not inserted but rather the entire result of the
action is rendered in my browser. The action also uses tiles to
display its result.

Should I post my code/setup? It's fairly straightforward and if I call
the action  directly it works fine.



On 11/16/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/11/16, doktora v <do...@gmail.com>:
> > In tiles1 I used to be able to do:
> >
> > <tiles:insert page="/someaction.do">
> > </tiles:insert>
> >
> > How, if at all, is this possible in in Tiles2, i.e. inserting the
> > result of an action as a tile?
>
> Use <tiles:insertTemplate>
> For other info about migration see:
> http://tiles.apache.org/migration/index.html
>
> HTH
> Antonio
>

Re: tiles1 - tiles2 migration: insert an action

Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/16, doktora v <do...@gmail.com>:
> In tiles1 I used to be able to do:
>
> <tiles:insert page="/someaction.do">
> </tiles:insert>
>
> How, if at all, is this possible in in Tiles2, i.e. inserting the
> result of an action as a tile?

Use <tiles:insertTemplate>
For other info about migration see:
http://tiles.apache.org/migration/index.html

HTH
Antonio