update checkbox after asking the server

42 views
Skip to first unread message

andymel

unread,
Mar 31, 2015, 5:56:08 PM3/31/15
to google-we...@googlegroups.com, g...@andymel.eu
Hi,

I have a CellTable. One of the columns is build like this 
Column<MyProxy, Boolean> colIsReference =
new Column<MyProxy, Boolean>(new CheckboxCell()) {
@Override
public Boolean getValue(MyProxy rdm) {
return Boolean.valueOf(rdm.isReference());
}
};
colIsReference.setFieldUpdater(new FieldUpdater<MyProxy, Boolean>() {
public void update(final int index, final MyProxy rmd, Boolean value) {
  dataUpdater().setReference(
rmd,
value.booleanValue(),
false, // don't override current reference (opens dialog if there is another reference)
new Runnable() {
// called if canceled
public void run() {
      // --->  Do something that unchecks the checkbox  <---
  }
}
   );
}
});

When the user clicks the checkbox of an entry, the server checks if the value may be changed easily at the moment. If yes, I don't have a problem.
If not (some other things have to be changed too) - I ask the user if he wants to change all necessary stuff. The user can click ok or cancel. If he clicks ok, I have no problem. But if the user cancels I want to uncheck the checkbox again.

Whats the best way to do that? I tried to update the table with setRowData (because in my proxy in rmd the flag is still false!) and I have tried with the updateRowData of the asyncDataProvider that I use.

Is there a way to bind the gui closer to my proxy? Because at the moment run() is called the proxy flag is false but the checkbox is true.

Thanks in advance!!

andymel

unread,
Apr 20, 2015, 10:45:01 AM4/20/15
to google-we...@googlegroups.com, g...@andymel.eu
Let me simplify my question.

How can I update the rows that have changed? When I delete a complete entry/row 
table.setVisibleRangeAndClearData(table.getVisibleRange(), true);
works perfectly fine. But if the entries are not changed the checkbox is not changed back by that line of code. When I reload the page (pressing F5) all data is right again.
  1. I have some rows/entries with a checkbox/boolean
  2. I click it
  3. A dialog opens asking me "really?"
  4. I say "no"
  5. The checkbox should be unchecked again
Any advice?
Best regards!

Ignacio Baca Moreno-Torres

unread,
Apr 20, 2015, 2:10:59 PM4/20/15
to google-we...@googlegroups.com, g...@andymel.eu
Looks like the viewData is caching the result so redraw end up drawing the same state. You need to call checkboxCell.clearViewData(proxy) if the user cancel the update or alternatively you can extends CheckboxCell to not use viewData. Not sure wich one is worst :).

Reply all
Reply to author
Forward
0 new messages