My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 13: How easy it is to change the 3 states sort into 2 state sort?
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Oct 2007


 
Reported by nbaak...@gmail.com, Apr 30, 2007

I would like to change the 3 states sort click into 2 states click and 
have the clear on the arrow click.

Is it hard to customize it, or it is possible for you to add a property to 
the property file to configure the sort states?

Thanks
Nad
Apr 30, 2007
#1 extremec...@gmail.com
This feature is built in. There were a few ways to do it, and I decided the easiest
way was to just provide a boolean on the HeaderRenderer. I forgot to document this,
but it is documented now. Look at the HeaderRenderer section and then at the
defaultSortOrderable attribute.

https://code.google.com/p/jmesa/wiki/Renderers

If you need something further you could grab the HtmlHeaderRendererImpl and customize
it. You can set your own renderers as needed on the column.

For the clear part of your request I was thinking we could just call the
removeAllSortsFromLimit(id); in the onInvokeAction() function on your page, but there
is no way to tell which button was clicked. For now if you really need this you will
have to take the HtmlHeaderRendererImpl and tweak it to make that call.

Or, actually a better way would be to take the jmesa.js file and put the
removeAllSortsFromLimit(id); as the first or last call in the
removeAllFiltersFromLimit(id) function. That would be the easiest way to do it. If
you notice the removeAllFiltersFromLimit(id) function is called when you click the
clear button. That does make your javascript custom, but this a pretty easy change
for now. Keep in mind that the javascript merely controls what information is passed
to the Limit...think of it as setting the Limit into controlled states from
javascript. I'll leave it up to you on how you would work this out with the
defaultSortOrderable as the two might bumps heads because they are not tied to each
other.

What I will do is keep this as a feature request and the todo will be to give people
a way to know what button was invoked, or something like that. The idea is that I
want people to be able to customize things in the onInvokeAction() function. We will
just have to enhance this feature some. 







Status: Accepted
May 1, 2007
#2 nbaak...@gmail.com
Thank you for the quick response, I took your advice and I set the 
defaultSortOrderable to false and added removeAllSortsFromLimit(id); to 
removeAllFiltersFromLimit(id) function.
I had to change one thing:
    column.getHeaderRenderer().setDefaultSortOrderable(false);
to 
    ((HtmlHeaderRenderer)column.getHeaderRenderer()).setDefaultSortOrderable(false);
to make it work.

I was a little bit adventurer and I replaced the arrow image with input image with 
onClick I added "removeSortFromLimit(id,property);onInvokeAction(id)" in the 
HtmlHeaderRendererImpl class.
The code change I made from:
        html.img();
        html.src(imagesPath + getCoreContext().getPreference
(HtmlConstants.SORT_ASC_IMAGE));
        html.style("border:0");
        html.alt("Arrow");
        html.end();
to 
        html.input().type("IMAGE");
        html.src(imagesPath + getCoreContext().getPreference
(HtmlConstants.SORT_ASC_IMAGE));
        html.onclick("removeSortFromLimit('" + limit.getId() + "','" + 
column.getProperty() + "');onInvokeAction('" + limit.getId() + "')");
        html.close();
and the same for DESC

To my surprise I got NumberFormatException error. What happen is when 
removeSortFromLimit(id,property) get invoked in the input image tag, the hidden page 
number get posted twice, and the class LimitActionFactoryImpl.getPage() tries to 
format an object array and fails with NumberFormatException error. I don't 
understand why removeSortFromLimit(id,property) works fine when invoked from the td 
tag.

Any way thanks for your help.
Nad

May 1, 2007
#3 extremec...@gmail.com
You shouldn't need to cast though. I am using the Java 1.5 feature of returning a
specific return type for different view implementations. For example this is what I
do when using the html view. This would work regardless of the factory you use.

HtmlComponentFactory factory = new HtmlComponentFactory(webContext, coreContext);
HtmlColumn firstName = factory.createColumn("name.firstName", customEditor);
firstName.getHeaderRenderer().setDefaultSortOrderable(false);

Not sure about the other things you tried...I'd have to try it myself.


May 2, 2007
#4 nbaak...@gmail.com

It work only if getting the column return HtmlColumn; and this what I used:

HtmlTableFactory tableFactory = new HtmlTableFactory(webContext, coreContext);
HtmlTable table = tableFactory.createTable("X", "name", "nickname", "term");
Column firstName = table.getRow().getColumn("name");
((HtmlHeaderRenderer)firstName.getHeaderRenderer()).setDefaultSortOrderable(false);

If table.getRow().getColumn(...) returns an HtmlColumn then I would not have to cast.

May 2, 2007
#5 extremec...@gmail.com
I will check into this then. It would be preferred if developers would not have to
cast anything.
May 2, 2007
#6 extremec...@gmail.com
I have this checked into the head stream so it will appear in the next release. I
will be doing another release in the next couple weeks with the start of the extra
Groovy hooks so you can refactor your code then.
May 2, 2007
#7 extremec...@gmail.com
I guess I was pretty vague on my last post...the HtmlRow now returns a HtmlColumn
when doing a row.getColumn()!
May 3, 2007
#8 nbaak...@gmail.com
Thanks
Oct 25, 2007
#9 extremec...@gmail.com
Will close and open as a separate issue with the correct naming.
Status: Fixed

Powered by Google Project Hosting