Reputation: 2327
Ok, so basically I have a jspf template file with a backing FragmentBean that I want to include multiple times in the same request page scope. When I include this template I pass it a different parameter value so I can identify which instance I'm dealing with inside the template and store the data correctly in a session map. The problem I'm having is any action I perform on one included instance of this template applies to all the other ones. So for example when I click a button to hide or unhide panels inside the template all of the included instances also hide and unhide their corresponding hidden panels. This lead me to realize that it is not creating new backing bean instances. It seems like I'm probably misusing jsp:include but how do I get the desired code-reuse of including a single jsp file multiple times?
I'm limited to JSF 1.2, JSTL 1.1 and JBoss 4.0.4. So no RichFaces ajax trickery. And yes I realize we need to upgrade. Another battle for another time.
Upvotes: 0
Views: 1962
Reputation: 2635
You are right, in that it is using the same instance multiple times, so any event or action updates that specific managed bean and the same information is reflected everywhere you have included your page.
When you include multiple times, it does not mean a new instance every time.
What you can do is pass parameters to identify from where you are including and then do some functionality.
Another trick, is to declare multiple declarations with a different session variable.
Upvotes: 3