-1

is it possible to have the same Bean with two different scopes in JSF 1.2?? What I mean is:

<managed-bean>
    <managed-bean-name>beanOne</managed-bean-name>
    <managed-bean-class>files.bean.BeanOne</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
            <property-name>someConfiguration</property-name>
            <value>#{configurationBean}</value>
    </managed-property>
</managed-bean>


<managed-bean>
    <managed-bean-name>beanOne</managed-bean-name>
    <managed-bean-class>files.bean.BeanOne</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
            <property-name>someParam</property-name>
            <value>#{param.value}</value>
    </managed-property>
</managed-bean>

Obviously, this solution doesn't work but it's what I want to do without having the same BeanOne two times with different names! Thanks!! ;)

Natiya
  • 463
  • 2
  • 9
  • 25

1 Answers1

0

Its not possible to have same bean with two different scopes. In your case, please give a different name to your other bean and have two different beans (one in request scope and the other in session scope)

To know more you can refer to some good posts by BalusC

Link1 & Link2

Community
  • 1
  • 1
Vikas V
  • 3,176
  • 2
  • 37
  • 60
  • ok, thanks!! finally, I've fixed my problem using this alternative: var params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); String someValue = params.get("someName"); so, I don't have to created another bean!! :) – Natiya Dec 18 '12 at 08:36
  • In your `faces-config.xml` , what is the `scope` to which you have mapped your bean to? – Vikas V Dec 18 '12 at 11:39