• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:setProperty

 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When I use <jsp:setProperty id="mybean" property="*"> it sets the bean properties by looping through the request object and calling the respective mutator methods (set methods).
But when the property is null or "" ( blank ) it doesnt set the property hence keeps the old value.
How can I get away from this problem. If I need to check the null or "" ( blank )then I end up looping through all the properties. Then whats the fun in using "*" ?? !!

cheers.
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're probably right in your comment. But what happens if the container can't find the bean in the scope you specify. It will instantiate the server and set all values automatically. This is the fun about it
I've never found any case when I need to change/modify the behaviour of this. If I'd have to, I'd do it manually, i guess..
if you find a better way to do it let me know..
good luck
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So use can make the best use of this only when bean is instantiated and the properties are initialised. i.e.
<jsp:useBean id="mybean" class="mypackage.MyClass" scope="session">
<jsp:setProperty name="mybean" property="*"/>
</jsp:useBean>
You cant use the setProperty with * other than this place, right ?
If so why they have not specified this in Specification !!! ?

Cheers.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I think it is not mandatory to user
<jsp:setProperty name="mybean" property="*"/>
only in <jsp: useBean......
what i found is ur setter method is never called if the value of respective object is null,hence the old value is retain in the bean variable.
cheers
Praful
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I agree with you.
But atleast there could have been a provision in jsp:stProperty which will set "" to the properties which are either null or blank.
Without this the usage of jsp:setProperty with property="*" has no proper usage other than initialisation. !! Right ?

Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!