ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Window constructor always called upon HTTP-request?

mhogendoorn
2 Sep 2010 08:25:42 GMT
2 Sep 2010 08:25:42 GMT

Where would you implement a log of each HTTP request coming to a specific page?

Currently I have this page that holds one Window.
In the *CONSTRUCTOR of this Window* I have programmed the logging into a database table.
But... can I savely assume that for each request coming to this page this window's constructor will be called?

Or is it better to add something like this to the page:
<?init class="MyInit"?> and implement public void MyInit.doInit() ?

Or am I forced to introduce a JEE Filter ?
What is the best you think?

thanks in advance!

YamilBrachoTop Contributor
2 Sep 2010 09:53:08 GMT
2 Sep 2010 09:53:08 GMT

Create a servlet that implements Filter

terrytornadoTop Contributor
2 Sep 2010 13:13:15 GMT
2 Sep 2010 13:13:15 GMT

I mean it's architecture dependend on how your zk application is working.

If you have all pages reachable with an own http address like normal richlets than it's like Yamil said a good way to catch them in a filter servlet.
If you have only ONE index.zul and every zk page are loading in their center area of a borderlayout than it's better to do that in the respective window controller.

best
Stephan

mhogendoorn
2 Sep 2010 13:37:51 GMT
2 Sep 2010 13:37:51 GMT

Yamil,
Yeah, I could surely use a filter... But... perhaps more theoratically... my question remains...

Terry,
There's indeed just one single ZUL
http://my.magic.company/index.zul
having

<window use="my.magic.Window" ...>
Welcome to this wonderful application
</window>

The question I have is:
Is the degault (no-argument) constructor in class my.magic.Window called for *every* request I send to http://my.magic.company/index.zul ?

terrytornadoTop Contributor
2 Sep 2010 14:01:29 GMT
2 Sep 2010 14:01:29 GMT

Hmmmmm, you can check this by debugging.

Do you ask this because you have spring in it?

EDIT: I see you have using use="" without spring. So in this case i would mean yes. But the zk renderer engine would only refresh comps that are modified.

terrytornadoTop Contributor
2 Sep 2010 14:24:53 GMT
2 Sep 2010 14:24:53 GMT

By the way. If you will log the same which is spring managed than you will have a problem.

Next is a sysout from TWO-times refresh a main index.zul:

2010-09-02 21:11:44,046 DEBUG   IndexCtrl M[<init>] - --> super()
2010-09-02 21:11:44,049 DEBUG   UserBarCtrl M[<init>] - --> super()
2010-09-02 21:11:44,054 DEBUG   StatusBarCtrl M[<init>] - --> super()
2010-09-02 21:11:44,064 DEBUG   IndexCtrl M[onCreate$outerIndexWindow] - --> [ForwardEvent onCreate$outerIndexWindow <Window outerIndexWindow>]
2010-09-02 21:11:44,070 DEBUG   MainMenuCtrl M[onCreate$mainMenuWindow] - --> [ForwardEvent onCreate$mainMenuWindow <MainMenuCtrl mainMenuWindow>]
2010-09-02 21:11:44,072 TRACE   ZkossTreeMenuFactory M[<init>] - Needed time for inserting the menu: 1ms
2010-09-02 21:11:44,089 DEBUG   MainMenuCtrl M - --> calling zul-file: /WEB-INF/pages/welcome.zul
2010-09-02 21:11:44,597 DEBUG   IndexCtrl M - Current desktop height :522
2010-09-02 21:11:44,597 DEBUG   IndexCtrl M - Current desktop width  :1564
---------------------
2010-09-02 21:11:48,019 DEBUG   IndexCtrl M[<init>] - --> super()
2010-09-02 21:11:48,022 DEBUG   UserBarCtrl M[<init>] - --> super()
2010-09-02 21:11:48,027 DEBUG   StatusBarCtrl M[<init>] - --> super()
2010-09-02 21:11:48,043 DEBUG   IndexCtrl M[onCreate$outerIndexWindow] - --> [ForwardEvent onCreate$outerIndexWindow <Window outerIndexWindow>]
2010-09-02 21:11:48,053 DEBUG   MainMenuCtrl M[onCreate$mainMenuWindow] - --> [ForwardEvent onCreate$mainMenuWindow <MainMenuCtrl mainMenuWindow>]
2010-09-02 21:11:48,055 TRACE   ZkossTreeMenuFactory M[<init>] - Needed time for inserting the menu: 1ms
2010-09-02 21:11:48,071 DEBUG   MainMenuCtrl M - --> calling zul-file: /WEB-INF/pages/welcome.zul
2010-09-02 21:11:48,527 DEBUG   IndexCtrl M - Current desktop height :522
2010-09-02 21:11:48,527 DEBUG   IndexCtrl M - Current desktop width  :1564

Next is a sysout from loading ONE time a mainModule with several tabs with own controllers in the Center area:

2010-09-02 21:20:00,108 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,126 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,127 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,132 DEBUG   DefaultTreecell M - -->[menu.Item.Articles] calling zul-file: /WEB-INF/pages/article/articleMain.zul
2010-09-02 21:20:00,135 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,137 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,142 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,142 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,144 DEBUG   PagedBindingListWrapper M - --> : listheader_ArtArticleNo
2010-09-02 21:20:00,144 DEBUG   PagedBindingListWrapper M - --> : listheader_ArtShorttext
2010-09-02 21:20:00,144 DEBUG   PagedBindingListWrapper M - --> : listheader_ArtPrice
2010-09-02 21:20:00,195 DEBUG   BaseSearchProcessor M - generateQL:
  select _it from de.forsthaus.XXXXXXXXXX.backend.model.Article _it where _it.tenantId = :p1 order by _it.shorttext asc
2010-09-02 21:20:00,196 DEBUG   HibernateSearchProcessor M - p1: 10
Hibernate: 
    select
        article0_.art_id as art1_12_,
        article0_.VERSION as VERSION12_,
        article0_.art_tnt_id as art3_12_,
        article0_.art_shorttext as art4_12_,
        article0_.art_longtext as art5_12_,
        article0_.art_no as art6_12_,
        article0_.art_base_price as art7_12_,
        article0_.art_list_price as art8_12_,
        article0_.art_total_stock as art9_12_,
        article0_.art_available_stock as art10_12_,
        article0_.art_last_edittime as art11_12_,
        article0_.art_last_edituser as art12_12_ 
    from
        public.prg_article article0_ 
    where
        article0_.art_tnt_id=? 
    order by
        article0_.art_shorttext asc limit ?
2010-09-02 21:20:00,268 DEBUG   BaseSearchProcessor M - generateRowCountQL:
  select count(*) from de.forsthaus.XXXXXXXXXX.backend.model.Article _it where _it.tenantId = :p1
2010-09-02 21:20:00,268 DEBUG   HibernateSearchProcessor M - p1: 10
Hibernate: 
    select
        count(*) as col_0_0_ 
    from
        public.prg_article article0_ 
    where
        article0_.art_tnt_id=?
2010-09-02 21:20:00,284 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,286 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,296 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,297 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,314 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,315 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,316 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,317 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,319 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,320 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,321 DEBUG   ArticleMainCtrl M[<init>] - super()
2010-09-02 21:20:00,321 DEBUG   ArticleMainCtrl M[<init>] - super()

19 times calling the constructor.
This is the result of the multi-threaded events of zk and heavy using of Events.sendEvent() in code. But spring knows that the classes exists. And create it only one time.
But in this case a logging of the visited pages is a hard thing.

best
Stephan