ajax4jsf精简代码的问题

charles1911 2010-10-21 04:07:14
以下为网页源文件代码:

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSF 'MyJsp.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<f:view>
<h:form>
<h:commandLink value="test" action="next" />
</h:form>
</f:view>
</body>
</html>


以下代码为我使用ajax4jsf后生成的网页代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><base href="http://localhost:8080/TestWeb/"><title>My JSF 'MyJsp.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head><body><form id="j_id_jsp_1560094981_1" name="j_id_jsp_1560094981_1" method="post" action="/TestWeb/MyJsp.faces" enctype="application/x-www-form-urlencoded"><input type="hidden" name="j_id_jsp_1560094981_1" value="j_id_jsp_1560094981_1"> <script type="text/javascript" language="Javascript">function dpf(f) {var adp = f.adp;if (adp != null) {for (var i = 0;i <adp.length;i++){f.removeChild(adp[i]);}}};functionapf(f,pvp){varadp=newArray();f.adp=adp;varps=pvp.split(',');for(vari=0,ii=0;i<ps.length;i++,ii++){varp=document.createElement("input");p.type="hidden";p.name=ps[i];p.value=ps[i+1];f.appendChild(p);adp[ii]=p;i+=1;}};functionjsfcljs(f,pvp,t){apf(f,pvp);if(t){f.target=t;}f.submit();dpf(f);};
</script> <a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['j_id_jsp_1560094981_1'],'j_id_jsp_1560094981_1:j_id_jsp_1560094981_2,j_id_jsp_1560094981_1:j_id_jsp_1560094981_2','');}return false">test</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id3:j_id4"></form></body></html>


以下为没使用ajax4jsf生成的网页代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="http://localhost:8080/TestWeb/">

<title>My JSF 'MyJsp.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>

<form id="j_id_jsp_1560094981_1" name="j_id_jsp_1560094981_1" method="post" action="/TestWeb/MyJsp.faces" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_id_jsp_1560094981_1" value="j_id_jsp_1560094981_1" />

<script type="text/javascript" language="Javascript">function dpf(f) {var adp = f.adp;if (adp != null) {for (var i = 0;i < adp.length;i++) {f.removeChild(adp[i]);}}};function apf(f, pvp) {var adp = new Array();f.adp = adp;var ps = pvp.split(',');for (var i = 0,ii = 0;i < ps.length;i++,ii++) {var p = document.createElement("input");p.type = "hidden";p.name = ps[i];p.value = ps[i + 1];f.appendChild(p);adp[ii] = p;i += 1;}};function jsfcljs(f, pvp, t) {apf(f, pvp);if (t) {f.target = t;}f.submit();dpf(f);};</script>
<a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['j_id_jsp_1560094981_1'],'j_id_jsp_1560094981_1:j_id_jsp_1560094981_2,j_id_jsp_1560094981_1:j_id_jsp_1560094981_2','');}return false">test</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id1:j_id2" />
</form>
</body>
</html>


本来ajax4jsf精简代码是个很好的功能,但我发现有些代码被精简后就不能运行了,比如上面的JS代码:
functionapf(f,pvp){varadp=newArray();f.adp=adp;varps=pvp.split(',');for(vari=0,ii=0;i<ps.length;i++,ii++){varp=document.createElement("input");p.type="hidden";p.name=ps[i];p.value=ps[i+1];f.appendChild(p);adp[ii]=p;i+=1;}};
把很多必要的空格给删掉了,求解
...全文
108 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
charles1911 2010-10-23
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 magong 的回复:]
你为什么要这样做呢。RichFace的组件用一点就可以了。
[/Quote]
我现在的网站已经差不多做好了,就差这一点功能了,不好改成RichFace组件了
magong 2010-10-23
  • 打赏
  • 举报
回复
你为什么要这样做呢。RichFace的组件用一点就可以了。
charles1911 2010-10-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 beer2010cn 的回复:]
哪里可以下载啊
[/Quote]网上BAIDU一下,应该能找到,你要的话我可以给你发一个,不过有上面的问题你还敢用?
liyinle2 2010-10-22
  • 打赏
  • 举报
回复
现在应该用这个东东的很少吧
,杯具!!!
charles1911 2010-10-22
  • 打赏
  • 举报
回复
没人知道 啊,郁闷
beer2010cn 2010-10-22
  • 打赏
  • 举报
回复
哪里可以下载啊
charles1911 2010-10-22
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 xuyang840117 的回复:]
。。。。。。。

你是不是 用错了啊

你贴出用了 ajax4jsf 你写的代码 出来
[/Quote]
我只不过加了个filter而已,其它的都没加

<filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>ajax4jsf</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
xuyang840117 2010-10-22
  • 打赏
  • 举报
回复
。。。。。。。

你是不是 用错了啊

你贴出用了 ajax4jsf 你写的代码 出来
charles1911 2010-10-22
  • 打赏
  • 举报
回复
郁闷了,回复即可得分

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧