我想突出顯示使用Ricfaces呈現的表格的當前選定行,但它不起作用。這裏是我的代碼:Richfaces Javascript not firing
的facelet:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich" template="templates/main.xhtml">
<ui:define name="body">
<h:form>
<fieldset>
<legend>
<h:outputText value="#{msg['result.legend']}" />
</legend>
<rich:dataTable id="resultTable" onRowMouseOver="this.style.backgroundColor='#f1f1f1'"
onRowMouseOut="this.style.backgroundColor=''"
value="#{searchController.result}" var="row">
<c:forEach items="${searchController.headers}" var="headr"
varStatus="status">
<rich:column>
<f:facet name="header">
<h:outputText value="#{headr}" />
</f:facet>
<h:outputText value="#{row[status.count-1]}" />
</rich:column>
</c:forEach>
</rich:dataTable>
</fieldset>
</h:form>
</ui:define>
我無法粘貼整個模板(main.xhtml)的源代碼。這是H的內容:body標籤(剛發現爲什麼:-)):
<rich:panel styleClass="mainPanel">
<ui:include src="../common/header.xhtml"></ui:include>
<ui:insert name="body"></ui:insert>
</rich:panel>
POM依賴關係:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>4.2.2.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
<!--dependency> <groupId>javax.faces</groupId> <artifactId>javax.faces-api</artifactId>
</dependency -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
凡searchController.headers是一個List <字符串>和searchController.result是列表<列表<字符串>>。表本身已正確顯示。
我在這裏錯過了什麼?
我正在使用Richfaces 4.2.2.Final,在Eclipse Indigo上開發。
可能的重複http://stackoverflow.com/q/10129551/1065197 – 2012-07-05 14:23:12
我想按照該線程中的建議來實現onRowMouseOver。我將我的嘗試基於我在這裏找到的示例:http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf,但我所做的不起作用。我不相信這是重複的。 – JazzHands 2012-07-05 14:32:35
您的概念錯誤。onRowMouseOver和onRowMouseOut正在使用'this',因此您正在更改'rich:dataTable'背景顏色。查看我發佈的鏈接,因爲要實現您所需要的內容,應該在此[突出顯示點擊行]中使用JavaScript,如BalusC顯示(http://balusc.blogspot.com/2006/06/using-datatables.html #HighlightRowsOnClick)示例或jQuery作爲我提供的重複鏈接。 – 2012-07-05 14:38:22