我在JSF开发中遇到了一个问题。首先我的环境如下: jsf 1.2 , myeclipce 8.5 , tomcat 6 代码如下,在datatable 外面的 commandlink 可以使用,而使用datatable 里的 commandlink 则是跳回本页,有没有大虾知道是怎么回事? jsf coding:
<h:form id="actionForm"> <h:panelGrid styleClass="titleBackground" id="listTitle" columns="1"> <h:outputText styleClass="PrimarySubheader" id="label_GeneralProfile" value="用户搜索"></h:outputText> </h:panelGrid> <h:panelGrid columns="5"> <h:outputLabel value="用户名称" styleClass="outputLabel"></h:outputLabel> <h:inputText value="#{pc_UserView.user.userName}"></h:inputText> <h:outputText styleClass="outputLabel" value="" style="margin-left: 20px"></h:outputText> <h:outputLabel value="用户状态" styleClass="outputLabel"></h:outputLabel> <h:selectOneMenu value="#{pc_UserView.user.state}"> <f:selectItem itemLabel="" itemValue=""/> <f:selectItem itemLabel="正常" itemValue="1"/> <f:selectItem itemLabel="非正常" itemValue="2"/> </h:selectOneMenu> <h:outputLabel value="用户帐号" styleClass="outputLabel"></h:outputLabel> <h:inputText value="#{pc_UserView.user.loginId}"></h:inputText> <h:outputText styleClass="outputLabel" value="" style="margin-left: 20px"></h:outputText> <h:commandButton id="display" value="Display." type="submit" action="#{pc_UserView.getUserList}"></h:commandButton> </h:panelGrid>
<h:dataTable id="userTable" value="#{pc_UserView.allUsers}" var="userObj" styleClass="dataTable" headerClass="headerClass" footerClass="footerClass" rowClasses="rowClass1, rowClass2" border="1" cellpadding="2" cellspacing="0" style="text-align: left" width="100%" > <h:column id="userId"> <f:facet name="header"> <h:outputText styleClass="SecondarySubheader" value="用户标识"></h:outputText> </f:facet> <h:outputText value="#{userObj.userId}"></h:outputText> <f:attribute value="180" name="width" /> </h:column> <h:column id="userName"> <f:facet name="header"> <h:outputText styleClass="SecondarySubheader" value="用户名称"></h:outputText> </f:facet> <h:outputText value="#{userObj.userName}"></h:outputText> </h:column> <h:column id="loginId"> <f:facet name="header"> <h:outputText styleClass="SecondarySubheader" value="登录账号"></h:outputText> </f:facet> <h:outputText value="#{userObj.loginId}"></h:outputText> </h:column> <h:column id="state"> <f:facet name="header"> <h:outputText styleClass="SecondarySubheader" value="用户状态"></h:outputText> </f:facet> <h:outputText value="#{userObj.state == 1 ? '正常' : '非正常'}"></h:outputText> </h:column> <h:column id="lastUpdateDate"> <f:facet name="header"> <h:outputText styleClass="SecondarySubheader" value="最后更新时间"></h:outputText> </f:facet> <h:outputText value="#{userObj.lastUpdateDate}"></h:outputText> </h:column> <h:column id="options"> <f:facet name="header"> <h:outputText styleClass="SecondarySubheader" value="操作"></h:outputText> </f:facet> <h:commandLink value="Edit" action="#{pc_UserEdit.toEdit}" immediate="true" > <f:param name="userId" value="#{userObj.userId}"></f:param> </h:commandLink> </h:column> </h:dataTable> <h:commandLink value="Edit" action="#{pc_UserEdit.toEdit}" immediate="true" > <f:param name="userId" value="#{userObj.userId}"></f:param> </h:commandLink> </h:form>