aspose file tools*
The moose likes JSF and the fly likes Spreadsheet custom component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Spreadsheet custom component" Watch "Spreadsheet custom component" New topic
Author

Spreadsheet custom component

Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
Currently all the custom sorting of tables is done via js client side. We want to switch to a model that sorts on the server side. Would it be possible to create a custom component for this? Maybe even make use of the Java Excel API? Eventualy we want to be able to export the filtered/sorted tables to a spreadsheet... any thoughts? Thank you; I really apreciate your time

-D.P.
Kevin Galligan
Ranch Hand

Joined: Aug 10, 2005
Posts: 70
Well, for the table display with sorting I'd look into this component...

http://myfaces.apache.org/tomahawk/extDataTable.html

The excel export is a pretty good idea. At my day job we're doing that for some reports, so now you got me thinking.

A custom component would probably work, but I was thinking you could also write a standard function to handle this.

1) Bind the table to a bean propery
2) Have a link that calls an 'exportExcel' function or something similar
3) Get the DataModel and the column children
4) Loop through the data model rows, then through the column children for each row, and build the file (JExcel or apache's POI)

How to deliver the file I'm not too clear on. From what I've read you can short circuit the response writting, so your action handler function can just write the excel file. I do not know if that's true but I think it'll work.
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
Thank you for the link! Yes, this is very interesting indeed... Do you think AJAX could assist us in this?
Kevin Galligan
Ranch Hand

Joined: Aug 10, 2005
Posts: 70
AJAX?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Did someone just mention AJAX in my forum? ;)

100% my opinion: Something like sorting a table would be a bit complicated for AJAX. I fear that you would spend way too much time creating this (especially if your javascript knowledge is as bad as mine) and then dealing with the bugs. AJAX has it's uses, I supose. But I don't think this is one of them.

That aside, most non-Sun JSF impemenations have some sort of data table with sorting capabilities. And if you are stuck just using Sun's RI it's easily done. I made a plain h:dataTable sortable with my own links and backing bean methods. It really wasn't that difficult. But still easier if all that is wrapped up in a tag like MyFaces data table.


GenRocket - Experts at Building Test Data
Kristin Stromberg
Ranch Hand

Joined: May 17, 2005
Posts: 91
None of the hard part (the sorting) would have to be coded in JS. Just the easy stuff. AJAX just does the magical part of pulling the info from the server without having to reload the form. I think this would be a really nice solution for your problem!

Check out the HTML/JavaScript forum for more info....
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
hmm.. Thank you all for your help. I really apreciate it. Is there a chance I could see the source for your sortable data table? Although, the ability to grab new data without page refresh is always tempting... Thanks for the suggustions. Any other words of advice?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Daniel Prene:
hmm.. Thank you all for your help. I really apreciate it. Is there a chance I could see the source for your sortable data table? Although, the ability to grab new data without page refresh is always tempting... Thanks for the suggustions. Any other words of advice?


I don't have the source. It was written for a job.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Kristin Stromberg:
None of the hard part (the sorting) would have to be coded in JS. Just the easy stuff. AJAX just does the magical part of pulling the info from the server without having to reload the form. I think this would be a really nice solution for your problem!

Check out the HTML/JavaScript forum for more info....


I don't see how none of the sorting would have to be done with JS. When you have the page, it's HTML. The only way to reorder the data in HTML is using JS. Sure, the data would come back differently, but you can't refresh the page to redisplay the data if you are going to use AJAX, hence, JS would need to redraw your table for you with the data in the order you want.
 
 
subject: Spreadsheet custom component