Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deciphering param attribute in setProperty jsp action?

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the hfsj book at page no 360 says that

The param attribute lets you set the value of a
bean property to the value of a request parameter.
JUST by naming the request parameter!

<jsp:useBean id=”person” type=”foo.Person” class=”foo.Employee”>
<jsp:setProperty name=”person” property=”name” param=”userName” />
</jsp:useBean>


my question it that useBean has a body which contains setProperty. this body runs CONDITIONALLY if there is no attribute with the name "person" in the page scope. so lets say that there IS an attribute with the name "person" in the page scope. in that case the body of useBean tag won't run and hence there WONT be any setting of the name property of person object as is said in above lines from the book. am i right ? am i missing something ? please help
Regards
 
Stefan Evans
Bartender
Posts: 1720
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your interpretation is correct.
You do not appear to be missing anything.

The tags nested within a useBean tag are executed only when it is instantiating the bean.

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Your interpretation is correct.
You do not appear to be missing anything.

The tags nested within a useBean tag are executed only when it is instantiating the bean.



thanks. but the book says that param attribute helps in set the value of a property to request parameter. but if the person attribute already exists in the given scope the set property tag won't even run and hence the param attribute wont be able to set the property. so this means only if person attribute is NOT in the scope does above statement has meaning. but the book makes a statement that param attribute sets the property.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic