I have a backing bean, and I’d like to load up a few lists when the bean is instantiated, so that the list may be used in a dropdown.
Is there a method that only gets called when the bean is first made?
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 could use a static initializer:
Or if they aren’t static lists then an initializer block:
Tutorial here.
EDIT* Remember that these backing beans are just POJOs and work like any other Java object. You can set up faces-config.xml like such:
Personally I find it easier to just us an initializer block. That’s what they are for.