0

NullPointerException on createComponents() with MVVM

asked 2013-08-06 03:28:37 +0800

anthonylau gravatar image anthonylau
17 2

updated 2013-08-06 03:32:01 +0800

I have a zul:

<window title="Templates" border="normal" zclass="z-window-overlapped"
                apply="org.zkoss.bind.BindComposer"  sizable="true"
                viewModel="@id('vm') @init('com.foo.TemplateViewModel')"
                onSize="System.out.println(self.getHeight())">
                <listbox id="templateListbox" model="@load(vm.templates)"
                    onSelect="@command('onSelect')" vflex="1"
                    selectedItem="@bind(vm.selectedEvent)" >
                    <listhead sizable="true">
                        <listheader label="Name" sort="auto" />
                        <listheader label="Description" sort="auto" />
                    </listhead>
                    <template name="model" var="tpl">
                        <listitem>
                            <listcell label="@load(tpl.key)" />
                            <listcell label="@load(tpl.description)" />
                        </listitem>
                    </template>
                </listbox>
            </window>

I create component:

Component comp = Executions.createComponents("/mvvm.zul", null, null); comp.setParent(parent);

I will get NullPointerException:

Encounters an error: Unknown exception: java.lang.NullPointerException.

java.lang.NullPointerException 
    at org.zkoss.bind.impl.AbstractRenderer.resoloveTemplate(AbstractRenderer.java:59) 
    at org.zkoss.bind.impl.BindListitemRenderer.render(BindListitemRenderer.java:41) 
    at org.zkoss.zul.Listbox$Renderer.render(Listbox.java:2644) 
    at org.zkoss.zul.Listbox.renderItems(Listbox.java:2762) 
    at org.zkoss.zul.Listbox.service(Listbox.java:3490) 
    at org.zkoss.zk.ui.impl.DesktopImpl.service(DesktopImpl.java:701)

There is no exception if I access the zul through URL.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-08-06 05:43:35 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Yes right... if you directly access the zul it should work no any doubt.But when you trying to create zul with this below code

Executions.getCurrent().createComponents("/modalWindow.zul",
                view, null);

You can not pass null in place of Component class object so you have to use like this

@Command
    public void openModal(@ContextParam(ContextType.VIEW) Component view){
        Executions.getCurrent().createComponents("/modalWindow.zul",
                view, null);
    }
link publish delete flag offensive edit

Comments

Thanks for the reply.

I tried to create component in Composer with "this.getSelf()" but still encounter NullPointerException

Executions.createComponents("/mvvm.zul", this.getSelf(), null);

anthonylau ( 2013-08-06 07:22:33 +0800 )edit

Share your Java code

sjoshi ( 2013-08-06 07:32:54 +0800 )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: 2013-08-06 03:28:37 +0800

Seen: 72 times

Last updated: Aug 06 '13

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