• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to Sort a Data Table using Headers & Other question

 
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 26300
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic