struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cedric Dumoulin <>
Subject Re: Setting tiles attributes from a bean in different scopes
Date Mon, 03 Mar 2003 16:35:26 GMT


BaTien Duong wrote:

>Hello Cedric and the group:
>Issue: need to retrieve properties of *myBean* in user session scope as
>values for tiles attributes in request scope.
  You can't set the scope of a tiles attribute: a tiles attribute is 
defined with <put> nested in an <insert>. A tile attribute is always in 
the tiles scope (the tiles context). However, you can import 
(<importAttribute>) a tile attribute in any jsp scope, or use 
it (<useAttribute>) as java variable.
  So, I don't clearly see what you are trying to do ;-).

>Solution from a scratch of my head:
>	<jsp:useBean id="myBean" scope="session" />
>	<tiles:useAttribute id="myAttribute" name="myAttribute" scope="request"
>className="java.lang.String" />
>	<tiles:put name="myAttribute" beanName="myBean" beanProperty="myAttribute"
  This code is not valid because the <put> tag should be nested inside 
an <insert> tag.

>	1) The bean and attribute are in different scopes. Can one set tile
>attributes from session scope?
  You can set an attribute from a bean stored in any scope:
<tiles:insert ...>
  <tiles:put name="myAttribute" beanName="myBean" beanScope="session" />
  This declare and set an attribute for the tile to be inserted. The 
attribute is called "myAttribute", its value is taken from the bean 
"myBean" which is in the "session" scope. 

>	2) Is there a faster way to assign an attribute at the time of
>initialization in <useAttribute> tag so we do not need <jsp:useBean> and
><tiles:put> tags?
  <useAttribute .../> tag is used to declare a java variable inside the 
jsp page. This variable is initialized from an attribute of the current 
tiles. This attribute has been passed to the current tiles. A side 
effect of this tag is to declare also a bean in one of the jsp scope.

>	3) Assuming myAttribute is a nested level of myBean ( i.e.
>getMyBean().getMyLevel2().getMyAttribute() ), is there an EL way similar to
  Remind that you can use the dot separator in the bean property name: 


>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message