4 Replies Latest reply on May 4, 2011 10:28 AM by James G

    rich:menuItem with onclick is not executing my action

    Scott Estabrooks Newbie

      I am using richfaces 3.3.3, and have a menuitem that is supposed to prompt to confirm that the selected item should be deleted.  If the javascript response is true it should delete the item, otherwise it should ignore the request. I know the action works because it used to work when it was an html commandButton.  Now we have moved it to a menubar with menu items, and the action is no longer called, although the prompt is displayed, and it does return true or false depending on what I've picked.  Is there something that I'm missing?

       

      Here's the line in question:

       

      <rich:menuItem submitMode="ajax" value="#{msg.comRemoveLabel}" disabled="#{ListPage.selectedCount == 0}"

                                  onclick="return confirm('This operation will delete the selected item. Do you want to continue?');"

                                  action="#{ListPage.remove}" reRender="list" />

       

      And to give it more context (the other onClick's are working as expected):

       

              <h:panelGroup id="taskPanel" style="width:100%;">

       

                  <rich:toolBar height="30px" itemSeparator="none">

                      <rich:toolBarGroup itemSeparator="none">

                          <rich:dropDownMenu id="action">

                              <f:facet name="label">

                                  <h:panelGroup>

                                      <h:outputText value="#{msg.comActionsLabel}" />

                                      <h:graphicImage value="#{Msg.expandIcon}" style="margin-bottom: -1px; margin-left: 3px;" />

                                  </h:panelGroup>

                              </f:facet>

                              <rich:menuItem submitMode="ajax" value="#{msg.comAddLabel}"

                                  onclick="Richfaces.showModalPanel('createDialog'); return false;" />

                              <rich:menuItem submitMode="ajax" value="#{msg.comRemoveLabel}" disabled="#{ListPage.selectedCount == 0}"

                                  onclick="return confirm('This operation will delete the selected item.. Do you want to continue?');"

                                  action="#{ListPage.remove}" reRender="list" />

                              <rich:menuItem submitMode="ajax" value="#{msg.comEditLabel}" disabled="#{ListPage.selectedCount != 1}"

                                  onclick="Richfaces.showModalPanel('createDialog'); return false;" />

                          </rich:dropDownMenu>

                      </rich:toolBarGroup>

                      <rich:toolBarGroup itemSeparator="none">

                          <rich:dropDownMenu id="view">

                              <f:facet name="label">

                                  <h:panelGroup>

                                      <h:outputText value="#{msg.comViewLabel}" />

                                      <h:graphicImage value="#{Msg.expandIcon}" style="margin-bottom: -1px; margin-left: 3px;" />

                                  </h:panelGroup>

                              </f:facet>

                              <rich:menuItem value="#{msg.comResetFiltersLabel}" action="#{ListPage.resetFilters}" reRender="list" />

                              <rich:menuItem submitMode="ajax" value="#{msg.comResetColumnsLabel}" action="#{ListPage.resetState}"

                                  reRender="list" />

                          </rich:dropDownMenu>

                      </rich:toolBarGroup>

                      <rich:toolBarGroup location="right">

                          <h:inputText id="searchText" value="#{ListPage.searchText}" title="#{msg.comSearchLabel}" />

                          <rich:menuItem id="searchButton" submitMode="ajax" value="#{msg.comSearchLabel}" styleClass="search-toolbar-item"

                              action="#{ListPage.search}" reRender="taskPanel, list" />

                          <rich:menuItem id="resetSearchButton" value="#{msg.comResetLabel}" styleClass="search-toolbar-item"

                              actionListener="#{ListPage.resetSearch}" rendered="#{ListPage.showReset}"

                              reRender="taskPanel, list" />

                      </rich:toolBarGroup>

       

                  </rich:toolBar>

              </h:panelGroup>

       

      This is followed by an extended data table (not included).  The item would deleted correctly if the action is called.

       

      Thanks for any help you can provide.

       

      ScottE