Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Listen for changes of the checked state in the embedded table of an AbstractTableField
Listen for changes of the checked state in the embedded table of an AbstractTableField [message #1042295] Tue, 16 April 2013 04:32 Go to next message
Fredrik Möller is currently offline Fredrik Möller
Messages: 11
Registered: April 2013
Junior Member
Hello

In my form class that extends AbstractForm there is a field of type AbstractTableField. The embedded table of this field has the property "Checkable" selected.

In my form i would like to be able to listen for changes of the checked state of the rows in the embedded table (to be able to activate or deactivate the save form button of the form).

I have tried the following:

@Override
  protected void execInitForm() throws ProcessingException {
    
    // For every field...
    for (IFormField field : getAllFields()) {
      field.addPropertyChangeListener("value", validationListener);
      field.addPropertyChangeListener("empty", validationListener);
    }

    // PropertyChangeListener for the activation of the Ok Button
       addPropertyChangeListener("saveNeeded", new PropertyChangeListener() {
      @Override
      public void propertyChange(PropertyChangeEvent event) {
        if (event.getNewValue().equals(false)) {
          getOkButton().setEnabledGranted(false);
        }
        else {
          getOkButton().setEnabledPermission(new UpdateStammdatenBibPermission());
        }
      }
    });
  }


My problem is that it does not seem to be any events fired when the checkboxes are selected or deselected in the embedded table.

BR
Fredrik Möller
Re: Listen for changes of the checked state in the embedded table of an AbstractTableField [message #1042737 is a reply to message #1042295] Tue, 16 April 2013 16:22 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 643
Registered: October 2011
Senior Member
Hi,

Thanks for your question.

I look at the code and figured out that the number of checked rows is not considered when the table field computes if it contains modifications or not.

To add this behavior, you can override execIsSaveNeeded() in your table field:
@Override
protected boolean execIsSaveNeeded() throws ProcessingException {
  boolean b = super.execIsSaveNeeded();
  if (b == false && getTable().getCheckedRows().length > 0) {
    b = true;
  }
  return b;
}


In my opinion this can be explained: per default, eclipse scout does not consider checked rows in table for "IsSaveNeeded", because from a persistence point of view this "checked/not checked" state is not relevant. It is not transferred to the FormData.

You need to do something with the "checked/not checked" information by yourself (it is your business logic). Therefore you also need to implement how your TableField should react with this information.

[Updated on: Tue, 16 April 2013 16:24]

Report message to a moderator

Re: Listen for changes of the checked state in the embedded table of an AbstractTableField [message #1065693 is a reply to message #1042737] Thu, 27 June 2013 03:45 Go to previous message
Fredrik Möller is currently offline Fredrik Möller
Messages: 11
Registered: April 2013
Junior Member
Hello Jeremie

Late feedback, but I just wanted to say that your information helped me forward.

Thank you.

Best regards
Fredrik Möller
Previous Topic:text of processing error dialog
Next Topic:SmartField.execValidateValue cannot be used
Goto Forum:
  


Current Time: Wed Jul 30 13:30:32 EDT 2014

Powered by FUDForum. Page generated in 0.06219 seconds