0

我怎么在zul格式页面中调用JavaBEAN?

asked 2010-10-19 21:55:13 +0800

thflove99 gravatar image thflove99
54 1

to Dear All : i'm beginner in develope,so i have to learn from your. thank for all's help.
i follow the Data binding Sample to use JaveBean in my ZUL page, like is:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>

<window >
<zscript><![CDATA[
//prepare the example person object
Person person = new Person();
person.setFirstName("Tom");
person.setLastName("Hanks");
]]>
</zscript>

<grid width="400px">
<rows>
<row> First Name: <textbox value="@{person.firstName}"/></row>
<row> Last Name: <textbox value="@{person.lastName}"/></row>
<row> Full Name: <label value="@{person.fullName}"/></row>
</rows>
</grid>
</window>


But is error, the error information is this:


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.zkoss.zk.ui.UiException: Sourced file: inline evaluation of: `` //prepare the example person object Person person = new Person(); . . . '' : Typed variable declaration : Class: Person not found in namespace : at Line: 6 : in file: inline evaluation of: `` //prepare the example person object Person person = new Person(); . . . '' : Person

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.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:122)
org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:310)
org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:796)
org.zkoss.zk.ui.impl.UiEngineImpl.execNonComponent(UiEngineImpl.java:753)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:553)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:498)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:631)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:587)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:531)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:498)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:378)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:299)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:229)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:165)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

How can i do it? I hava write a JaveBean in my project, the Path is Test.Person.
How can i use the javaBean in zul Page? I want the ZUL page read the data From DataBase and Show it in zul.page,but the first job,i must let the zul Page show the date from JavaBean.
Thank for all!

大家好,英文版的估计还是深夜,我是ZK的初学者,今天有个任务是从数据库中取数据显示到页面,我看了ZK数据绑定的相关教程,也跟着它的例子写了一个,但是在运行时,提示错误,我建立的Person类在页面上无法识别,我想知道ZUL页面中用什么方法才可以引用JAVABEAN啊? JSP中是用useBean标签的,那ZUL里面呢?
不胜感激!

delete flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2010-10-21 21:09:54 +0800

iantsai gravatar image iantsai
2755 1

在你的<zscript>開始的地方加一行:

import my.app.bean.Person;

link publish delete flag offensive edit

answered 2010-10-26 00:54:58 +0800

thflove99 gravatar image thflove99
54 1

谢谢,我这个问题已经解决。只是这里我现在用不上,当时是想用bean.getID的方法,将相应的值放到页面上去。

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: 2010-10-19 21:55:13 +0800

Seen: 892 times

Last updated: Oct 26 '10

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