• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MyFaces Data Table didn't work

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Data Table that's currently mapped to a ResultSet.

It displays data, but I'm not able to interact with it so I changed it to a MyFaces Data Table to see if that would allow me to click a check box and have that data saved in the updateable ResultSet (so I can determine which rows the user clicked).

To change the Core Data Table to a My Faces data table, I added the required line:

<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

to the top of the JSP.

I added the myfaces-all.jar into the common/lib folder of Tomcat 5.0.29.

Then I changed the "h:" to "t:" on the data table opening and closing tags.

The result?

Now, no data is displayed. No errors, no logs entries, nothing.

Is there a simple trick to display a simple ResultSet with a MyFaces data table?

Couldn't find any examples on setting up a MyFaces Data Table (the one on the Apache site is for illusturation only and doesn't include any specifics needed).

Thanks to anyone in advance!!!

-- Mike
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there are a few MyFaces specific entries that go in the web.xml. Download the examples zip and run the simple.war and then look at it's web.xml to see what you need.

As far as all your ResultSet issues, to be honest, I haven't dealt with straight JDBC for a very long time. It gets very tedious once you start using something like iBatis or Hibernate along with Spring.

Here is what I would suggest you do. Get away from binding to ResultSet's. Move all the data out of the ResultSet and into some sort of Pojo/Bean/whatever. Put those objects in a List and bind your data table to that list of objects. Then, when one of those objects' data changes, submit that update to the database in your data access layer. You don't have to change any of your JDBC stuff. Just add another layer, a model layer that isn't JDBC (ResultSets).

Tonight, when I get home from work, and if you ask nicely, , I'll whip out a quick example of what I am talking about and send you the entire project so you can see what I am talking about. If you need it that is. Let me know.
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pretty please!!! <s>

I think I know what you're talking about, but I'm not sure if I understand how to implement the listners and such.

I look forward to seeing your code.

Thanks very very much in advance!!!

-- Mike
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike, where do you want me to send the code?
 
Saloon Keeper
Posts: 27763
196
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

Originally posted by Gregg Bolinger:
Mike, where do you want me to send the code?



Could you post it here (or if it's too big, provide a URL)? JavaRanch is for sharing!
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll be glad to post Gregg's code in a day or two once I complete this project or Gregg can do in the meantime. <s>

What I did to fix the problems I was having was to, as Gregg suggested, dump the ArrayList as the Data List's data source and instead just use the ResultSet to create an ArrayList (I changed the DataModel to ListDataModel and little things like that).

Now, all is working great!

My project is almost done.

Thanks for all the fantastic help!!!

-- Mike
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops,

In my reply above I meant to say ...dump the *ResultSet* for the data source for the data table and just use the ResultSet to populate an ArrayList for the Data Table.

Sorry 'bout that.

-- Mike
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what I sent Mike.









 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is great.

I tried to add column sorting and got stuck. There is example code at:

http://www.irian.at/myfaces/sortTable.jsp.source

where they have things like this defined in the data table definition:
<t ataTable...
sortColumn="#{list.sort}"
sortAscending="#{list.ascending}"
preserveDataModel="true"
preserveSort="true">

then, an actual column:

<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="type" arrow="true">
<h utputText value="#{example_messages['sort_cartype']}" </t:commandSortHeader>
</f:facet>
<h utputText value="#{car.type}" />
<f:facet name="footer">
<h utputText id="ftr1" value="(footer col1)" />
</f:facet>
</h:column>

What I think I'm missing is what needs to actually be in the "list" mentioned in the table definition above.

I currently have the table tags appearing, but since I don't have this "cars.list" implemented, nothing is sorting.

Is it simple to get the sorting working?

Look forward to hearing how to do this.

Thanks.

-- Mike
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you take the example I provided "list" would == "personList" and it's up to you to provide a sort()/ascending() method to sort your data in the list. It doesn't have to be called sort/ascending. You could call it sortThisCrap(). It works the same as calling an actionListener or action method.

You *might* have to give those methods a string and boolean argument though for MyFaces sorting. I am not 100% sure about that. I haven't really messed much with sorting. I downloaded the example simple.war source code and have been looking at that.
[ December 28, 2005: Message edited by: Gregg Bolinger ]
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic