0

Actualy I want after clicking logout session get invalidate. But it is going firstly on getter setter and there I created a session. After that is goes to session invalidate method. And it will throw exception.

How would I skip getter setter on click of button and directly call the action method?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

0

Just don't do business job in getters/setters. The getters/setters should solely do the things as their name suggests: returning a property or setting a property. Nothing more. It should not load/preinitialize properties. The loading/preinitializing should be done by a (post)constructor or action(listener) method.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Can I call Directly to method for rendered which can give me true and false in return. – user1304570 Apr 03 '12 at 12:50
  • Yes, if you prepare it in (post)constructor of the bean or action(listener) of a previous request, as said. This is less costly if the bean is in view scope. It's hard to give a kickoff code example as long as you don't show the code of your current approach in flavor of an SSCCE. – BalusC Apr 03 '12 at 12:59
  • can u please elaborate it little bit with example – user1304570 Apr 03 '12 at 13:02
  • General examples are already given in the "See also" link. A specific example suitable for your case cannot be given because your current functional requirement and code approach is not clear, as said. I can for example not imagine a sensible real world use case of creating the session in a getter. – BalusC Apr 03 '12 at 13:06