开发者

call a custom listener for cancel in p:rowEditor

I have been trying to call a custom listener when the cancel button is 开发者_Go百科clicked in the primefaces rowEditor component. But I am not able to find the correct attribute to do this.

The problem with the cancel button is that it works fine when the row is already present in the dataTable, if I try to add a new row dynamically to the dataTable and click on the cancel button [ if I think that it is not required ], the empty row is shown in the dataTable, when the empty row should be deleted.

Would you please help me out ?


Try like (JSF2 + Primefaces 2.2.1) ...

<p:column headerText="Test">
    <p:rowEditor>
        <p:ajaxStatus oncomplete="#{yourBean.yourHandleMethod()}"></p:ajaxStatus>
    </p:rowEditor>
</p:column>


I am afraid this functionality isn't available out of box. The rowEditor component has built in integration to a dataTable and its own events and listeners for editing a single existing row. The cancel button of the rowEditor component has the sole functionality of toggling the output and input facets of the Primefaces column components.

If you are good at jQuery you may be able to hack the functionality in by finding the DOM element by the cancel button class, jQuery('.ui-icon-close') and assigning a custom javascript event listener but this could be problematic in a dataTable where there are multiple rows and it sounds as if you would like to delete a blank row if Cancel is selected.

A better approach is create an Add New button that displays a dialog with a form. Submitting through the form in the dialog can add the necessary row to your dataTable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜