0

i have a question concerning two java beans, which was declared in faces-config.xml and have two different managed-bean-scopes in JSF 1.2. First of all i would like to explain the problem, which i have now.

I have the possibility to export some information from my java system into an another system (the details of the data and their concret transport way are not so important i think).

Important is in my opinion, that the java bean, which triggers that export, has the managed bean scope "session". The data export works i the background of my system and need this session scope.

The user can see an information in the jsf / xhtml page, that the export was started and here is the concret problem:

<ui:repeat value="#{adminArea.informationForExport}" var="info">
    <h:outputText value="#{info}" />
</ui:repeat>

This information is a part of the HTML DOM each time and will not disappears, if the user watch an another xhtml page in my system and goes back to this xhtml page, on that he can start the data export.

My Bean "adminArea" was declared in faces-config.xml with the managed bean scope "session" and implemented the java code for the data export:

<managed-bean>
    <managed-bean-name>adminArea</managed-bean-name>
    <managed-bean-class>resources.adminArea</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

The declared bean "adminArea" was refered as a managed property in the bean "newCalculation", which was the managed bean scope "request":

<managed-bean>
    <managed-bean-name>newCalculation</managed-bean-name>
    <managed-bean-class>resources.calculation</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>        
    <managed-property>
        <property-name>adminArea</property-name>
        <value>#{adminArea}</value>
    </managed-property>     
</managed-bean>

This bean needs the managed bean scope "request".

Is the only way the change the managed bean scope of the bean "adminArea" from "session" into "request"? But that causes the problem, that my data export doesn´t work in the background.

Or can i solve this problem with other instruments?

Greetz Marwied

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

1

Final answer:

  1. Move to JSF 2.0. It has many useful features described here.
  2. If you want to display specific information on a specific page try to use view scope. Take a look at here to see the difference between Request and View scopes. Try to link user interface directly with view scoped beans. All session or application information you can recieve by ManagedProperty injection.
  3. I suggest you to refuse from xml-configured beans and move to annotations. Good comment about that you can read here.
  4. About background processing in JSF. Those things are usually performed by Enterprise Java Beans (EJBs). Take a look at EJB 3 and maybe Timer Service.
Community
  • 1
  • 1
Maksim
  • 449
  • 4
  • 11
  • That was implemented with java code. You can trigger it by pressing a command button on the jsf page. A flag is set in my database and an another process called every 30 seconds the database and executes the data export. And if the falg was set, the user gets the information on jsf page, which will not dissappears –  Nov 27 '13 at 07:40
  • implemented with java code... I understood this like you create a new thread and start some process over there. Am I wrong? – Maksim Nov 27 '13 at 07:43
  • nothing with thread or something else. I need a init method or something else for this jsf pages, which deleted information for the user on the jsf page –  Nov 27 '13 at 07:44
  • First of all if you want to display specific information on a specific page try to use view scope. Tak a look at [here](http://stackoverflow.com/a/6026009/1051509) to see the difference between Request and View scopes. – Maksim Nov 27 '13 at 07:48
  • Also I suggest you to refuse from xml-configured beans and move to annotations. Good comment about that you can read [here](http://stackoverflow.com/a/5090914/1051509). – Maksim Nov 27 '13 at 07:51
  • And the last one: try to link user interface directly with view scoped beans. All session or application information you can recieve by ManagedProperty injection. – Maksim Nov 27 '13 at 07:57
  • And about background processing in JSF. Those things are usually performed by Entrprice Java Beans (EJBs). Take a look at EJB 3 and maybe Timer Service. – Maksim Nov 27 '13 at 08:07
  • I see multiple references to the view scope and annotations, but as far as I know that is all JSF 2 specific and the question clearly states that this is a JSF 1.2 application. – Gimby Nov 27 '13 at 08:57
  • Yes, you're right. Did not noticed this. Will correct my answer. – Maksim Nov 27 '13 at 09:03