Ok, I haven't read carefully enough your previous mail.
You can create a new definition from a definition read in the factory, and then instruct current Struts action to use your new definition. More precisely, the definition associated to the struts forward will be overloaded by your definition.
The class org.apache.struts.webapp.tiles.test.TestActionTileAction use in the tiles-documentation/test do that.
Following is an extract from this class. The code get the definition, copy it, modify the copy, and then put it in the appropriate request attribute. The

// Read definition from factory, but we can create it here.

ComponentDefinition definition = DefinitionsUtil.getDefinition( ... );

definition = new ComponentDefinition(definition);

definition.putAttribute( "attributeName", "aValue" );

DefinitionsUtil.setActionDefinition( request, definition);

...

return (mapping.findForward("success"));


Cedric



Roland Carlsson wrote:

Hi !
I think the DefinitionDispatcherAction doesn't do what I want to do....

Imagine that you have a definition with 2 tiles (left and body)
In the left tile there are a collection of links that will change the
content of body.

If I understands what the DefinitonDispatcherAction does it will change what
defintion to use. What I want to do is to change one tile in the defintion,
much like a frameset where i doesn't change the frameset, only one page in
it. So I want to call the same defintion and alter a tile in that defintion.
Not change the defintion.

The problem with the perform-method I posted is that it change the tile in
the application-scope and I havn't figured out yet how to make the change
isolate into a request only.

Regards
Roland




----- Original Message -----
From: "Cedric Dumoulin" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 2:11 PM
Subject: Re: <tiles:put /> in ActionForward.perform()



Hi,

I think there is an action in the Tiles/Struts distribution doing
exactly that ;-)
Check org.apache.struts.tiles.actions.DefinitionDispatcherAction.

Cedric

Roland Carlsson wrote:


I have solved my own question. If anyone is intrested I past the code

below.

The change in the definition lasts only for the request and will not make
any permanent changes.

Regards
Roland Carlsson


public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
String forward = "success";
String path = request.getParameter("body");
// Change nothing
if(path == null || path.equals("")){
// do nothing
}else{
// Try to change body-page
ServletContext context =
this.getServlet().getServletConfig().getServletContext();
ComponentDefinition cd = null;
try{
cd = DefinitionsUtil.getDefinition(path, request, context) ;
cd.put("body", request.getParameter("body"));
// if something is wrong
}catch(Exception e){
e.printStackTrace();
forward = "error";
}
}
return mapping.findForward(forward);
}

----- Original Message -----
From: "Roland Carlsson" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, October 29, 2002 4:31 PM
Subject: <tiles:put /> in ActionForward.perform()





Hi!
I'm trying to expand my tiles with a dynamic body. I want to control

this

body with a simple parameter in the url eg
http://localhost:8081/myPage?body=aTile.jsp . Does anyone have an

example


of



how to do this?

Thanks in advance
Roland Carlsson


--
To unsubscribe, e-mail:



<mailto:struts-user-unsubscribe@;jakarta.apache.org>



For additional commands, e-mail:



<mailto:struts-user-help@;jakarta.apache.org>




--
To unsubscribe, e-mail:

<mailto:struts-user-unsubscribe@;jakarta.apache.org>

For additional commands, e-mail:

<mailto:struts-user-help@;jakarta.apache.org>




--
To unsubscribe, e-mail:

<mailto:struts-user-unsubscribe@;jakarta.apache.org>

For additional commands, e-mail:

<mailto:struts-user-help@;jakarta.apache.org>



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




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

Reply via email to