I have a slight problem I have a bean, session scope with two methods I call
From the UI (web front end) if I click one button i want a certain method to be called, otherwise a different method.
The issue is that the constrcutor is called each time, which resets some values, does anybody know of a work around? How could i possibly tackle this issue? Is it possible for me to examine which button is has requested the method, so I could direct the requested to the relevant method?
Can you post your web page code and the bean. Do you have any bean variables being referred on the page? It is possible that this session bean is being called the first time when you hit that button. So the constructor gets called. Add a variable to this bean and use that in the web page in some way(give style hidden if you do not want to be displayed). This way, the constrcutor will be called before the web page is displayed in order to 'get' the new variable. Now when you hit the button, the constructors should not be called since the bean is already initialized by this time.
But I would like to see the code to understand the exact problem.
Something's wrong here. If you declare a bean with session scope, it's constructed when originally referenced, then stored until the session is destroyed - either because it was explicitly invalidated or because it timed out. A constructor can ONLY be called when the bean is first constructed, so what you're describing sounds more like a bean with request scope.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Mar 31, 2005
Hi there guys,
Sorry for the delay in reply.
Sill mistake, faces-config.xml was set as request... took a while, it's sorted now thanks.