managed bean init nach page load

A

Alexander Burger

Hallo,

bei einem page load mit jsf wird die managed bean initialisiert.

Nun dauert die Initialisierung viele Sekunden.
So lange wird die Seite nicht angezeigt.

Ich wuerde nun gerne erst die Seiten darstellen lassen und dann im
Hintergrund die managed bean mit Werten füllen, die erst später benötigt
werden.

ich verwende jsf 2.0

zuerst hatte ich es mit dem constructor und darin einem thread versucht.
dann mit einem @postconstruct und einer init-methode.

Das Problem ist, dass ich irgendwie nicht auf das managed bean zugreifen
kann. Ich erhalte immer eine nullpointer-exception.
Auch habe ich versucht, das managed bean nochmals aus dem faces zu holen.

Hat da jemand einen Ratschlag, wie man ein solches Problem löst?

Danke für Hilfen.

Gruß
Alex
 
A

Arne Vajhøj

bei einem page load mit jsf wird die managed bean initialisiert.

Nun dauert die Initialisierung viele Sekunden.
So lange wird die Seite nicht angezeigt.

Ich wuerde nun gerne erst die Seiten darstellen lassen und dann im
Hintergrund die managed bean mit Werten füllen, die erst später benötigt
werden.

ich verwende jsf 2.0

zuerst hatte ich es mit dem constructor und darin einem thread versucht.
dann mit einem @postconstruct und einer init-methode.

Das Problem ist, dass ich irgendwie nicht auf das managed bean zugreifen
kann. Ich erhalte immer eine nullpointer-exception.
Auch habe ich versucht, das managed bean nochmals aus dem faces zu holen.

Hat da jemand einen Ratschlag, wie man ein solches Problem löst?

May I suggest posting a copy translated to English - that
will increase the number of potential responders.

Arne
 
A

Arved Sandstrom

May I suggest posting a copy translated to English - that
will increase the number of potential responders.

Arne

There's also a subset of us who can _read_ and comprehend the German but
would feel more comfortable responding in English, but don't in turn
know how well Alexander would get the English.

FWIW it's a JSF 2.0 managed bean initialization question. Whatever is
being done during initialization is a lengthy operation. The OP would
like to background the long-duration work. What's been tried is a thread
in the ctor, and also an init method with the @PostConstruct annotation.

There is evidently a problem in getting at (working with) the managed
bean, with NPEs resulting.

Advice is sought. :)

For my part I have the following questions of the OP:

1. What's the scope of the managed bean? I'm guessing it's not request,
but I don't know that;

2. What's the nature of the initialization? It's presumably, judging by
the OP's indication that he'd like to display the view and have the
long-duration init happen in the background, not required for rendering
the first view. Is it needed for possible postback? How granular is it -
one homogeneous length op, or several operations?

AHS
 
R

Robert Klemme

bei einem page load mit jsf wird die managed bean initialisiert.

Nun dauert die Initialisierung viele Sekunden.
So lange wird die Seite nicht angezeigt.

Apparently Alexander has a web application which initializes a JMX
bean during page access. Initialization takes long ("many seconds")
which of course delays the page display. IMHO that design is flawed
and the JMX bean should be initialized at application load time. See
for example

http://download.oracle.com/docs/cd/...nitialized(javax.servlet.ServletContextEvent)

Cheers

robert
 
A

Alexander Burger

Alexander said:
Hallo,

bei einem page load mit jsf wird die managed bean initialisiert.

Nun dauert die Initialisierung viele Sekunden.
So lange wird die Seite nicht angezeigt.

Ich wuerde nun gerne erst die Seiten darstellen lassen und dann im
Hintergrund die managed bean mit Werten füllen, die erst später benötigt
werden.

ich verwende jsf 2.0

zuerst hatte ich es mit dem constructor und darin einem thread versucht.
dann mit einem @postconstruct und einer init-methode.

Das Problem ist, dass ich irgendwie nicht auf das managed bean zugreifen
kann. Ich erhalte immer eine nullpointer-exception.
Auch habe ich versucht, das managed bean nochmals aus dem faces zu holen.

Hat da jemand einen Ratschlag, wie man ein solches Problem löst?

Danke für Hilfen.

Gruß
Alex

Hello,

sorry a lot, that I didn't translate it. sorry.

so here the translation:

during a page load with jsf the initialization of managed bean will be done.

Just that initialization of that beans needs a lot of time.
For that time, there is no display of the page.

I would like now, that the page is be displayed and after that,
in background, the initialization of the managed bean will be done.
The values of that bean will be used later in the website.
So there wouldn't be a conflict doing that.

I'm using jsf 2.0

first I used a constructor and inside a thread.
After that I used @postconstruct and the init-method.

But the problem is, that I don't have access to the bean-object during the
thread process. I get a nullpointer exception in the thread in the case I
try to connect to the object of the bean.
Also I tried to get the bean from the faces. But no success.

Is there anybody, which could help me with some advice?

thank you in advance.

regards
Alex
 
A

Alexander Burger

Arved said:
There's also a subset of us who can _read_ and comprehend the German but
would feel more comfortable responding in English, but don't in turn
know how well Alexander would get the English.

FWIW it's a JSF 2.0 managed bean initialization question. Whatever is
being done during initialization is a lengthy operation. The OP would
like to background the long-duration work. What's been tried is a thread
in the ctor, and also an init method with the @PostConstruct annotation.

There is evidently a problem in getting at (working with) the managed
bean, with NPEs resulting.

Advice is sought. :)

thank you for translation :)
For my part I have the following questions of the OP:

1. What's the scope of the managed bean? I'm guessing it's not request,
but I don't know that;

no, it is session.
2. What's the nature of the initialization? It's presumably, judging by
the OP's indication that he'd like to display the view and have the
long-duration init happen in the background, not required for rendering
the first view.

yes, exactly.
Is it needed for possible postback?

sorry, what is postback?
How granular is it -
one homogeneous length op, or several operations?
Well in that managed bean there a several data taken from database
into private values. That database access needs a lot of time.
These data will be used on a later view.
Of course I could load it later, when I need it there.
but in that case I have the same problem on that later view.
That was my first solution.

So my idea, I just do it when managed bean is created, but in background.
The user wouldn't notice that.
And when user need it, it is already loaded.


thank you for your answer.

regards
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top