今天在完成一個(gè)功能時(shí),遇到了一點(diǎn)問(wèn)題:
使用rich:dataTable顯示了一個(gè)列表,需要實(shí)現(xiàn)的功能是:右鍵點(diǎn)擊row的時(shí)候需要彈出contextMenu并且讓此行記錄被高亮顯示。
<rich:contextMenu attached="false" id="fulfillmentItemContextMenu" submitMode="ajax">
xxxxxxxx
</rich:contextMenu>
<rich:dataTable xxxxxxx>
<rich:column xxxxxx>
<rich:column xxxxxx>
<rich:column xxxxxx>
<rich:componentControl event="onRowContextMenu" for="statusContextMenu" operation="show">
</rich:dataTable>
但是要使此記錄被顯示的功能是實(shí)現(xiàn)在后臺(tái)bean里面,所以要先執(zhí)行這個(gè)函數(shù)之后再?gòu)棾鰧?duì)應(yīng)的菜單。這樣就不能使用componentControl來(lái)控制了,只能使用a4j:support了。
將對(duì)應(yīng)的componentControl代碼改為:
<a4j:support action="#{backBean.selectItem(id)}" event="onRowContextMenu"
reRender="xxPanel" oncomplete="#{rich:component('xxxxContextMenu')}.doShow(event, {})"/>
注意:richContextMenu的官方文檔對(duì)這個(gè)tag的js函數(shù)解釋的不是很清楚,也沒(méi)有對(duì)應(yīng)的例子,這是我在google了好久之后才發(fā)現(xiàn)的一個(gè)小例子。請(qǐng)注意加粗部分代碼的使用。
另附官方對(duì)richContextMenu的js函數(shù)的說(shuō)明:
使用rich:dataTable顯示了一個(gè)列表,需要實(shí)現(xiàn)的功能是:右鍵點(diǎn)擊row的時(shí)候需要彈出contextMenu并且讓此行記錄被高亮顯示。
<rich:contextMenu attached="false" id="fulfillmentItemContextMenu" submitMode="ajax">
xxxxxxxx
</rich:contextMenu>
<rich:dataTable xxxxxxx>
<rich:column xxxxxx>
<rich:column xxxxxx>
<rich:column xxxxxx>
<rich:componentControl event="onRowContextMenu" for="statusContextMenu" operation="show">
</rich:dataTable>
但是要使此記錄被顯示的功能是實(shí)現(xiàn)在后臺(tái)bean里面,所以要先執(zhí)行這個(gè)函數(shù)之后再?gòu)棾鰧?duì)應(yīng)的菜單。這樣就不能使用componentControl來(lái)控制了,只能使用a4j:support了。
將對(duì)應(yīng)的componentControl代碼改為:
<a4j:support action="#{backBean.selectItem(id)}" event="onRowContextMenu"
reRender="xxPanel" oncomplete="#{rich:component('xxxxContextMenu')}.doShow(event, {})"/>
注意:richContextMenu的官方文檔對(duì)這個(gè)tag的js函數(shù)解釋的不是很清楚,也沒(méi)有對(duì)應(yīng)的例子,這是我在google了好久之后才發(fā)現(xiàn)的一個(gè)小例子。請(qǐng)注意加粗部分代碼的使用。
另附官方對(duì)richContextMenu的js函數(shù)的說(shuō)明:
Function | Description | Apply to |
---|---|---|
hide() | Hides component or group | Component, group |
show(event, context) | Shows component or group | Component, group |