문제

I am working with an application built on IceFaces. Part of this application allows the user to select a form, create a duplicate, and then edit and save this duplicate under a different name. There are two variations in these duplicates: one an identical copy, one with some information redacted.

To select a form, the user has a search page that returns a sortable table of search results. In the current system, the final column of each row has two buttons, one for each variant of duplicate. When either one is clicked, it triggers two listeners: a RowSelectionListener which updates the model with the ID of the selected row, and a second listener depending on the button that uses this ID to retrieve the selected form, creates a copy, and redirects the user to the relevant edit page.

We would like to replace the two buttons with a single context menu, where the user can right-click a row and select their desired option. We've implemented this context menu using the contextMenu component (http://icefaces-showcase.icesoft.org/showcase.jsf?grp=aceMenu&exp=contextMenuBean) and it works fine, with one issue: right-clicking does not trigger the rowSelectionListener. This means users need to first left-click the table entry they want to edit, then right-click to see the menu.

This is of course not a very intuitive way of working, so I was wondering if there's a way to tie the row selection to the right mouse button, or perhaps to tie the context menu to the left mouse button - either works, so long as the user just has to click once.

도움이 되었습니까?

해결책

You do not need a rowSelectionListener. Just use a oncontextmenu on the row which is generated by ice:panelGroup when used along with the attributes contextValue and menuPopup. The contextValue can be used to uniquely identify a row.

<ice:column>
<f:facet name="header">
        <h:outputText value="Col header" />
</f:facet>
    <ice:panelGroup contextValue="#{myVar.rowId}" menuPopup="menupopupId">
        <ice:outputText value="#{myVar.property}" />
    </ice:panelGroup>
</ice:column>
....
<ui:include src="menuPop.xhtml"/>

menuPop.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ice:panelGroup styleClass="icePnlMenuPopupGrp">
    <ice:menuPopup id="menupopupId">
        <ice:menuItem id="myItem" value="My Item"
            actionListener="#{controller.doAction}">
        </ice:menuItem>
        .....
    </ice:menuPopup>
</ice:panelGroup>
</ui:composition>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top