Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

target attribute of c:set

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
The following quoted text is come from JSTL1.1 spec page 40


Syntax 1: Set the value of a scoped variable using attribute value
<c:set value=�value� var=�varName� scope=�{page|request|session|application}�]/>
Syntax 2: Set the value of a scoped variable using body content
<c:set var=�varName� [scope=�{page|request|session|application}�]>
body content
</c:set>
Syntax 3: Set a property of a target object using attribute value
<c:set value=�value� target=�target� property=�propertyName�/>
Syntax 4: Set a property of a target object using body content
<c:set target=�target� property=�propertyName�>
body content
</c:set>


I understand syntax 1 and 2, the var attribute is a name of a scoped variable, but I am not sure what is the target attribute in syntax 3 and 4, I tested some codes and found that the target object must be a scoped object(JavaBean or Map type), is that right ?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ming Li:
hi,
The following quoted text is come from JSTL1.1 spec page 40
I understand syntax 1 and 2, the var attribute is a name of a scoped variable, but I am not sure what is the target attribute in syntax 3 and 4, I tested some codes and found that the target object must be a scoped object(JavaBean or Map type), is that right ?


Syntax 3: Set a property of a target object using attribute value
<c:set value=�value� target=�target� property=�propertyName�/>
Sets the value (using value attribute) of the javaBean/Map object (exception will be thrown if the target is not javaBean or Map) property.
If the value attribute is null, the specific property will be removed from Map object & set to null for javabeans.
Syntax 4: Set a property of a target object using body content
<c:set target=�target� property=�propertyName�>
body content
</c:set>
This is similar to syntax 3 except that value for the property will be taken from body content.
Thanks,
Moorthi
[ January 31, 2004: Message edited by: Moorthi Ramasamy ]
 
Ming Li
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Moorthi,
Thanks for your reply, but my doubt is that I am not sure if the JavaBeans/Maps you mentioned must be scoped variables, I tested some code and I think they must be scoped varibles, the spec does not mention this directly, so, I am not sure!
anybody clear my mine?
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic