开发者

Order to execute method while loading JSF page

I've got 2 Controllers.

FirstController

One will go to the DB and make a count(*) to see how many messages are unread.

SecondController

The other will open the message and when it opens, if it is unread, it'll be marked as read.


The problem that i'm facing is that when I open the JSF page, it executes first the fir开发者_Python百科stcontroller and then the second one. So it does not refresh how many messages I still have unread.

Is it possible to set an order to execute methods while opening the page?

The page looks like a left side menu, that contains how many messages are unread, and in the center will open the message.

How can I do it?


You didn't exactly give any details on how "JSF executes the firstcontroller". Is this via a preRenderViewEvent handler, a @PostConstuct method, or what?

From you problem description, it sounds like the order already happens to be correct? You say that the firstcontroller is executed, and this FirstController checks for unread messages. So messages are being 'refreshed'. But then you say that it does not refresh the unread messages, so which is it?

Regardless, a single JSF view (page) is best backed by a single backing bean. This single backing bean orchestrates calls to different services (e.g. EJB beans) and prepares all required data. The view then binds to this backing bean only to fetch its data.

With this setup you won't run in any execution order problems at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜