【发布时间】:2012-01-17 06:56:43
【问题描述】:
我是 JQuery 的新手。我正在尝试在 JSF 中使用 jQuery 来隐藏和显示组件。虽然用 JSF 很容易实现,但我的要求还是用 jQuery 来实现。
但我无法隐藏任何组件。 代码sn-p是:-
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JQuery Effects</title>
<script type="text/javascript" src="script/jquery-1.7.1.js" >
function showSuccess()
{
jquery("#formId\\:showLinkId").click(function(){
jquery("#formId\\:success").hide('slow',function(){
alert('Hide Done');
});
});
}
</script>
</head>
<body>
<f:view>
<h:form id="formId">
<rich:panel header="Jquery" style="position: relative; width: 350px;">
<h:commandButton id="showLinkId" value="Click Here" onclick="showSuccess()" />
<h:outputLabel id="success" value="DONE" ></h:outputLabel>
</rich:panel>
</h:form>
</f:view>
</body>
</html>
但是在 GUI 上看不到任何效果。 脚本文件保存在 WebContent/script 中。
我什至尝试在页面之间包含脚本,但是再次没有用
请指导我..
【问题讨论】:
-
如果可能,请不要将 JSP 与 JSF 一起使用。使用 Facelets!这会让你保持清醒;)
-
@Mike Braun 我们可能会迁移到 JSF2.0。
标签: jquery jsf jsf-2 richfaces