You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@gmail.com on 2007/04/11 20:33:35 UTC

Tiles 2 Lifecycycle

I am discovering slightly different behavior between my application with
Tiles and without.  Consider the following snippet of configuration:

        <action name="course_*" method="{1}" class="course">
            <result name="input" type="tiles">course.page</result>
            <result type="tiles">course.page</result>
        </action>

Shouldn't returning SUCCESS from my action result in a new Action class
instance and it's dependencies being injected?  My web page is retaining the
values as if the bean in the action class was not renewed.  I don't recall
seeing this behavior before adding struts.  What steps are happening as the
request is passed to the tiles definition?


<tiles-definitions>

  <definition name="standard" template="/pages/base.jsp">
        <put name="title" value="Standard Title for base.jsp" />
      <put name="header" value="/pages/header.jsp" />
      <put name="navigation" value="/pages/navigation.jsp" />
      <put name="body"   value="/pages/body.jsp" />
      <put name="footer" value="/pages/footer.jsp" />
  </definition>

  <definition name="course.page" extends="standard">
        <put name="title" value="Course" />
      <put name="body"  value="/pages/course.jsp" />
  </definition>
</tiles-definitions>

-- 
Scott
stanlick@gmail.com

Re: Tiles 2 Lifecycycle

Posted by Antonio Petrelli <an...@gmail.com>.
2007/4/23, stanlick@gmail.com <st...@gmail.com>:
> Hi Antonio --
>
> I have been teaching for the past couple weeks and now returning to
> S2/Tiles.  I would like to understand how Tiles affects the S2 lifecycle.

AFAIK Tiles affects S2 only in rendering the results. What I mean is
if you are using a result of "tiles" type, it will be rendered by
rendering its components, that can be JSPs or other view pages. If
things have not changes, currently only JSP and FreeMarker are
supported.
This means that JSP pages (for example) can read all the beans put in
all the usual scopes (request, session, etc.)
Essentially, using Tiles is not so different to use normal JSP (or
FreeMarker) pages: Tiles composes pages and renders them, but how the
beans are put in the page is a task of the JSP (or FreeMarker) page.

Antonio

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


Re: Tiles 2 Lifecycycle

Posted by st...@gmail.com.
Hi Antonio --

I have been teaching for the past couple weeks and now returning to
S2/Tiles.  I would like to understand how Tiles affects the S2 lifecycle.

Scott

On 4/15/07, Antonio Petrelli <an...@gmail.com> wrote:
>
> 2007/4/13, stanlick <st...@gmail.com>:
> >
> > Antonio --
> >
> > Can you explain this using this example?
>
> I am sorry, I did not understand you and gave you a bad answer.
> But I am wondering what you exactly wanted: do you want to inject
> beans in Tiles definitions, or JSP pages? Or possibly in the view
> preparer?
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Tiles 2 Lifecycycle

Posted by Antonio Petrelli <an...@gmail.com>.
2007/4/13, stanlick <st...@gmail.com>:
>
> Antonio --
>
> Can you explain this using this example?

I am sorry, I did not understand you and gave you a bad answer.
But I am wondering what you exactly wanted: do you want to inject
beans in Tiles definitions, or JSP pages? Or possibly in the view
preparer?

Antonio

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


Re: Tiles 2 Lifecycycle

Posted by stanlick <st...@gmail.com>.
Antonio -- 

Can you explain this using this example?

		<action name="course_*" method="{1}" class="course">
			<result name="input" type="tiles">course.page</result>
		</action>

My class "course" is wired up in Spring.  The course.page tiles definition
cab be found below.  The course.jsp allows CRUD operations for a Course. 
All four methods in the class return INPUT.  An intial request of this page
via action=course_input invokes Spring and ultimately display my composite
page.  The problem is that as items are added and the save() method returns
INPUT, the beans are not renewed via Spring.  However, the other methods
returning INPUT do invoke Spring and renew the objects behind the page!  I
don't understand how each of the CRUD methods return INPUT, yet only the
save() method is skipping the Spring step.  I'll add that the save() Action
method is invoked through the form, while the other three methods are
invoked via links.  I have also included the course.jsp where you will find
this code.  There seems to be a different lifecycle that is based on the
invocation technique.


  <definition name="standard" template="/pages/base.jsp">
  	  <put name="title" value="Standard Title for base.jsp" />
	  <put name="header" value="/pages/header.jsp" />
	  <put name="navigation" value="/pages/navigation.jsp" />	  
	  <put name="body"   value="/pages/body.jsp" />
	  <put name="footer" value="/pages/footer.jsp" />
  </definition>
  <definition name="course.page" extends="standard"
preparer="controller.CourseController">    
  	  <put name="title" value="Course" />     
	  <put name="body"   value="/pages/course.jsp" />
  </definition>  

	<body>
		<s:form >
			<s:textfield name="course.text" key="course.add.text" size="40" />
			<s:submit key="label.save" action="course_save"/>
		</s:form>

		<table border="1">
			<s:iterator value="#request.list">
				<tr>
					<td>
						<s:property value="id" />
					</td>
					<td>
						<input type="text" name="course.text" size="40"
							value="<s:property value="text"/>">
					</td>
					<td>
						<s:url id="url" action="course_remove">
							<s:param name="course.id">
								<s:property value="id" />
							</s:param>
						</s:url>
						<s:a href="%{url}">Remove</s:a>
					</td>
				</tr>

			</s:iterator>
		</table>
	</body>
-- 
View this message in context: http://www.nabble.com/Tiles-2-Lifecycycle-tf3561248.html#a9981576
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Tiles 2 Lifecycycle

Posted by Antonio Petrelli <an...@gmail.com>.
2007/4/13, stanlick <st...@gmail.com>:
>
> Wouldn't it be easier if you could redirect to yourself without involving
> another action for this purpose?  I use tile definitions as the target for
> all my requests.  Once the user successfully does a task related to that
> "page," I'd like to represent the tile with freshly injected beans.  Can you
> explain the lifecycle of a tiles request as it relates to Spring?

It's not a problem of Spring, a Tiles definition cannot be redirected
to, at least directly.
See:
http://www.mail-archive.com/user@struts.apache.org/msg58441.html

Antonio

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


Re: Tiles 2 Lifecycycle

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick <st...@gmail.com> wrote:
> Wouldn't it be easier if you could redirect to
> yourself without involving another action for this 
> purpose?  

Sure. 

The action you redirect to wouldn't need to be a
separate action; it could be the same one.

But a tile isn't an action, so you wouldn't get
Prepare and all those other features of the normal S2
stack.

> Can you explain the lifecycle of a tiles request as 
> it relates to Spring?

Someone else should chime in here, because I really
don't know.

My impression, however, is that the two are completely
unrelated, just like if you were dispatching to a JSP.
If you want to run an action (therefore the normal S2
stack), you need to involve an action somehow.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Tiles 2 Lifecycycle

Posted by stanlick <st...@gmail.com>.
Wouldn't it be easier if you could redirect to yourself without involving
another action for this purpose?  I use tile definitions as the target for
all my requests.  Once the user successfully does a task related to that
"page," I'd like to represent the tile with freshly injected beans.  Can you
explain the lifecycle of a tiles request as it relates to Spring?

Scott
-- 
View this message in context: http://www.nabble.com/Tiles-2-Lifecycycle-tf3561248.html#a9979957
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Tiles 2 Lifecycycle

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> So is there a way to redirect to a tile definition?

Not that I know of; so far if I'm returning a result
from an action that needs a redirect I've been
redirecting to an action with a tile "success" or
"input" result.

d.

> 
> 
> 
> On 4/11/07, Dave Newton <ne...@yahoo.com>
> wrote:
> >
> > --- stanlick@gmail.com wrote:
> > > <result type="tiles">course.page</result>
> > >
> > > Shouldn't returning SUCCESS from my action
> result in
> > > a new Action class instance and it's
> dependencies
> > > being injected?
> >
> > No; it's not a redirect. It's just like you put a
> JSP
> > value in for the result.
> >
> > d.
> >
> >
> >
> >
> >
> >
>
____________________________________________________________________________________
> > 8:00? 8:25? 8:40? Find a flick in no time
> > with the Yahoo! Search movie showtime shortcut.
> > http://tools.search.yahoo.com/shortcuts/#news
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> 
> 
> -- 
> Scott
> stanlick@gmail.com
> 



       
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/

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


Re: Tiles 2 Lifecycycle

Posted by st...@gmail.com.
So is there a way to redirect to a tile definition?



On 4/11/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- stanlick@gmail.com wrote:
> > <result type="tiles">course.page</result>
> >
> > Shouldn't returning SUCCESS from my action result in
> > a new Action class instance and it's dependencies
> > being injected?
>
> No; it's not a redirect. It's just like you put a JSP
> value in for the result.
>
> d.
>
>
>
>
>
> ____________________________________________________________________________________
> 8:00? 8:25? 8:40? Find a flick in no time
> with the Yahoo! Search movie showtime shortcut.
> http://tools.search.yahoo.com/shortcuts/#news
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Tiles 2 Lifecycycle

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> <result type="tiles">course.page</result>
> 
> Shouldn't returning SUCCESS from my action result in
> a new Action class instance and it's dependencies 
> being injected?

No; it's not a redirect. It's just like you put a JSP
value in for the result.

d.



       
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time 
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news

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