Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Datatable not updating when clicking on commandlink

 
Andrew Dambrosio
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JSF1.2 and Richfaces 3.3 and have a datatable with a column that contains an up arrow and another column that has a down arrow. These allow you to move the row up and down. However, when I click on them, the moveUp method in the bean is triggered and the order is updated, but I don't see this in my browser. When I trigger it again, I can tell (with printlns) that the order is reset to what was originally retrieved from the database.
Below is an extract of my JSP and bean. Please help
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A commandLink will never execute if any data on the form fails valiadation. That's the most common problem people have - they didn't put a general "errors" tag on the page, forgot to set a field value, and the message was lost.

However, in this case, I think it's most likely that your actionListener is invalid. You provided a "throws Exception" clause to the method signature and I think that disqualifies it from being seen by the EL processor. If you need to throw an exception, wrap it in a JSFException. They're unchecked, so they don't need to be declared in the signature.

In any event, there's no benefit in using an actionListener here. You should use a simple "action" instead.
 
Andrew Dambrosio
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried what you said and it made no difference. The datatable is not rerendered properly. At the end of the moveUp method, the order is correct. But it seems like between the end of that method and the re-render, the changes are lost. I added a <h:messages> tag and there is no error.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little confused here. You're showing code for binding a dataTable, although for this particular function, there's no need for binding.

But you're not showing how you defined the DataModel object that wraps your data for the table, and that's the critical part.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic