Re: Dynamic forward in tiles

2004-03-26 Thread Pedro Salgado
On 25/03/2004 13:22, Mariano García [EMAIL PROTECTED]
wrote:

 El mié, 24-03-2004 a las 20:21, Pedro Salgado escribió:
   Below is a reply sent to this mailing list about something very similar to
 what you are looking for.
 
 but there is any way to use dynamic content only using tiles tags? In my
 case, I have a 'setAttribute(serverLocation, Location)' function in an
 Action in order to store a bean with a location information.
 
 Location is a string (an url), so I want to use this url into a tile
 definition, like this:
 
 definition name=tracebox.def.encoderconfig
 extends=tracebox.def.menu
 put name=title value=encoderconfig /
 put name=body value=LOCATION /
 /definition
 
 I think it must be a easy solution, using tile tags.
 

  The way I presented to you is the cleaner one :)

  If you define the put declaration in Tiles it will always be static (at
least for what I understood and read so far).

  If you want to make a tiles attribute dynamic, you must specify and
implement the tiles controller (described in the other mail).

  The not so clean solution is to use a tiles template with a c:import
url='${request.dynamicTilesAttribute}'/ inside.

 what do you think?

  I guess this is not a question of what I think... It is more of how it
works :)
  This could be a nice feature to Tiles though.

  One could implement a Tiles controller that made this possible. You just
needed to parse all of attributes for ${scope.Attribute} values = it would
be inneficient most of the attributes are static. If the put declaration had
a dynamic attribute (true/false) it would certainly much more
interesting/efficient. Maybe I will try and do this on my weekend ;)



Pedro Salgado
  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic forward in tiles

2004-03-25 Thread Mariano García
El mié, 24-03-2004 a las 20:21, Pedro Salgado escribió:
   Below is a reply sent to this mailing list about something very similar to
 what you are looking for.

but there is any way to use dynamic content only using tiles tags? In my
case, I have a 'setAttribute(serverLocation, Location)' function in an
Action in order to store a bean with a location information.

Location is a string (an url), so I want to use this url into a tile
definition, like this:

definition name=tracebox.def.encoderconfig
extends=tracebox.def.menu
  put name=title value=encoderconfig /
  put name=body value=LOCATION /
/definition

I think it must be a easy solution, using tile tags.

what do you think?

-- 
  Mariano García González :: Ingeniero de Sistemas

OPTIVA MEDIAPGP 0x89E8E4CE
O'Donnel 29
28010 Madrid (España)
t. +34 91 577 80 57
www.optivamedia.com

© This message is printed on 100% recycled electrons.


signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada	digitalmente


Re: Dynamic forward in tiles

2004-03-24 Thread Pedro Salgado

  Below is a reply sent to this mailing list about something very similar to
what you are looking for.

  Hope it helps,

Pedro Salgado


Hi Robert..

I guess you could achieve the same using the controllerClass attribute and
building your class.. For instance, I have this definition in the
tiles-defs.xml file:
---
   definition name=.layout
   path=/common/layout.jsp
controllerClass='com.dars.XTileAction'
 put name=title   value=Encabezado primario/
 put name=leftsidevalue=/common/leftside.jsp/
 put name=rightside   value=/common/rightside.jsp/
 put name=header  value=/common/header.jsp/
 put name=footer  value=/common/footer.jsp/
 put name=bodyvalue=/common/body.jsp/
   /definition
---
  And I have this controllerClass
---
package com.dars;
import org.apache.struts.tiles.actions.TilesAction;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.IOException;

public class XTileAction extends TilesAction implements Controller{
public void perform(ComponentContext tilesctx,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servctx)
throws ServletException, IOException{
 /* GetAttributes */
 String titulo= (String)tilesctx.getAttribute(title);
 String derecha= (String)tilesctx.getAttribute(rightside);
 /* GetAttributes */
 System.out.println(  Titulo: +titulo);
 System.out.println( Derecha: +derecha);
 /* SetAttributes */
   tilesctx.putAttribute(title, Titulo nuevo de esta vaina..);
   tilesctx.putAttribute(rightside, /common/footer.jsp);
 /* SetAttributes */
}
}
---
You can change the values of those attributes at runtime. I prefer to do
it using this method.

Atte.
Domingo A. Rodriguez S.


 --- Robert Taylor [EMAIL PROTECTED] escribió:  Greetings, I have a
tiles definition in my tiles-defs.xml similar to
 below:
 
  definition name=search extends=layout
 put name=heading value={0}Search type=string /
 put name=content value=/search.jsp type=page /
   /definition
 
 which I would like to be able to modify the heading value such that
 at runtime I could substitute a value for {0}.
 
 For example, it would be ideal to use a JSTL type of syntax such as:
 
 definition name=search extends=layout
 put name=heading value=${param.myValue}Search type=string /
 put name=content value=/search.jsp type=page /
   /definition
 
 but this does not work.
 
 
 
 robert
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
  

_
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


On 24/03/2004 18:14, Mariano García González
[EMAIL PROTECTED] wrote:

 
 Hi all,
 
 I am newbie using tiles, so maybe this question is too easy for you.
 
 I want to use a tile definition in which, one of the attribute values is
 dynamic. It is something like this:
 
 definition name=tracebox.def.encoderconfig extends=tracebox.def.menu
 put name=title value=encoderconfig /
 put name=body value=DYNAMIC CONTENT /
 /definition
 
 I want to use a dynamic url in body attribute, depending of a bean
 attribute.
 
 I hope you understand me. Could you help me?
 
 Thanks,
 Mariano.
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic forward in tiles

2004-03-24 Thread Mike Foody
I have a similar question.  I would like to insert at runtime multiple 
instances of the same layout and set a property at that time.  I didn't 
see a way to do this via the documentation and so extended the TilesTool 
with the following code.  Is there something I've missed?  If not is the 
code below a reasonable way to do this?

Thank you,

Mike

public class TilesTool extends org.apache.velocity.tools.struts.TilesTool {
  
   public String get(Object obj)
   {
   if (obj instanceof ComponentDefinition)
   {
   try
   {
   return processDefinition((ComponentDefinition)obj);
   }
   catch (Exception e)
   {
   Velocity.error(Exception while rendering 
ComponentDefinition + e.getMessage());
   }
   }
   return super.get(obj);
   }
  
   public ComponentDefinition getDefinition(String name)
   {
   ComponentDefinition definition = null;
   try
   {
   definition = TilesUtil.getDefinition(name, this.request, 
this.application);
   }
   catch (DefinitionsFactoryException dfe)
   {
  
   }
   return definition;
   }
  
  
}

Pedro Salgado wrote:

 Below is a reply sent to this mailing list about something very similar to
what you are looking for.
 Hope it helps,

Pedro Salgado

Hi Robert..

I guess you could achieve the same using the controllerClass attribute and
building your class.. For instance, I have this definition in the
tiles-defs.xml file:
---
  definition name=.layout
  path=/common/layout.jsp
   controllerClass='com.dars.XTileAction'
put name=title   value=Encabezado primario/
put name=leftsidevalue=/common/leftside.jsp/
put name=rightside   value=/common/rightside.jsp/
put name=header  value=/common/header.jsp/
put name=footer  value=/common/footer.jsp/
put name=bodyvalue=/common/body.jsp/
  /definition
---
 And I have this controllerClass
---
package com.dars;
import org.apache.struts.tiles.actions.TilesAction;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.IOException;
public class XTileAction extends TilesAction implements Controller{
   public void perform(ComponentContext tilesctx,
   HttpServletRequest request,
   HttpServletResponse response,
   ServletContext servctx)
   throws ServletException, IOException{
/* GetAttributes */
String titulo= (String)tilesctx.getAttribute(title);
String derecha= (String)tilesctx.getAttribute(rightside);
/* GetAttributes */
System.out.println(  Titulo: +titulo);
System.out.println( Derecha: +derecha);
/* SetAttributes */
  tilesctx.putAttribute(title, Titulo nuevo de esta vaina..);
  tilesctx.putAttribute(rightside, /common/footer.jsp);
/* SetAttributes */
   }
}
---
You can change the values of those attributes at runtime. I prefer to do
it using this method.
Atte.
Domingo A. Rodriguez S.
--- Robert Taylor [EMAIL PROTECTED] escribió:  Greetings, I have a
tiles definition in my tiles-defs.xml similar to
 

below:

definition name=search extends=layout
   put name=heading value={0}Search type=string /
   put name=content value=/search.jsp type=page /
 /definition
which I would like to be able to modify the heading value such that
at runtime I could substitute a value for {0}.
For example, it would be ideal to use a JSTL type of syntax such as:

definition name=search extends=layout
   put name=heading value=${param.myValue}Search type=string /
   put name=content value=/search.jsp type=page /
 /definition
but this does not work.



robert

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   

_
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On 24/03/2004 18:14, Mariano García González
[EMAIL PROTECTED] wrote:
 

Hi all,

I am newbie using tiles, so maybe this question is too easy for you.

I want to use a tile definition in which, one of the attribute values is
dynamic. It is something like this:
definition name=tracebox.def.encoderconfig extends=tracebox.def.menu
put name=title value=encoderconfig /
put name=body value=DYNAMIC CONTENT /
/definition
I want to use a dynamic url in body attribute, depending of a bean
attribute.
I hope you understand me. Could you help me?

Thanks,
Mariano.

Re: Dynamic forward in tiles

2004-03-24 Thread Mike Foody
I apologize if I didn't mention it but I'm using the Velocity tiles 
tool.  Maybe that would be a better place for this question. 

Mike



Mike Foody wrote:

I have a similar question.  I would like to insert at runtime multiple 
instances of the same layout and set a property at that time.  I 
didn't see a way to do this via the documentation and so extended the 
TilesTool with the following code.  Is there something I've missed?  
If not is the code below a reasonable way to do this?

Thank you,

Mike

public class TilesTool extends 
org.apache.velocity.tools.struts.TilesTool {
 public String get(Object obj)
   {
   if (obj instanceof ComponentDefinition)
   {
   try
   {
   return processDefinition((ComponentDefinition)obj);
   }
   catch (Exception e)
   {
   Velocity.error(Exception while rendering 
ComponentDefinition + e.getMessage());
   }
   }
   return super.get(obj);
   }
 public ComponentDefinition getDefinition(String name)
   {
   ComponentDefinition definition = null;
   try
   {
   definition = TilesUtil.getDefinition(name, this.request, 
this.application);
   }
   catch (DefinitionsFactoryException dfe)
   {
 }
   return definition;
   }
}

Pedro Salgado wrote:

 Below is a reply sent to this mailing list about something very 
similar to
what you are looking for.

 Hope it helps,

Pedro Salgado

Hi Robert..

I guess you could achieve the same using the controllerClass 
attribute and
building your class.. For instance, I have this definition in the
tiles-defs.xml file:
---
  definition name=.layout
  path=/common/layout.jsp
   controllerClass='com.dars.XTileAction'
put name=title   value=Encabezado primario/
put name=leftsidevalue=/common/leftside.jsp/
put name=rightside   value=/common/rightside.jsp/
put name=header  value=/common/header.jsp/
put name=footer  value=/common/footer.jsp/
put name=bodyvalue=/common/body.jsp/
  /definition
---
 And I have this controllerClass
---
package com.dars;
import org.apache.struts.tiles.actions.TilesAction;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.IOException;

public class XTileAction extends TilesAction implements Controller{
   public void perform(ComponentContext tilesctx,
   HttpServletRequest request,
   HttpServletResponse response,
   ServletContext servctx)
   throws ServletException, IOException{
/* GetAttributes */
String titulo= (String)tilesctx.getAttribute(title);
String derecha= (String)tilesctx.getAttribute(rightside);
/* GetAttributes */
System.out.println(  Titulo: +titulo);
System.out.println( Derecha: +derecha);
/* SetAttributes */
  tilesctx.putAttribute(title, Titulo nuevo de esta 
vaina..);
  tilesctx.putAttribute(rightside, /common/footer.jsp);
/* SetAttributes */
   }
}
---
You can change the values of those attributes at runtime. I prefer to do
it using this method.

Atte.
Domingo A. Rodriguez S.
--- Robert Taylor [EMAIL PROTECTED] escribió:  Greetings, I have a
tiles definition in my tiles-defs.xml similar to
 

below:

definition name=search extends=layout
   put name=heading value={0}Search type=string /
   put name=content value=/search.jsp type=page /
 /definition
which I would like to be able to modify the heading value such that
at runtime I could substitute a value for {0}.
For example, it would be ideal to use a JSTL type of syntax such as:

definition name=search extends=layout
   put name=heading value=${param.myValue}Search type=string /
   put name=content value=/search.jsp type=page /
 /definition
but this does not work.



robert

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
  


_
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On 24/03/2004 18:14, Mariano García González
[EMAIL PROTECTED] wrote:
 

Hi all,

I am newbie using tiles, so maybe this question is too easy for you.

I want to use a tile definition in which, one of the attribute 
values is
dynamic. It is something like this:

definition name=tracebox.def.encoderconfig 
extends=tracebox.def.menu
put name=title value=encoderconfig /
put name=body value=DYNAMIC 

Re: Dynamic forward in tiles

2004-03-24 Thread Pedro Salgado
On 24/03/2004 22:45, Mike Foody [EMAIL PROTECTED] wrote:

 I apologize if I didn't mention it but I'm using the Velocity tiles
 tool.  Maybe that would be a better place for this question.
 

  Well the solution for your problem is the one below.
I don't if your using velocity to generate your tiles file (I use velocity
just to build SQL/DAOs with the OJB framework).
If this is true, then you just have to make it generate a tiles file with a
controller class defined by you.

  The runtime argument must be handled by you, programatically, in your own
tiles controller class.



Pedro Salgado

 Mike
 
 
 
 
 Mike Foody wrote:
 
 I have a similar question.  I would like to insert at runtime multiple
 instances of the same layout and set a property at that time.  I
 didn't see a way to do this via the documentation and so extended the
 TilesTool with the following code.  Is there something I've missed?
 If not is the code below a reasonable way to do this?
 
 Thank you,
 
 Mike
 
 
 public class TilesTool extends
 org.apache.velocity.tools.struts.TilesTool {
  public String get(Object obj)
{
if (obj instanceof ComponentDefinition)
{
try
{
return processDefinition((ComponentDefinition)obj);
}
catch (Exception e)
{
Velocity.error(Exception while rendering
 ComponentDefinition + e.getMessage());
}
}
return super.get(obj);
}
  public ComponentDefinition getDefinition(String name)
{
ComponentDefinition definition = null;
try
{
definition = TilesUtil.getDefinition(name, this.request,
 this.application);
}
catch (DefinitionsFactoryException dfe)
{
  }
return definition;
}
 }
 
 Pedro Salgado wrote:
 
  Below is a reply sent to this mailing list about something very
 similar to
 what you are looking for.
 
  Hope it helps,
 
 Pedro Salgado
 
 
 Hi Robert..
 
 I guess you could achieve the same using the controllerClass
 attribute and
 building your class.. For instance, I have this definition in the
 tiles-defs.xml file:
 ---
   definition name=.layout
   path=/common/layout.jsp
controllerClass='com.dars.XTileAction'
 put name=title   value=Encabezado primario/
 put name=leftsidevalue=/common/leftside.jsp/
 put name=rightside   value=/common/rightside.jsp/
 put name=header  value=/common/header.jsp/
 put name=footer  value=/common/footer.jsp/
 put name=bodyvalue=/common/body.jsp/
   /definition
 ---
  And I have this controllerClass
 ---
 package com.dars;
 import org.apache.struts.tiles.actions.TilesAction;
 import org.apache.struts.tiles.ComponentContext;
 import org.apache.struts.tiles.Controller;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import java.io.IOException;
 
 public class XTileAction extends TilesAction implements Controller{
public void perform(ComponentContext tilesctx,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servctx)
throws ServletException, IOException{
 /* GetAttributes */
 String titulo= (String)tilesctx.getAttribute(title);
 String derecha= (String)tilesctx.getAttribute(rightside);
 /* GetAttributes */
 System.out.println(  Titulo: +titulo);
 System.out.println( Derecha: +derecha);
 /* SetAttributes */
   tilesctx.putAttribute(title, Titulo nuevo de esta
 vaina..);
   tilesctx.putAttribute(rightside, /common/footer.jsp);
 /* SetAttributes */
}
 }
 ---
 You can change the values of those attributes at runtime. I prefer to do
 it using this method.
 
 Atte.
 Domingo A. Rodriguez S.
 
 
 --- Robert Taylor [EMAIL PROTECTED] escribió:  Greetings, I have a
 tiles definition in my tiles-defs.xml similar to
  
 
 below:
 
 definition name=search extends=layout
put name=heading value={0}Search type=string /
put name=content value=/search.jsp type=page /
  /definition
 
 which I would like to be able to modify the heading value such that
 at runtime I could substitute a value for {0}.
 
 For example, it would be ideal to use a JSTL type of syntax such as:
 
 definition name=search extends=layout
put name=heading value=${param.myValue}Search type=string /
put name=content value=/search.jsp type=page /
  /definition
 
 but this does not work.
 
 
 
 robert
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
   
 
 
 _
 Do You Yahoo!?
 Información de Estados Unidos y América Latina, en Yahoo!