is it possible in java that code in constructor is called only once even if page is refreshed via some actionListener. In C# Page.PostBack method works fine but here in java i can not find right method.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can know when it’s postback with a function such as:
If for every refresh the default constructor is called, that means that your bean is
RequestScoped. A refresh (GET) or a postback (POST) are considered as requests, so the bean will be created for every request. There are other instantiation options such asSessionScopedorApplicationScopedor just instantiate it when a postback occurs, with the above function.Setting the scope a-la-JSF1.2
Edit your
faces-config.xmlfile located under/WEB-INF:you can use
request,sessionorapplication