Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spreadsheet custom component

 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the link! Yes, this is very interesting indeed... Do you think AJAX could assist us in this?
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AJAX?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kristin Stromberg
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic