1

ZK MVC : how can i wait till the compose of another componant

asked 2014-05-28 15:08:13 +0800

elmetni gravatar image elmetni
145 7

updated 2014-05-28 16:38:30 +0800

hello , i m working on a ZK project , using ZK MVC approach. what i did try to do is to initalize "a panel" after doAfterCompose a div , but the problem is that i got a "java.lang.NullPointerException"

java.lang.NullPointerException dashboard.display.doAfterCompose(display.java:24) dashboard.display.doAfterCompose(display.java:1)

and those are a simple exemple of what i did try to do . My view "mypage.zul"

<zk>
<borderlayout>
     <west width="140px" splittable="true" collapsible="true" maxsize="140">
        <div align="center" apply="dashboard.display">
                    <label value="WorkLoad"></label><checkbox></checkbox>
        </div>
     </west>

     <center autoscroll="true"  >
      <div>
        <portallayout id="portalLayout" maximizedMode="whole" width="100%" >

            <portalchildren   >
                  <panel  id="panelworkload"   >
                        <panelchildren>  
                            <div width="100%"  >
                            <charts  id="workloadDay" type="column" />
                            </div>  
                        </panelchildren>
                  </panel>
             </portalchildren>            
         </portallayout> 
       </div>
    </center>

</borderlayout>
</zk>

My conroler : "display"

public class display extends SelectorComposer<Div>{

@Wire
Checkbox  objectif_checkbox;

@Wire
Panel  panelworkload;

public void doAfterCompose(Div comp) throws Exception {
    super.doAfterCompose(comp);

    panelworkload.setTitle("hello workload");

    }
}

and this is the exception that i got

java.lang.NullPointerException dashboard.display.doAfterCompose(display.java:24) dashboard.display.doAfterCompose(display.java:1) org.zkoss.zk.ui.impl.UiEngineImpl.doAfterCompose(UiEngineImpl.java:578) org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:880) org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:826) org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:735) org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:699)

what i have throught of it so far is that the div has been composed before the portallayout , that why the server cant reconize portallayout when div is created

can anyone help me pls ? i m kinda stuck here ...and thank you

delete flag offensive retag edit

Comments

hello mhj , sry i cant comment on ur post yet so i will put my replay here :) ya i have noticed it and i corrected it , it still give me the same exception , this s not my realy project i wrote this simple example to decript my case i dont know really what i have done wrong .

elmetni ( 2014-05-28 16:43:01 +0800 )edit

i edit the post , u can try the code source to see if you can find something about it , and thank you so much

elmetni ( 2014-05-28 16:43:35 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-05-29 02:46:55 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

I believe your problem is that the panel is not in the div's hierarchy, look what happens in zkfiddle: link

link publish delete flag offensive edit
1

answered 2014-05-29 14:52:24 +0800

elmetni gravatar image elmetni
145 7

updated 2014-05-29 14:53:05 +0800

Ya exactly , i solved the problem by adding another doAfterCompose methode to wait till initialisation of panel . the code source was something like this

SelectorComposer<Panel> s = new SelectorComposer<Panel>();

        s.doAfterCompose((Panel)comp.getParent().getParent().getParent().getParent()....getChildren().get(0));

thank you bro for pointing to the problem

link publish delete flag offensive edit
0

answered 2014-05-28 16:36:23 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

Hello elmetni, i saw that you declared differents names for panelworkload (panelworkload on zul and panelworkloadday on java) maybe that helps you...

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-05-28 15:08:13 +0800

Seen: 27 times

Last updated: May 29 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More