4 Replies Latest reply on Oct 8, 2008 9:26 AM by Peter Whitmore

    I need some help(please)

    Peter Whitmore Newbie


      I've been struggling to solve an issue regarding showing the progress of a long operation.

      I bet this is an rtfm question but I haven't been able to find the answer despite searching here, in google and other forums.

      my environment is JBoss 4.2.2 Seam 2.1.0BETA 1 and richfaces 3.2.2GA.

      Now the problem:

      I have a backing bean which is used for showing the progress(SessionProgressBean). It's scope is set to ScopeType.SESSION, it is not an ejb.

      I have another bean which is a stateful ejb also with the seam scopetype set to session. Into this bean i have injected the SessionProgressBean using the

      @In(value="#{sessionProgressBean}", scope=ScopeType.SESSION)

      The long running method is invoked via an action in another session bean via a page using an ajax form and button.


      I have a page which uses the sessionProgressBean to display a rich:progressBar with it's information. This page works fine on it's own and when I invoke the start via the sessionProgressBean as in the example supplied with richfaces.

      Now before you start crying THIS IS A RICHFACES ISSUE, please here me out.

      When I output the sessionProgressBean to the console, I clearly get two different instances depending on whether the progressbar is polling or a setter is used on the injected bean during the long running process. My assumption was that a bean declared in the session would be unique for that session.

      The main reason for me doing this (apart from nicer ui) was to give the user an opportunity to cancel the operations similar to how it is done in any swing gui. It is important for my application and I would therefore appreciate any help or simple examples to help me see the error of my ways.

      Basically what am I doing wrong?

      Thanks in advance.


        • 1. Re: I need some help(please)
          Olivier Thierry Apprentice

          Don't know if it's the reason of your problem, but when I see this :

          @In(value="#{sessionProgressBean}", scope=ScopeType.SESSION)

          It means that you inject a component which name is returned by a component called sessionProgressBean, and not a component which name is sessionProgressBean.

          Maybe you should have written this instead :

          @In(value="sessionProgressBean", scope=ScopeType.SESSION)

          • 2. Re: I need some help(please)
            Mikael Andersson Master

            Are you sure that the session bean isn't wrapped in a proxy and that it is the proxy instance which is different?

            Also if the sessionProgressBean is Session scoped you shouldn't need to specify it when in injecting.

            What you might want to add is a craeate=true just incase it doesn't exist.

            Sort of lost track of your problem when reading the post, is the problem that you are seeing two different beans (which might simply be the proxy).

            Not much help but perhaps useful info :)


            • 3. Re: I need some help(please)
              Peter Whitmore Newbie

              Thanks for the tips.

              @Olivier: is there a big difference between the two? The bean has the @Name attribute set to sessionProgressBean. (Is this a case of RTFM?) I'll try it out and see if there is a difference.

              @Micke: The problem is that I seem two have two different instances in the seam Session. One is the instance assigned to my web page and one is the instance inside my ejb/seam backing bean doing the long-running task. To verify this I did some sysout with the instance and the output had two different id's. ie MyClass@1234 from the web page and MyClass@5789 from the backing bean.

              I assumed that seam manages the beans in a session that they are unique to that session and that any session scope bean would be able to access the same instance of the bean and manipulate the data. Am I wrong and if not, what are the possible causes of my problem?


              • 4. Re: I need some help(please)
                Peter Whitmore Newbie

                Olivier thanks:

                Your suggestion about the syntax gave me the same instance as was used in the web page. I am a little confused as to how this makes a difference. I guess a book is going to have to be bought and of course read.