我用JSF实现了一个查询和列表页面,这个列表中的链接是通过buttonLink实现的,列表出来后点击链接总没有反应,要点很多次才有一次是对的,这到底是为什么啊?是JSF的Bug还是我的实现有问题啊?请高手们指导!JSP代码如下:<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:a4j="http://richfaces.org/a4j"><head>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>    
<link rel="stylesheet"
href="#{facesContext.externalContext.requestContextPath}/cn/hnisi/gac/resources/css/default.css"
type="text/css"></link>
</head>
<body>
<ui:decorate template="/cn/hnisi/gac/GACWorkspace.xhtml"> <!-- 标题以及工具栏 -->
<ui:define name="BizTitleAndToolBar">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr height="1">
<td>&nbsp;</td>
</tr>
<tr>
<td width="180" height="26"
style="padding-left:8px;padding-top:3px;font-weight:bold;font-size:10pt;color:white;background:url(#{facesContext.externalContext.requestContextPath}/cn/hnisi/gac/resources/images/titlebar/activetitle.gif);background-repeat :no-repeat">
&nbsp;组织机构列表_用户列表</td>
<td align="right"
style="background:url(#{facesContext.externalContext.requestContextPath}/cn/hnisi/gac/resources/images/titlebar/titlebar-back.gif);background-repeat:repeat-x">
<style type="text/css">
<!--
.toolbarButton{
font-size:10pt;
color: #333;
border: 0px solid #EEF1F7;
padding-top: 3px;
height:22px;
cursor:hand;
background:#White repeat-x top left;
}
.toolbarButtonOn{
font-size:10pt;
color: #234C6F;
border: 1px solid #9B8748;
padding-top: 3px;
height:22px;
cursor:hand;
border-color: #727377;
background:  #EEF1F7 repeat-x top left;
} -->
</style>
<button name="save" class="toolbarButton"
onmouseout="toolbarButtonMouseOut()"
onmouseover="toolbarButtonMouseOver()"></button> </td>
</tr>
</table>
</ui:define>
<!-- 简要查询条件区 -->
<ui:define name="QueryConditionPanel">
<table width="90%" align="center">
<tr>
<td class="list_condition_td_title_left">查询条件:</td>
</tr>
<tr><td>
<h:panelGrid columns="2" width="100%" height="30" class="edit_list">
<h:form>
<h:panelGroup>
<h:outputLabel class="" width="30%" value=" 名称:  " />
<h:inputText class="commonTextInput" value="#{orgModel.name}" size="20" />
</h:panelGroup>
<h:commandButton class="button_list" value=" 查询 " action="#{orgModel.onQuerySubmit}" />
</h:form>
</h:panelGrid>
</td></tr>
<tr>
<td>
<h:form>
<c:choose>
     <c:when test="${orgModel.parentCode!='0000'}">
<h:commandButton value="新增组织机构"  action="#{orgModel.onAddnewInit}">
<f:param value="#{orgModel.parentCode}" name="code"/>
</h:commandButton> <h:commandButton value="上级组织机构"  action="#{orgModel.showSuperList}">
<f:param value="#{orgModel.parentCode}" name="code"/>
</h:commandButton>
        </c:when>
     </c:choose>
     </h:form>
</td>
<td>
</td>
</tr>
</table>
</ui:define>

<!-- 查询结果区  -->
<ui:define name="QueryResultList">
<h:form style="margin:0px;">
<table width="90%" align="center">
<tr><td>
<rich:dataTable id="datalist" rows="#{orgModel.pageSize}"
onRowMouseOver="this.style.backgroundColor='#BDDFFF'"
onRowMouseOut="this.style.backgroundColor='#F6F6F6'"
columns="6" align="center"  cellpadding="0" cellspacing="0"
width="100%" border="0" var="org" value="#{orgModel.list}"
rowClasses="row1class,row2class" colClasses="col15,col15,col10,col20,col10,col10,col10,col10"
>
<f:facet name="header">
<rich:columnGroup>
<rich:column colspan="1">
<h:outputLabel  value="机构名称"/>
</rich:column>
<rich:column colspan="1">
<h:outputLabel  value="机构代码" />
</rich:column>
<rich:column colspan="1">
<h:outputLabel  value="机构级别" />
</rich:column>
<rich:column colspan="1">
<h:outputLabel value="备注" />
</rich:column>
<rich:column colspan="1" >
<h:outputLabel value="修改" />
</rich:column>
<rich:column colspan="1">
<h:outputLabel value="删除" />
</rich:column>
<rich:column colspan="1">
<h:outputLabel value="业务用户浏览" />
</rich:column>

</rich:columnGroup>
</f:facet> <h:column>
<div align="center">
<h:commandLink value="#{org.name}" action="#{orgModel.showSubList}">
<f:param value="#{org.code}" name="code"/>
</h:commandLink>
</div>
</h:column>
<h:column>
<h:outputText value="#{org.code}" />
</h:column>
<h:column>
<h:outputText value="#{org.orgLevel}" />
</h:column>
<h:column>
<h:outputText value="#{org.memo}" />
</h:column>

<h:column>
<div align="center">

<h:commandLink value="【修改】" action="#{orgModel.onUpdateInit}">
<f:param value="#{org.id}" name="id"/>
</h:commandLink>
</div>
</h:column>
<h:column rendered="${org.allowDelete}">
<div align="center">
<h:commandLink value="【删除】"  action="#{orgModel.onUpdateInit}">
<f:param value="#{org.id}" name="id"/>
</h:commandLink>
</div>    
</h:column>
<h:column rendered="${!org.allowDelete}">
<div align="center">
<h:outputText value="不允许删除"/>
</div>    
</h:column>
<h:column>
<div align="center">
<h:commandLink value="【浏览用户】" action="#{orgModel.onUpdateInit}">
<f:param value="#{org.id}" name="id"/>
</h:commandLink>
</div>
</h:column>
</rich:dataTable>
</td></tr>
<tr><td>
<rich:datascroller for="datalist" maxPages="#{orgModel.pages}" />
</td></tr>
</table>
</h:form>
</ui:define>

</ui:decorate></body>
</html>

解决方案 »

  1.   

    一般不是程序的问题
    把你的web.xml中涉及javax.faces.STATE_SAVING_METHOD的设置改为client就可以了
      <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
      </context-param>
      

  2.   

    以删除为例,修改如下:
    <h:commandLink value="【删除】"  action="#{orgModel.onUpdateInit}" immediate="true">
                                    <f:param value="#{org.id}" name="id"/>
                                </h:commandLink>
      

  3.   

    哦,那是因为你查出结果后,查询条件有的值不存在了,或者是为空了,这样你提交的时候会再次验证你的查询
    条件,条件不满足当然就不会提交了。immediate="true"加入会,你在操作的时候就会跳过验证,直接执行。
    结贴给分吧,谢谢
      

  4.   

    to mxm_1123,加了immediate="true"也是一样啊,点很多次才有一次有效的啊to hornbilltofy,感觉好像设置为client就好了,测试两天,两天后来结贴,呵呵,最好hornbilltofy 给我讲讲是什么原因嘛,server方式就可能会失效?和应该是JSF的Bug吧。
      

  5.   

    Thank You !!!!!!!!!!!!
    Very Much !!!!!!!!!!!!!!