Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The time of listener methods called

 
Russell Tao
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if there is any reson behind the time of listener methods is called?
eg. in HttpSessionBindingListener,
valueBound method will be called before the object is accessible through getAttribute method
valueUnbound method will be called after the object is removed from the session

Cause so many listeners, hardly to remember all of them.
[ February 26, 2006: Message edited by: Russell Tao ]
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because, in the exam, you can be given a chunk of source code, and the answer will depend on the events happening 'before' or 'after'

e.g. counters
 
Russell Tao
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesus Angeles:
because, in the exam, you can be given a chunk of source code, and the answer will depend on the events happening 'before' or 'after'

e.g. counters


Yes. I wonder how to remember those 'before' and 'after'. If there is a reason behind it, then it can be easy to remember.
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have HF, there is a good explanation to remember this: (pg183 question)

It goes like this. Imagine the bean is populated with info from a database. You want your bean to know every time it is added to a session, so that you can repopulate the bean and get the latest info. So call valueBound() before getAttribute(), so that you are assured of keeping the bean in sync with the database.

I hope I am right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic