Whats the correct way to create multiple instances of managed beans in JSF 2.0

后端 未结 3 2041
别跟我提以往
别跟我提以往 2020-12-18 03:20

If I want to create more than one instance of managed bean in JSF 2.0, under different names in the same scope, how should I proceed? Ideally, I want the equivilant to (for

3条回答
  •  猫巷女王i
    2020-12-18 03:53

    One possibility is to make your class abstract and subclass it into as many named instances as you need, which you may leave empty. This will also help you separate future managed bean functionality which really only concerns one of the cases.

    You will have to move the @ManagedBean (and scope) annotation to all the subclasses, regrettably, even though it is @Inherited. For the current version of Mojarra atleast, others I don't know.

提交回复
热议问题