Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Sort a Data Table using Headers & Other question  RSS feed

 
Mike London
Ranch Hand
Posts: 1334
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a JSTL Result which correctly connects to the database and displays the listing of employees for a session variable.

Hurray! <g>

Ok, now I need to implement sorting on the columns of the data table -- so when the user clicks a column the data table sorts by that column -- and be able to programmatically manipulate the data grid to update the database after the user interacts with it.

Here's what I'm thinking based on my JSF abilites thus far...

========================
Column Sorting...
========================

1. For each header of the data table... could put a command link control as the header like this...

(pseudo code)

<header for employee name...>
<h:commandLink action = "#{originalManagedBean.sortByName}">
</header>

Then, when the user clicks the header, it would kick off the method "sortByName()" in the bean that manages this JSF page. The bean would maintain a local variable to keep track of what the current sort was (asc or desc).

Would this be the best way to implement sorting for a data table against a database?


========================
Data Table Manipulation
========================

2. How to best manipulate the data table after the user has interacted with it (checked column check boxes for example) and I need to save those changes back to the database amd further manipulate the data.

Would I put some type of action on the individual column checkboxes so they update the JSTL Result or would handling the data table as a whole be done on Submit.

I'm really not clear on how I manipulate the JSTL Result object with my traditional "JSP-POST(Back)" way of thinking.

A key question I am running into is ... How do I get at the data table object and manipulate the results so I can do whatever I need to do with the JSTL Result's current dataset?

===========================

Thank you very much for any and all replies!!!

-- Mike
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't make it too hard on yourself. Some JSF controls support the "click-on-column-header" paradigm already. Apache MyFaces, for one, though the documentation's more than a little obscure.
 
Mike London
Ranch Hand
Posts: 1334
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

That's good to know.

The problem I'm having with JSF currently is exactly the current crop of documentation: either I can't find an example (like my other posting about not being able to find an example using a Data Table and a JSTL Result Model (or ResultSetModel)) or the documentation I could find is obscure.

Thank you very much for your reply.

-- M
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!