0

ZK JSP Tags and method calling on spring bean

asked 2009-01-29 18:04:42 +0800

Donz gravatar image Donz
54 1

updated 2009-01-29 18:05:27 +0800

Hello.
I use Spring Web MVC and need to get Ajax and some components from ZK. So I try following code:

<%@ taglib uri="http://www.zkoss.org/2005/zul/jsp/" prefix="z" %>
<z:variable-resolver use="org.zkoss.zkplus.spring.DelegatingVariableResolver"/>
...
<z:page>
<z:textbox name="sample" value="${cardListController.test}"/>

Where cardListController my Spring controller with variable test with getter and setter. But I get only:

org.zkoss.zk.ui.UiException: javax.servlet.jsp.JspException: java.lang.NullPointerException
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
org.zkoss.lang.Classes.newInstance(Classes.java:78)
org.zkoss.lang.Exceptions.wrap(Exceptions.java:164)
org.zkoss.zk.ui.UiException$Aide.wrap(UiException.java:46)
org.zkoss.jsp.zul.impl.RootTag$MyRichlet.service(RootTag.java:307)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:398)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:292)

while jsp parsing.

What do I do wrong?
And may be could you advise me the better way to use ZK Ajax with Spring Web MVC? I need to access ModelAndView objects and form object from ZK tags. And I need only something like
<z:textbox name="sample" onChange="${cardListController.bar( ${myForm} )}"/>
I found out how to call static method on full named class, but it's not convenient, cause I need to access non-static fields in my spring controller.

delete flag offensive retag edit

5 Replies

Sort by » oldest newest

answered 2009-01-31 01:26:51 +0800

Donz gravatar image Donz
54 1

Is it possible at all?

link publish delete flag offensive edit

answered 2009-02-02 04:01:34 +0800

windperson gravatar image windperson
415 1

Hi Donz,
You can refer this smalltalk to get ZK Integrated with Spring:
http://www.zkoss.org/smalltalks/zkspringwf/

link publish delete flag offensive edit

answered 2009-02-02 16:58:51 +0800

Donz gravatar image Donz
54 1

Thanks, but I've already read it, and it isn't explain some thins that unobvious for me.
But it seems I have right decision

link publish delete flag offensive edit

answered 2009-02-03 04:24:03 +0800

windperson gravatar image windperson
415 1

Hi Donz,
Can you provide a runnable sample code of your work? Thx.

link publish delete flag offensive edit

answered 2009-02-03 13:48:47 +0800

Donz gravatar image Donz
54 1

Hello.
My investigation follows:

<%@ page contentType="text/html;charset=windows-1251" language="java" pageEncoding="windows-1251" %>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%--Include Spring context--%>
<z:variable-resolver use="org.zkoss.zkplus.spring.DelegatingVariableResolver"/>
<%-- Use annotation binding --%>
<z:init use="org.zkoss.zkplus.databind.AnnotateDataBinderInit"/>

<form:form method="post" action="${contextPath}/cards/list.html" name="form.cards">
    <z:page>
        <%--Variables for ZK--%>
        <z:variables command="${command}" local="false"/>
        <z:variables cardList="${cardList}" local="false"/>
        <z:variables testLabelText="Тестовая метка" local="false"/>
        <%--Use ZK var with annotation binding--%>
        <div class="bl04"><z:label id="testLabel" value="@{cardList}"/></div>
        <%--Use spring object. This label couldn't be updated because of not using ZK var--%>
        <div class="bl04"><z:label id="testLabel2" value="${cardList[0]}"/></div>
        <div class="bl03"> </div>
        <div class="bl04">
            <div class="bl05r2">
                <div class="bl05l">
                    <%--Calling method from spring bean with ZK vars as parameters and update component 'testLabel'. In my case method showTrashed remove first element of cardList list--%>
                    <div class="chkbx1"><z:checkbox name="showTrashed"
                                                    onCheck="cardListController.showTrashed( command, cardList );
                                                    binder.loadComponent( testLabel )"/></div>
                </div>
                <div class="select_txt"><spring:message code="checkTrashedLabel"/></div>
            </div>
        </div>
    </z:page>
</form:form>

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2009-01-29 18:04:42 +0800

Seen: 446 times

Last updated: Feb 03 '09

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