RE: Setting tiles attributes from a bean in different scopes

2003-03-04 Thread BaTien Duong
Great. Thanks again. Nothing can replace words from the mouth of a real
developer.
BaTien

-Original Message-
From: Cedric Dumoulin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 3:46 AM
To: Struts Users Mailing List
Subject: Re: Setting tiles attributes from a bean in different scopes




BaTien Duong wrote:

>Thanks Cedric. You save us a day! 3 more items to be sure:
>
>1) Assuming we have *myAttribute* from *myBean* in user session
>myBean.getLevel2().getMyAttribute(). To use myAttribute as a JSP Java
>variable, we need:
>   //set an attribute for tile insert
>   
>beanScope="session" beanProperty="level2.myAttribute" />
>   
>
>
  This declare a tile attribute initialized from your bean. This
attribute can be used in the inserted tile only, not in the current page

>   //declare a Java variable for JSP usage
>   
>
  This can be done in the inserted tile only. It declare a java variable
and a bean in the "request" scope. A java variable is only visible
inside the jsp page where it is declared. The bean is visible in its scope.

>
>   // myAttribute is now available for all sub tiles in the jsp
>   <%= myAttribute ... %>
>
  NO ! The java variable is not visible in sub tiles because they are
other jsps. But the bean stored in the request scope is visible. so, you
can retrieve it from the scope:


>
>2) Assuming now level2 is a HashMap and myAttributeName is the key
>corresponding to myAttribute value: myAttribute = (HashMap
>myBean.getLevel2()).get("myAttributeName")
>the beanProperty can be set: beanProperty="level2.myAttributeName"
>
  I don't remember the exact syntax for accessing hashmap. It is the
same syntax used in Struts tags.

>
>3) Assuming as in (2) but myAttribute is now a property of level2Obj, which
>is the value of myAttributeName key: myAttribute = ( Level2Obj (HashMap
>myBean.getLevel2()).get("myAttributeName").getMyAttribute(), the
>beanProperty can be set:
>   beanProperty="level2.myAttributeName.myAttribute"
>
  It should work. In fact Tiles use the BeanUtils library. So, if this
library support it, Tiles support it also.

Cedric

>


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



Re: Setting tiles attributes from a bean in different scopes

2003-03-04 Thread Cedric Dumoulin


BaTien Duong wrote:

Thanks Cedric. You save us a day! 3 more items to be sure:

1) Assuming we have *myAttribute* from *myBean* in user session
myBean.getLevel2().getMyAttribute(). To use myAttribute as a JSP Java
variable, we need:
	//set an attribute for tile insert
	
	  
	beanScope="session" beanProperty="level2.myAttribute" />
	
 

 This declare a tile attribute initialized from your bean. This 
attribute can be used in the inserted tile only, not in the current page

//declare a Java variable for JSP usage

 This can be done in the inserted tile only. It declare a java variable 
and a bean in the "request" scope. A java variable is only visible 
inside the jsp page where it is declared. The bean is visible in its scope.

// myAttribute is now available for all sub tiles in the jsp
<%= myAttribute ... %>
 NO ! The java variable is not visible in sub tiles because they are 
other jsps. But the bean stored in the request scope is visible. so, you 
can retrieve it from the scope:


2) Assuming now level2 is a HashMap and myAttributeName is the key
corresponding to myAttribute value: myAttribute = (HashMap
myBean.getLevel2()).get("myAttributeName")
the beanProperty can be set: beanProperty="level2.myAttributeName"
 I don't remember the exact syntax for accessing hashmap. It is the 
same syntax used in Struts tags.

3) Assuming as in (2) but myAttribute is now a property of level2Obj, which
is the value of myAttributeName key: myAttribute = ( Level2Obj (HashMap
myBean.getLevel2()).get("myAttributeName").getMyAttribute(), the
beanProperty can be set:
beanProperty="level2.myAttributeName.myAttribute"
 It should work. In fact Tiles use the BeanUtils library. So, if this 
library support it, Tiles support it also.

   Cedric

Thanks.

-Original Message-
From: Cedric Dumoulin [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 9:35 AM
To: Struts Users Mailing List
Subject: Re: Setting tiles attributes from a bean in different scopes


 Hi,

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  nested in an . A tile attribute is always in
the tiles scope (the tiles context). However, you can import
() a tile attribute in any jsp scope, or use
it () as java variable.
 So, I don't clearly see what you are trying to do ;-).
 

Solution from a scratch of my head:



   

 This code is not valid because the  tag should be nested inside
an  tag.
 

Questions:
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:

 

 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  tag so we do not need  and
 tags?
   

  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
JSTL?
   

 Remind that you can use the dot separator in the bean property name:
beanProperty="myLevel2.myAttribute"
 Cedric

 

Thanks?

-
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]
-
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: Setting tiles attributes from a bean in different scopes

2003-03-03 Thread BaTien Duong
Thanks Cedric. You save us a day! 3 more items to be sure:

1) Assuming we have *myAttribute* from *myBean* in user session
myBean.getLevel2().getMyAttribute(). To use myAttribute as a JSP Java
variable, we need:
//set an attribute for tile insert

  


//declare a Java variable for JSP usage


// myAttribute is now available for all sub tiles in the jsp
<%= myAttribute ... %>

2) Assuming now level2 is a HashMap and myAttributeName is the key
corresponding to myAttribute value: myAttribute = (HashMap
myBean.getLevel2()).get("myAttributeName")
the beanProperty can be set: beanProperty="level2.myAttributeName"

3) Assuming as in (2) but myAttribute is now a property of level2Obj, which
is the value of myAttributeName key: myAttribute = ( Level2Obj (HashMap
myBean.getLevel2()).get("myAttributeName").getMyAttribute(), the
beanProperty can be set:
beanProperty="level2.myAttributeName.myAttribute"

Thanks.


-Original Message-
From: Cedric Dumoulin [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 9:35 AM
To: Struts Users Mailing List
Subject: Re: Setting tiles attributes from a bean in different scopes



  Hi,

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  nested in an . A tile attribute is always in
the tiles scope (the tiles context). However, you can import
() a tile attribute in any jsp scope, or use
it () as java variable.
  So, I don't clearly see what you are trying to do ;-).

>
>Solution from a scratch of my head:
>   
>   className="java.lang.String" />
>   />
>
>
  This code is not valid because the  tag should be nested inside
an  tag.

>Questions:
>   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:

  

  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  tag so we do not need  and
> tags?
>
   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
>JSTL?
>
  Remind that you can use the dot separator in the bean property name:
beanProperty="myLevel2.myAttribute"

  Cedric

>
>Thanks?
>
>
>-
>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]


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



Re: Setting tiles attributes from a bean in different scopes

2003-03-03 Thread Cedric Dumoulin
 Hi,

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  nested in an . A tile attribute is always in 
the tiles scope (the tiles context). However, you can import 
() a tile attribute in any jsp scope, or use 
it () as java variable.
 So, I don't clearly see what you are trying to do ;-).

Solution from a scratch of my head:
	
	
className="java.lang.String" />
	
/>
 

 This code is not valid because the  tag should be nested inside 
an  tag.

Questions:
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:

 

 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  tag so we do not need  and
 tags?
  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
JSTL?
 Remind that you can use the dot separator in the bean property name: 
beanProperty="myLevel2.myAttribute"

 Cedric

Thanks?

-
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]