Hi Daniel,
 
You cannot register listeners for keyboard shortcuts on a ULC component. So you'll need to create an extension anyways. In that extension on the client-side you could extend the action map in the following way:
        getBasicTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
                KeyEvent.VK_F2, 0, "saveChanges");
        getBasicTable().getActionMap().put("saveChanges", new AbstractAction()
        {
            public void actionPerformed(final ActionEvent e)
            {
                if (getBasicTable().isEditing())
                {
                    getBasicTable().getCellEditor().stopCellEditing();
                }
                invokeULC("saveChanges");
            }
        });
I haven't tested this and it's far from complete. You'll need to implement saveChanges in the server side of your extension. F2 is probably not the best idea for the shortcut. Here it toggles the editing mode of the current cell. You probably should post again to the ULC developer list if this doesn't help. Maybe someone else can provide better advice.
 
Cheers,
  Robert
 
----- Original Message -----
Sent: Wednesday, July 12, 2006 11:01 AM
Subject: RE: [ULC-developer] stopCellEditing

Well i can tell you one case where i need stopCellEditing() (or another solution).
 
If the user is currently editing a cell and then presses the shortcut (e.g. "F2") in order to save the changes, the changes he made to the currently editing cell are not written to the model.
 
I found out that you can change some of these settings over the delivery mode:
 
ULCTableModelAdapter.getInstance(table.getModel()).setEventDeliveryMode(UlcEventCategories.MODEL_UPDATE_CATEGORY, UlcEventConstants.SYNCHRONOUS_MODE);
 
Is there any setting i can change to force the editor to write the current editing value to the server?
Otherwise i have to live with your solution. But the problem is the additional client/server roundtrip i produce.
 
Greets
Daniel


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ulc rbeeger
Sent: Dienstag, 11. Juli 2006 10:55
To: Daniel Dilitz; [EMAIL PROTECTED]
Subject: Re: [ULC-developer] stopCellEditing

Hi Daniel,
 
AFAIK something like that cannot be achieved because of how ULC works. The method calls that are send from the server to the client are collected and returned to the client as a response to the request that started your server code - some event in most cases. So even if you write an extension to ULCTable that provides this stopCellEditing method, there is no way to make it synchronous.
You'll have to do something like that instead:
addCellEditingStoppedListener(new CellEditingStoppedListner()
{
  public void cellEditingStopped()
  {
    saveTableData();
  }
});
stopCellEditing();
 
You need to create this new listener type and create obligatory bunch of listner related operations (see the ULC Extension guide).
stopCellEditing on the client has to trigger the event once it called the stopCellEditiing() method on the table.
 
You should check whether you really need it, though. ULCTable is smarter than the Swing JTable. In some situation where you would need to explicitely stop cell editing with a Swing JTable, ULC stops it by itself - e.g. clicking on a button..
 
Cheers,
  Robert
----- Original Message -----
Sent: Tuesday, July 11, 2006 9:35 AM
Subject: [ULC-developer] stopCellEditing

Hi
 
I need a method like stopCellEditing() on my table which forces the table to stop cell editing and call the validation on current editing cell.
The problem is, if i enhance my table which such a call (which would call the client and there call the stopCellEditing() on jtable) the call would be asynchronous.
 
But i need a synchronous stopCellEditing() for code like this:
 
public void saveTable(){
   stopCellEditing();
   saveTableData();
}
 
Can you give me a hint how to achieve this?
 
Thanks in advance
 
Daniel

Reply via email to