1 2 Previous Next 18 Replies Latest reply: Aug 16, 2011 9:44 AM by Tiago Augusto Coelho RSS

rich:coulmns sortBy not working

Žiga Gantar Newbie

As mentioned in the https://jira.jboss.org/jira/browse/RF-7517 ticket the rich:columns sortBy is not functioning any more. It supposedly doesn't work from 3.3.0 CR2. I can only confirm that it is not working on 3.3.1 GA, which we use in our environment. I am using mixed rich:column and rich:columns and sortBy is working on rich:column and not working in rich:columns. Is there any plan to fix this or is there any new way of using sortBy in rich:columns?

Best regards,
Žiga Gantar

  • 1. Re: rich:coulmns sortBy not working
    Nick Belaevski Master

    Hello,

    "sortOrder" should be specific for each column, e.g.: sortOrder="#{localeHandler.sortOrder}"

    Have you done this?

  • 2. Re: rich:coulmns sortBy not working
    Žiga Gantar Newbie

    In the ticket I mentioned the other guy said that it doesn't work even with the added "sortOrder". I added sortOrder="unsorted" on the columns declaration so it is not specific for each column since I don't need specific sorting up front. I need it to be user specific, which ever column user wants to sort let him sort.

    BTW is this a new prerequisite since we didn't have this before and it worked as it should? Does this mean that there is no default value if you don't put anything in sortOrder

  • 3. Re: rich:coulmns sortBy not working
    Nick Belaevski Master

    Sort order value selected by the user is lost if not bound to model variable, that's it. Of course, such binding will let the user sort the table as desired.

  • 4. Re: rich:coulmns sortBy not working
    Žiga Gantar Newbie

    Changed the code to also use sortOrder property but it still doesn't work. What to do next?

  • 5. Re: rich:coulmns sortBy not working
    Nick Belaevski Master

    One more on the topic: https://jira.jboss.org/jira/browse/RF-6234

    Here is what working for me:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:a4j="http://richfaces.org/a4j"
     xmlns:rich="http://richfaces.org/rich">
    <head>
    <meta http-equiv="Content-Type" content="text/html" />
    <title>SEPARATOR</title>
    </head>
    <body>
    
    
    <f:view>
    <h:form>
     <rich:dataTable id="table" value="#{itemList.items}" var="row"
     rows="15">
     <rich:columns value="#{itemList.columns}" var="column" index="i"
     sortBy="#{row[column]}" id="column#{i}" sortOrder="#{itemList.sortOrder[column]}">
     <f:facet name="header">
     <h:outputText value="#{column}" />
     </f:facet>
     <h:outputText value="#{row[column]}" />
     </rich:columns>
     </rich:dataTable>
    </h:form>
    </f:view>
    
    </body>
    </html>


    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.UUID;
    
    
    public class ItemList {
    
     private String[] columns = {"name", "uuid"};
    
     private Map<String, Object> sortOrder = new HashMap<String, Object>();
    
     public Map<String, Object> getSortOrder() {
     return sortOrder;
     }
    
     private List<Item> items;
    
     public ItemList() {
     items = new ArrayList<Item>();
     for (int i = 0; i < 30; i++) {
     Item item = new Item();
     item.setName("Name " + i);
     item.setUuid(UUID.randomUUID().toString());
     items.add(item);
     }
     }
    
     public List<Item> getItems() {
     return items;
     }
    
     public void checkAll() {
     for (Item item : items) {
     item.setFlag(true);
     }
     }
     public void uncheckAll() {
     for (Item item : items) {
     item.setFlag(false);
     }
     }
    
     public String[] getColumns() {
     return columns;
     }
    }


    public class Item {
     private boolean flag;
    
     private String name;
    
     private String uuid;
    
     /**
     * @return the uuid
     */
     public String getUuid() {
     return uuid;
     }
    
     /**
     * @param uuid the uuid to set
     */
     public void setUuid(String uuid) {
     this.uuid = uuid;
     }
    
     /**
     * @return the flag
     */
     public boolean isFlag() {
     return flag;
     }
    
     /**
     * @param flag the flag to set
     */
     public void setFlag(boolean flag) {
     this.flag = flag;
     }
    
     /**
     * @return the name
     */
     public String getName() {
     return name;
     }
    
     /**
     * @param name the name to set
     */
     public void setName(String name) {
     this.name = name;
     }
    
    }


    ItemList has "session" scope.

  • 6. Re: rich:coulmns sortBy not working
    Žiga Gantar Newbie

    Solved it! The problem was that I was already setting the sortOrder values in in the map, example using your code below, sort of:

    private Map<String, Object> sortOrder = new HashMap<String, Object>();
    ...
    
    for(...) {
    sortOrder.put(columnName, Ordering.UNSORTED);
    }
    


    Now I see that object for storing sortOrder which is used by the columns tag is needed, container sort of.

    Thank you very much,
    Žiga - Ziga

  • 7. Re: rich:coulmns sortBy not working
    Thomas W Newbie

    How does this work for scrollableDataTable? Providing the model property as described here does not seem to work for that table implementation. The getter is never called.

  • 8. Re: rich:coulmns sortBy not working
    Ilya Shaikovsky Master

    sortExpression should be used for scrollable table instead of sortBy as described in documentation.

  • 9. Re: rich:coulmns sortBy not working
    ajit patil Newbie

    I created a map and used it in the list like this

    <rich:columns value="#{crystalListBean.columns}"
     var="column" index="ind" id="${idg.nextid}"
     sortBy="#{dataRow.dataColumns[ind].value}" sortOrder="#{crystalListBean.sortOrder[column]}">


    It sort the values but only once...if i try to sort it more than once doesn't work. May be I am doing something wrong. Can you suggest a solution?


  • 10. Re: rich:coulmns sortBy not working
    Ilya Shaikovsky Master

    asupa, please not to comment on different threads(which seems not fully analogous to your case) but create your own thread with full problem description and code snippets. I would be easier to deal with you case in this way.

  • 11. Re: rich:coulmns sortBy not working
    Christian Nockemann Newbie

    I'm still having this problem.

     

    I tried downgrading to 3.3.0CR1 but it didn't help.

     

    My code:

    <rich:dataTable

     

    value="#{flowScope.homeBean.olapElement['olapElementTopFlop'].reportRows}"

     

    var="row" rowClasses="odd, even" width="100%">

     

    <rich:columns

     

    value="#{flowScope.homeBean.olapElement['olapElementTopFlop'].report.columnHeaders}"

     

    var="cols" index="ind" sortBy="#{row[ind].data}"

     

    style="white-space:nowrap;">

     

    <f:facet name="header">

     

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

     

    </f:facet>

     

    ... some Numbers...

     

    </

     

    rich:columns>

     

    </rich:dataTable>

     

     

    Only adding the sortOrder Attribute helps.

    Binding a map of "Ordering"s to it won't resolve my problem because the sortOrder should alternate between DESCENDING and ASCENDING like in the columns-Livedemo.

    Right now i am writing a bean-method which accomplishes this alternation, but it feels like a big overhead.

     

    Any news on this?

  • 12. Re: rich:coulmns sortBy not working
    mark lewis Newbie

    Does this affect rich:column as well as rich:columns?

     

    I have a 5 column dataTable with a sortBy column 2 like below.  I'm using RF 3.3.2.SR1 and with the below I get sorted columns output with an up arrow on the column header which doesn't respond when I click on it.

     

    Let me know if I should post this in a new thread, but I think it's related to the above. Thanks

     

                <rich:dataTable onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                    onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                    cellpadding="0" cellspacing="0" width="100%" border="0" var="item"
                    value="#{MyBacking.DataList}">
                    <f:facet name="header">
                        <h:outputText value="connections" />
                    </f:facet>
    
                    <rich:column style="text-align:center" width="150px">
                        <f:facet name="header">
                            <h:outputText value="de" />
                        </f:facet>
                        <h:graphicImage value="e.jpg" alt="node" />
                        <br />
                        <h:outputText styleClass="txtBold"
                            value="#{MyBacking.ode}" />
                    </rich:column>
    
                    <rich:column width="30%" sortBy="#{item.dId}" sortOrder="ASCENDING">
                        <f:facet name="header">
                            <h:outputText value="Detail" />
                        </f:facet>
    
                        <h:outputText value="ID:   " />
                        <h:outputText styleClass="txtBold" value="#{item.dId}" />
                        <br />
                        <h:outputText value="Name: " />
                        <h:outputText styleClass="txtBold" value="#{item.Name}" />
                        <br />
                        <h:outputText value="FID:   " />
                        <h:outputText styleClass="txtBold" value="#{item.fId}" />
                        <br />
                        <h:outputText value="Dir:  " />
                        <h:outputText styleClass="txtBold" value="#{item.Dir}" />
                        <br />
    
                        <a4j:repeat value="#{item.ks}" var="fm">
                            <h:outputText value="sk: " />
                            <h:outputText styleClass="txtBold" value="#{fm}" />
                            <br />
                        </a4j:repeat>
                    </rich:column>
    
                    <rich:column style="text-align:center" width="150px">
                        <f:facet name="header">
                            <h:outputText value="nformation" />
                        </f:facet>
    
                        <h:outputText value="Switch: " />
     
    
                        <br />
                        <h:outputText styleClass="txtBold" value="#{item.hl}" />
                    </rich:column>
    
                    <rich:column width="30%">
                        <f:facet name="header">
                            <h:outputText value="Detail" />
                        </f:facet>
    
                        <h:outputText value="e: " />
                        <h:outputText styleClass="txtBold" value="#{item.e}" />
                        <br />
                        <h:outputText value="r: " />
                        <h:outputText styleClass="txtBold" value="#{item.r}" />
                        <br />
                        <h:outputText value="re: " />
                        <h:outputText styleClass="txtBold" value="#{item.re}" />
                        <br />
                        <h:outputText value="t: " />
                        <h:outputText styleClass="txtBold" value="#{item.t}" />
                    </rich:column>
    
                    <rich:column style="text-align:center" width="150px">
                        <f:facet name="header">
                            <h:outputText value="ode" />
                        </f:facet>
    
                        <h:graphicImage value="e.jpg" alt="node" />
                        <br />
                        <h:outputText styleClass="txtBold"
                            value="#{item.t}:#{item.dft}" />
                    </rich:column>
                </rich:dataTable>
    
  • 13. Re: rich:coulmns sortBy not working
    Shimon Lifshitz Newbie

    I think that it will work more then once if you add "id" attribute to the columns. It exists in the working example.

    I had the same problems, first nothing worked so I add sortOrder attribute, and them it worked only once. After some investigations (include source debug) i saw that something is going wrong with automatic client id. So I added "id" attribute.. and WALLLA... al is working fine.

     

    Shimon Lifshitz

     

    working code example: (col is a HashMap)

     

     

    <rich:columns sortBy="#{row[col.name]}" var="col" value="#{reservation.explorer.columnsDataModel.wrappedData}" sortOrder="#{col.sortOrder}" id="#{col.name}">

     

    <h:outputText

     

    value="#{row[col.name]}" >

     

    </h:outputText>

     

    </rich:columns>

  • 14. Re: rich:coulmns sortBy not working
    Charleen Miguel Novice

    If I try to do

     

    id="#{col.name}"

     

    I get the error message: "According to TLD or attribute directive in tag file, attribute id does not accept any expressions."  I found in another thread that id accepts expressions in facelets but not in JSF.  How am I supposed to get this to work in JSF 1.2? We don't have the luxury of switching to facelets. Are there any other workarounds to getting sorting to work in dynamic columns?

1 2 Previous Next