2011-04-12 51 views
1

JSF:JSF RichFaces的:a4jSkin.tableBackgroundColor行爲斑馬錶

<rich:dataTable id="files" styleClass="table" headerClass="header" 
value="#{file}" var="fileRecord" rendered="#{file.rowCount>0}" 
rowClasses="even,odd" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" 
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"> 
<rich:column> 

前提:
具有斑馬樣式表以白色和灰色的行
步驟:對行
1.鼠標懸停,它是好的
2.鼠標掉了,它變成了白色

postcondition: 表丟失其「斑馬」

它發生了因爲#{a4jSkin.tableBackgroundColor}評估爲白色。
如何保留斑馬造型?

感謝您的協助。

回答

2

應改爲:

#{a4jSkin.rowBackgroundColor} 
0
<rich:dataTable id="files" styleClass="table" headerClass="header" 
    value="#{file}" var="fileRecord" rendered="#{file.rowCount lt 0}" 
    rowClasses="even,odd" 
    onRowMouseOver="tableRowColor=this.style.backgroundColor; 
    this.style.backgroundColor='#dedede'" 
    onRowMouseOut="this.style.backgroundColor=tableRowColor"> 
<rich:column> 
+1

能否請您解釋一下爲什麼會工作嗎?我知道'onRowMouseOut'表的背景顏色會變成(undefined)「tableRowColor」變量嗎? – mabi 2014-05-29 16:03:47

+0

當檢測到mouseOver時,它將當前backgroundColor保存在名爲tableRowColor的變量中,然後分配顏色#dedede。當鼠標不在時,它分配存儲在tableRowColor變量中的樣式。它現在正在爲我工​​作。 – JuandaU 2014-05-30 18:18:29

+0

我仍然不認爲依賴這樣的全局是一個好主意(閱讀:一個可怕的黑客),但我看到你在追求什麼。 – mabi 2014-05-30 18:37:22