Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:setProperty

 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something that I just thought of <jsp:setProperty> is only used to set String or primitive attributes of a bean and not other Object types ie.: set Dog object to a Person object.
 
Mamadou Touré
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Justin,

Remember in your Standard action <jsp:setProperty>, you can use an expression for the "value" attribute, so if that value evaluates to something that is compatible to your bean property, it will probably work.

Ex
let`s say you have a bean called "Person", and that bean has a property called "Dog" .

so when you say

<jsp:setProperty name = "personBean" property = "dog" value = "<%=request.getParameter("dog")%>" />

So if value (part in bold character) evalutes to Dog, it will propably work

Hope this will help

Regards
[ December 18, 2008: Message edited by: Mamadou Tour� ]
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:setProperty name = "personBean" property = "dog" value = "<%=request.getParameter("dog")%>" />
I'm sure you mean value = "<%=request.getAttribute("dog")%>", but I understood what you meant, thanks.
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure in assuming that <jsp:setProperty> used only for String and primitives types as defined in:

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm13.html#17460
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure in assuming that <jsp:setProperty> used only for String and primitives types as defined in...

Be careful. The table you are looking at is about type conversion when property="*" is used. The value attribute can accept a request-time attribute expression as a value. What can you deduce from that statement ?
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So as the <jsp:setProperty> can accept a request-time attribute expression as a value, then <jsp:setProperty> can be used to set a property of a bean that is of a type Object ie.: set Dog object to a Person object.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic