0

ZK JSF problem

asked 2009-01-17 15:31:42 +0800

lendle gravatar image lendle
213 3

Hello, I'm trying to configure zk with JSF. The version of zk is 3.5.2, with zk JSF component 2.0 and myfaces 1.2.5

The jsf page is like the following:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://www.zkoss.org/jsf/zul" prefix="z"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <f:view>
            <z:page>
                <z:window title="HelloWorld!">
                    <z:textbox id="t1" f:value="#{JpaResourceBean.value}"/>
                    <h:inputText value="#{JpaResourceBean.value}"/>
                </z:window>
            </z:page>
        </f:view>

    </body>
</html>

When running, z:textbox always displays ValueExpression[#{JpaResourceBean.value}]
but h:inputText renders correct value.

The following is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>

    <listener>
		<description>
			Used to cleanup when a session is destroyed
		</description>
		<display-name>ZK Session Cleaner</display-name>
		<listener-class>
			org.zkoss.zk.ui.http.HttpSessionListener
		</listener-class>
	</listener>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
		<description>ZK loader for ZUML pages</description>
		<servlet-name>zkLoader</servlet-name>
		<servlet-class>
			org.zkoss.zk.ui.http.DHtmlLayoutServlet
		</servlet-class>
		<!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet).
			It must be the same as <url-pattern> for the update engine.
		-->
		<init-param>
			<param-name>update-uri</param-name>
			<param-value>/zkau</param-value>
		</init-param>
		<!-- Optional. Specifies the default log level: OFF, ERROR, WARNING,
			INFO, DEBUG and FINER. If not specified, the system default is used.
			<init-param>
			<param-name>log-level</param-name>
			<param-value>OFF</param-value>
			</init-param>
		-->
		<load-on-startup>1</load-on-startup><!-- Must -->
	</servlet>

    <servlet>
		<description>The asynchronous update engine for ZK</description>
		<servlet-name>auEngine</servlet-name>
		<servlet-class>
			org.zkoss.zk.au.http.DHtmlUpdateServlet
		</servlet-class>
	</servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zul</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zhtml</url-pattern>
	</servlet-mapping>

    <servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>/zk/*</url-pattern>
	</servlet-mapping>

    <servlet-mapping>
		<servlet-name>auEngine</servlet-name>
		<url-pattern>/zkau/*</url-pattern>
	</servlet-mapping>


	<!--
		ZULJSF , Optional. Uncomment it if you never acces faces bean in zul component
		To access faces bean , use org.zkoss.jsf.zul.util.ContextUtil.getBean(beanName:String);
	-->
	<filter>
		<filter-name>ZK FacesContext Filter</filter-name>
		<filter-class>
			org.zkoss.jsf.zul.util.HttpFacesContextFilter
		</filter-class>

		<init-param>
			<param-name>update-uri</param-name>
			<param-value>/zkau</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>ZK FacesContext Filter</filter-name>
		<servlet-name>zkLoader</servlet-name>
	</filter-mapping>
	<filter-mapping>
		<filter-name>ZK FacesContext Filter</filter-name>
		<servlet-name>auEngine</servlet-name>
	</filter-mapping>

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/welcomeJSF.jsp</welcome-file>
        </welcome-file-list>
    </web-app>

Is there anything wrong in my configuration?

Thanks!

delete flag offensive retag edit

11 Replies

Sort by ยป oldest newest

answered 2009-01-17 18:38:02 +0800

jtoupin gravatar image jtoupin
156

I do not know much about JSF but shouldn't that be:

${JpaResourceBean.value}

?

link publish delete flag offensive edit

answered 2009-01-18 03:36:11 +0800

lendle gravatar image lendle
213 3

Oops......
Yes, <z:textbox id="t1" f:value="${JpaResourceBean.value}"/>
produces correct result.

However, since standard JSF components requires #{JpaResourceBean.value},
the syntax used by zk JSF components seems confusing.

Furthermore, the official example and tutorial use #{......} syntax, it seems
a correction is needed.

link publish delete flag offensive edit

answered 2009-01-18 03:54:46 +0800

lendle gravatar image lendle
213 3

Oops again......

Although <z:textbox id="t1" f:value="${JpaResourceBean.value}"/> may render correct result,
it appears that the textbox is not actually bound to JpaResourceBean.value, since update
will have no effect.

So, there must be problem in my configuration, but I don't know how to correct it.

Any suggestion is appreciated, thanks!

link publish delete flag offensive edit

answered 2009-01-18 04:36:40 +0800

lendle gravatar image lendle
213 3

After some further test,

the problem disappear if the same project is deployed to tomcat 6.0.18
the problem only appears on glassfish 2/3

is there any conflict between zk jsf and glassfish? thanks!

link publish delete flag offensive edit

answered 2009-01-19 01:15:50 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

What is the error message whenr running glassfish,
Please check your jsf configuration/jar in web application and application server, I guess some runtime are embedded in some application server.

link publish delete flag offensive edit

answered 2009-01-21 14:30:42 +0800

lendle gravatar image lendle
213 3

Hello, dennis:
The most problem is, there is no error message at all when running glassfish.
Moreover, when testing with tomcat, I used exactly the same JSF jar files (I copied
Sun's JSF RI from glassfish to tomcat).
Is there any other possibilities I could try?
thanks!

link publish delete flag offensive edit

answered 2009-01-21 14:34:46 +0800

lendle gravatar image lendle
213 3

By the way,
is zk with JSF a good mechanism?
I mean, since zk is AJAX-based while the life cycle of JSF is mostly post-based,
is mixing these two approaches reasonable?
What is the best practice?
Thanks!

link publish delete flag offensive edit

answered 2009-01-22 08:36:29 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

In my experience, use ZK to develop a web application is easier/faster then use JSF (JSF Spec./Runtime is too complex).
ZK JSF use wrapping mechanism to integrate ZK with JSF life cycle. there are too many environment issues to solve in JSF in different runtime I think.

why don't you just use ZK?

link publish delete flag offensive edit

answered 2009-01-29 14:30:27 +0800

lendle gravatar image lendle
213 3

Hello, Dennis:
thanks for your suggestion.
And yes, it seems use data binding of ZK alone is simpler and more reasonable.

By the way, what's your opinion about zk + spring web flow?
I'm now trying to use spring web flow to control logical flow and zk for presentation and data binding.
This architecture appears quite clean and attractive.

link publish delete flag offensive edit

answered 2009-02-02 07:17:18 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

Hi, Lendel, In My personal comment,
ZK provide several MVC features in past of year, it make do MVC and integrate with spring easier.
if you have good system desing and has well desing documents of your project, it is more convenient to do MVC with such feature with spring bean/webflow.
but, if your system is developing without any document(for a fast developing?XP?) I think is will make system hard to maintain(for example, to fine where is the controller , where is the next page).

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-17 15:31:42 +0800

Seen: 282 times

Last updated: Feb 02 '09

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