You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Ben Warner (JIRA)" <ji...@apache.org> on 2009/04/24 09:38:30 UTC

[jira] Created: (CLK-527) FormTable sort fields are not populated for render

FormTable sort fields are not populated for render
--------------------------------------------------

                 Key: CLK-527
                 URL: https://issues.apache.org/jira/browse/CLK-527
             Project: Click
          Issue Type: Bug
          Components: core
    Affects Versions: 1.5
            Reporter: Ben Warner


On an instance of FormTable we have the capability to set the sorted column, sorted ascending, and page number values. These methods are inherited from the Table class but no overridden methods are provided in Form Table.

When the form table is rendered there are hidden form fields defined which are intended to store the values of these properties but the values of these hidden fields don't ever seem to be set. These hidden fields get rendered in the startTag() method of the internal form...

            buffer.append(getForm().startTag());

Because these fields are not populated, the submit function is not aware of any sorting that has been applied to the table and the values are often populated into the wrong underlying objects if the default sorting of the table is not the same as the explicit sorting of the table.

I've resolved this for my application by subclassing FormTable and overriding the 3 relevant methods as follows:

    public void setSortedColumn(String columnName) {
        Field field = (Field)getForm().getFields().get(COLUMN);
        if(field != null){
            field.setValue(columnName);
        }
        setSorted(false);
        super.setSortedColumn(columnName);
    }

    public void setSortedAscending(boolean ascending) {
        Field field = (Field)getForm().getFields().get(ASCENDING);
        if(field != null){
            field.setValue("" + ascending);
        }
        setSorted(false);
        super.setSortedAscending(ascending);
    }

    public void setPageNumber(int pageNumber) {
        Field field = (Field)getForm().getFields().get(PAGE);
        if(field != null){
            field.setValue("" + pageNumber);
        }
        super.setPageNumber(pageNumber);
    }

These overridden methods should be in FormTable to resolve this bug. I have been working with version 1.5 so it may already be resolved in a later version.

Note also that I am calling setSorted(false) in the first 2 methods.

BW.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (CLK-527) FormTable sort fields are not populated for render

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-527?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bob Schellink closed CLK-527.
-----------------------------

       Resolution: Fixed
    Fix Version/s: 1.5.2
                   2.0.2
                   2.1.0

Thanks for the clarification Ben.

Fixed in trunk and backported to 1.5.2 and 2.0.2

> FormTable sort fields are not populated for render
> --------------------------------------------------
>
>                 Key: CLK-527
>                 URL: https://issues.apache.org/jira/browse/CLK-527
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5
>            Reporter: Ben Warner
>             Fix For: 2.1.0, 2.0.2, 1.5.2
>
>
> On an instance of FormTable we have the capability to set the sorted column, sorted ascending, and page number values. These methods are inherited from the Table class but no overridden methods are provided in Form Table.
> When the form table is rendered there are hidden form fields defined which are intended to store the values of these properties but the values of these hidden fields don't ever seem to be set. These hidden fields get rendered in the startTag() method of the internal form...
>             buffer.append(getForm().startTag());
> Because these fields are not populated, the submit function is not aware of any sorting that has been applied to the table and the values are often populated into the wrong underlying objects if the default sorting of the table is not the same as the explicit sorting of the table.
> I've resolved this for my application by subclassing FormTable and overriding the 3 relevant methods as follows:
>     public void setSortedColumn(String columnName) {
>         Field field = (Field)getForm().getFields().get(COLUMN);
>         if(field != null){
>             field.setValue(columnName);
>         }
>         setSorted(false);
>         super.setSortedColumn(columnName);
>     }
>     public void setSortedAscending(boolean ascending) {
>         Field field = (Field)getForm().getFields().get(ASCENDING);
>         if(field != null){
>             field.setValue("" + ascending);
>         }
>         setSorted(false);
>         super.setSortedAscending(ascending);
>     }
>     public void setPageNumber(int pageNumber) {
>         Field field = (Field)getForm().getFields().get(PAGE);
>         if(field != null){
>             field.setValue("" + pageNumber);
>         }
>         super.setPageNumber(pageNumber);
>     }
> These overridden methods should be in FormTable to resolve this bug. I have been working with version 1.5 so it may already be resolved in a later version.
> Note also that I am calling setSorted(false) in the first 2 methods.
> BW.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CLK-527) FormTable sort fields are not populated for render

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-527?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bob Schellink reassigned CLK-527:
---------------------------------

    Assignee: Bob Schellink

> FormTable sort fields are not populated for render
> --------------------------------------------------
>
>                 Key: CLK-527
>                 URL: https://issues.apache.org/jira/browse/CLK-527
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5
>            Reporter: Ben Warner
>            Assignee: Bob Schellink
>             Fix For: 2.1.0, 2.0.2, 1.5.2
>
>
> On an instance of FormTable we have the capability to set the sorted column, sorted ascending, and page number values. These methods are inherited from the Table class but no overridden methods are provided in Form Table.
> When the form table is rendered there are hidden form fields defined which are intended to store the values of these properties but the values of these hidden fields don't ever seem to be set. These hidden fields get rendered in the startTag() method of the internal form...
>             buffer.append(getForm().startTag());
> Because these fields are not populated, the submit function is not aware of any sorting that has been applied to the table and the values are often populated into the wrong underlying objects if the default sorting of the table is not the same as the explicit sorting of the table.
> I've resolved this for my application by subclassing FormTable and overriding the 3 relevant methods as follows:
>     public void setSortedColumn(String columnName) {
>         Field field = (Field)getForm().getFields().get(COLUMN);
>         if(field != null){
>             field.setValue(columnName);
>         }
>         setSorted(false);
>         super.setSortedColumn(columnName);
>     }
>     public void setSortedAscending(boolean ascending) {
>         Field field = (Field)getForm().getFields().get(ASCENDING);
>         if(field != null){
>             field.setValue("" + ascending);
>         }
>         setSorted(false);
>         super.setSortedAscending(ascending);
>     }
>     public void setPageNumber(int pageNumber) {
>         Field field = (Field)getForm().getFields().get(PAGE);
>         if(field != null){
>             field.setValue("" + pageNumber);
>         }
>         super.setPageNumber(pageNumber);
>     }
> These overridden methods should be in FormTable to resolve this bug. I have been working with version 1.5 so it may already be resolved in a later version.
> Note also that I am calling setSorted(false) in the first 2 methods.
> BW.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CLK-527) FormTable sort fields are not populated for render

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702934#action_12702934 ] 

Bob Schellink commented on CLK-527:
-----------------------------------

Thanks Ben.

Regarding the setSorted(false) calls, why is that needed? Did you run into issues if this was not set?

kind regards

bob

> FormTable sort fields are not populated for render
> --------------------------------------------------
>
>                 Key: CLK-527
>                 URL: https://issues.apache.org/jira/browse/CLK-527
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5
>            Reporter: Ben Warner
>
> On an instance of FormTable we have the capability to set the sorted column, sorted ascending, and page number values. These methods are inherited from the Table class but no overridden methods are provided in Form Table.
> When the form table is rendered there are hidden form fields defined which are intended to store the values of these properties but the values of these hidden fields don't ever seem to be set. These hidden fields get rendered in the startTag() method of the internal form...
>             buffer.append(getForm().startTag());
> Because these fields are not populated, the submit function is not aware of any sorting that has been applied to the table and the values are often populated into the wrong underlying objects if the default sorting of the table is not the same as the explicit sorting of the table.
> I've resolved this for my application by subclassing FormTable and overriding the 3 relevant methods as follows:
>     public void setSortedColumn(String columnName) {
>         Field field = (Field)getForm().getFields().get(COLUMN);
>         if(field != null){
>             field.setValue(columnName);
>         }
>         setSorted(false);
>         super.setSortedColumn(columnName);
>     }
>     public void setSortedAscending(boolean ascending) {
>         Field field = (Field)getForm().getFields().get(ASCENDING);
>         if(field != null){
>             field.setValue("" + ascending);
>         }
>         setSorted(false);
>         super.setSortedAscending(ascending);
>     }
>     public void setPageNumber(int pageNumber) {
>         Field field = (Field)getForm().getFields().get(PAGE);
>         if(field != null){
>             field.setValue("" + pageNumber);
>         }
>         super.setPageNumber(pageNumber);
>     }
> These overridden methods should be in FormTable to resolve this bug. I have been working with version 1.5 so it may already be resolved in a later version.
> Note also that I am calling setSorted(false) in the first 2 methods.
> BW.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CLK-527) FormTable sort fields are not populated for render

Posted by "Ben Warner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702969#action_12702969 ] 

Ben Warner commented on CLK-527:
--------------------------------

Hey Bob,

Yes I did have issues with this. The setSortedColumn method on Table looks like this:

    public void setSortedColumn(String value) {
        sortedColumn = value;
    }

Changing the sort column does not update the sorted value to false.

The render method calls sortRowList() before rendering the body rows:

    protected void sortRowList() {
        if (!isSorted() && StringUtils.isNotBlank(getSortedColumn())) {
            Column column = (Column) getColumns().get(getSortedColumn());
            Collections.sort(getRowList(), column.getComparator());
            setSorted(true);
        }
    }

The first time this method gets called it will set the 'sorted' variable to true and no matter how many times you change the sort column or direction this 'sorted' variable does not get re-initialised. The second time we come into sortRowList() the list only gets sorted if the isSorted() method returns false:

    public boolean isSorted() {
        return sorted;
    }

So, if you change the sort column between when the table was first sorted and when it was rendered, the new sort order will not be reflected in the table. There lies the problem.

Regards,
BW.

> FormTable sort fields are not populated for render
> --------------------------------------------------
>
>                 Key: CLK-527
>                 URL: https://issues.apache.org/jira/browse/CLK-527
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5
>            Reporter: Ben Warner
>
> On an instance of FormTable we have the capability to set the sorted column, sorted ascending, and page number values. These methods are inherited from the Table class but no overridden methods are provided in Form Table.
> When the form table is rendered there are hidden form fields defined which are intended to store the values of these properties but the values of these hidden fields don't ever seem to be set. These hidden fields get rendered in the startTag() method of the internal form...
>             buffer.append(getForm().startTag());
> Because these fields are not populated, the submit function is not aware of any sorting that has been applied to the table and the values are often populated into the wrong underlying objects if the default sorting of the table is not the same as the explicit sorting of the table.
> I've resolved this for my application by subclassing FormTable and overriding the 3 relevant methods as follows:
>     public void setSortedColumn(String columnName) {
>         Field field = (Field)getForm().getFields().get(COLUMN);
>         if(field != null){
>             field.setValue(columnName);
>         }
>         setSorted(false);
>         super.setSortedColumn(columnName);
>     }
>     public void setSortedAscending(boolean ascending) {
>         Field field = (Field)getForm().getFields().get(ASCENDING);
>         if(field != null){
>             field.setValue("" + ascending);
>         }
>         setSorted(false);
>         super.setSortedAscending(ascending);
>     }
>     public void setPageNumber(int pageNumber) {
>         Field field = (Field)getForm().getFields().get(PAGE);
>         if(field != null){
>             field.setValue("" + pageNumber);
>         }
>         super.setPageNumber(pageNumber);
>     }
> These overridden methods should be in FormTable to resolve this bug. I have been working with version 1.5 so it may already be resolved in a later version.
> Note also that I am calling setSorted(false) in the first 2 methods.
> BW.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.