5 Replies Latest reply on Dec 5, 2013 3:47 AM by suckerd

    Context menu broken after sorting/filtering ExtendedDataTable with built-in (RF 4.3.0+) controls.

    gmlussi

      Hi, I have the following problem...

       

      Using <rich:contextMenu id="docContextMenu" mode="ajax" target="documentsTable"> to attach a context menu to <rich:extendedDataTable id="documentsTable" ... > the context menu works perfectly, and displays every time, until you use the filter or sort controls at the top of the table, from which point on the context menu is broken and no longer displays (instead you just get the usual browser menu).

       

      Not sure if legit bug, or problem with code, but this has only happens after our RichFaces 4.3.0 upgrade, before which we were using custom sorting/filtering, and had no problem with context menus breaking...

       

      ... any help or suggestions are much appreciated! We really need to push the next release of our site out, and working context menus are critical.

       

      Also, if this seems like a bug, rather than a problem with our code, then perhaps I should raise a JIRA? Also looking for advice on that front.

       

      Cheers!

        • 1. Re: Context menu broken after sorting/filtering ExtendedDataTable with built-in (RF 4.3.0+) controls.
          gmlussi

          Update (still broken):

           

          I created a stripped down test page with only an Extended Data Table and Context Menu component, within a form, with a backing filter bean...

           

          Test page:

           

          {code:xml}

          <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"

                xmlns:rich="http://richfaces.org/rich" xmlns:f="http://java.sun.com/jsf/core"

                xmlns:fn="http://java.sun.com/jsp/jstl/functions">

           

          <h:head>

          </h:head>

           

          <h:body>

              <h:form id="testForm">

                  <rich:extendedDataTable value="#{testFilterBean.testData}" var="testValue" id="testTable">

           

                      <rich:column sortBy="#{testValue}" sortOrder="#{testFilterBean.sortsOrders['test']}"

                                   filterValue="#{testFilterBean.testFilter}"

                                   filterExpression="#{fn:containsIgnoreCase(testValue,testFilterBean.testFilter)}">

                          <f:facet name="header">

                              <h:outputText value="Test"/>

                          </f:facet>

                          <h:outputText value="#{testValue}"/>

                      </rich:column>

           

                  </rich:extendedDataTable>

           

                  <rich:contextMenu id="testContextMenu" target="testTable">

           

                      <rich:menuItem id="docContextMenuMetadataOption" execute="@this" mode="client">

                          Test Option

                      </rich:menuItem>

           

                  </rich:contextMenu>

              </h:form>

          </h:body>

           

          </html>

          {code}

           

          backing:

           

          {code:java}

          package com.test;

           

          import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;

          import org.richfaces.component.SortOrder;

           

          import javax.inject.Named;

          import java.io.Serializable;

          import java.util.ArrayList;

          import java.util.HashMap;

          import java.util.List;

          import java.util.Map;

           

          @Named("testFilterBean")

          @ViewAccessScoped

          public class TestFilterBean implements Serializable {

           

              private Map<String, SortOrder> sortsOrders;

              private List<String> sortPriorities;

           

              private String testFilter = "";

           

              public TestFilterBean() {

                  sortsOrders = new HashMap<>();

                  sortPriorities = new ArrayList<>();

              }

           

              public String getTestFilter() {

                  return testFilter;

              }

           

              public void setTestFilter(String testFilter) {

                  this.testFilter = testFilter;

              }

           

              public List<String> getSortPriorities() {

                  return sortPriorities;

              }

           

              public Map<String, SortOrder> getSortsOrders() {

                  return sortsOrders;

              }

           

              public ArrayList getTestData()

              {

                  ArrayList<String> testData = new ArrayList<>();

                  testData.add("Row 1");

                  testData.add("Row 2");

                  testData.add("Row 3");

                  return testData;

              }

           

          }

          {code}

           

          The problem remains (the context menu is not attached, and is broken, after use of filter or sort) with the above sample code. Oddly, the context menu doesn't break if there is no h:form on the page (but obviously that's no use, as I need to be able to submit on that page).

           

          Nobody have any suggestions?

           

          Or does this seem like a good candidate to formally raise a bug against?

          • 2. Re: Context menu broken after sorting/filtering ExtendedDataTable with built-in (RF 4.3.0+) controls.
            gmlussi

            Ok... it seems that the reason our custom filters and sorts don't break the context menu is because when we make the sort link or input filter box ourselves we can attach the following:

             

            {code:xml}<a4j:ajax render="#{parentForm}"/>{code}

             

            to force a re-render. If we don't add that line, then the menu breaks / is not attached after filtering.

             

            When using the built-in sort and filter there seems to be no way to specify a render list for after the sort or filter. Is there any way I could get the form to re-render after using the built-in controls? (If it's impossible, are we in feature-request territory?)

             

            Thanks.

            • 3. Re: Context menu broken after sorting/filtering ExtendedDataTable with built-in (RF 4.3.0+) controls.
              jhuska

              Hello,

               

              thanks for going deeper into the issue and finding the root cause.

               

              IMHO it is a bug and it is (the similar one) already reported here:

              https://issues.jboss.org/browse/RF-11973

               

              Please see the comments there, I was able to reproduce your issue.

               

              Regards,

              Juro

              • 4. Re: Context menu broken after sorting/filtering ExtendedDataTable with built-in (RF 4.3.0+) controls.
                gmlussi

                Hi Juro,

                 

                Thanks for the reply / looking into it.

                 

                I'd say that seems about right, it seems to be related to that re-render issue (I assume filter/sort is ajax rendering the table only, causing the broken context menu).

                 

                Oddly enough, I've had problems with that exact bug in the past, and previously had to try to work around it. I hope it gets resolved...

                 

                Cheers,

                 

                Gavin

                • 5. Re: Context menu broken after sorting/filtering ExtendedDataTable with built-in (RF 4.3.0+) controls.
                  suckerd

                  Hi I did file a JIRA Ticket - please vote for it!

                  [RF-13418] After sorting on extendedDataTable the contextMenu is broken - JBoss Issue Tracker

                   

                  THX+CU Mike