Hi Elisabeth,

The default delivery mode for model update event is
UlcEventConstants.DEFERRED_MODE. This means that the event
will be sent when the next roundtrip is initiated from the client.

Now if you want to trap every change of value, you can set the event
delivery mode to UlcEventConstants.SYNCHRONOUS_MODE

          DefaultTableModel model = new DefaultTableModel();
        ULCTable table = new ULCTable(model);
        ClientContext.setModelUpdateMode(model,UlcEventConstants.SYNCHRONOUS
_MODE);


Please see the snippet at the end of this mail.

When you edit a cell in a table, setValueAt is called on the client side
table model when editing stops. The client side table model then sends a
TableModelEvent to the server. When this event is sent is determined by the
UpdateMode.

I hope this works for you. If not, then we will have to look into your
ULCTable extension.

Thanks and regards,

Janak
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Kliman, Elizabeth
Sent: Wednesday, August 16, 2006 2:19 AM
To: ULC Developer List (E-mail)
Subject: [ULC-developer] Table setValueAt method


Hi,
We're in the middle of converting our code to ULC 6.1 and we have run into a
snag with the table.  We do some validation when users enter data into the
table.  This does not work anymore because the setValueAt method is not
being called until the last minute - when the pane is about to close - which
is too late.
I saw the email discussion with the subject line "RE: [ULC-developer]
CheckBoxRenderer sample with valuechanged listener".  From this email it
sounds like the model update mode is DEFERRED, and so the new values will
not get sent to the server side until something else initiates a round trip.
I tried adding in the line specifying that the model update mode should be
SYNCHRONOUS, but this has had no effect.
Is there something we can do to make the table work the way it used to where
the setValueAt method is called as soon as the user tabs off or clicks off
the particular cell they were editing?
Also, please note that we've got lots of extensions integrated into our
application - including an extension on ULCTable.  It's possible one of our
extensions is doing something weird, but I thought I'd ask if there was an
intentional change to the way the setValueAt method gets called in a table
and if there is a simple way to change it.
Thanks.
Elizabeth Kliman, B.Sc., SCJP
------------------------------------------


import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ClientContext;
import com.ulcjava.base.application.IEditorComponent;
import com.ulcjava.base.application.IRendererComponent;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCCheckBox;
import com.ulcjava.base.application.ULCComponent;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.event.ITableModelListener;
import com.ulcjava.base.application.event.TableModelEvent;
import com.ulcjava.base.application.table.DefaultTableModel;
import com.ulcjava.base.application.table.ITableCellEditor;
import com.ulcjava.base.application.table.ITableCellRenderer;
import com.ulcjava.base.application.table.ULCTableColumn;
import com.ulcjava.base.development.DevelopmentRunner;
import com.ulcjava.base.shared.UlcEventConstants;

public class ULCTableUpdateModeSnippet extends AbstractApplication {

    protected ULCComponent createContent() {

        DefaultTableModel model = new DefaultTableModel(new Object[][] { {
"ho", Boolean.TRUE, "hey" },
                { "hi", Boolean.FALSE, "ha" } }, new String[] { "More Text",
"My Boolean", "My Text" });
        ULCTable table = new ULCTable(model);
        ClientContext.setModelUpdateMode(model,
UlcEventConstants.SYNCHRONOUS_MODE);


        ULCTableColumn col = table.getColumnModel().getColumn(1);
        col.setCellRenderer(new CheckBoxRenderer());
        col.setCellEditor(new CheckBoxEditor());
        model.addTableModelListener(new ITableModelListener() {

            public void tableChanged(TableModelEvent event) {
                int col = event.getColumn();
                int row = event.getFirstRow();
                DefaultTableModel model =
(DefaultTableModel)event.getSource();
                System.out.println("Value at " + row + " " + col + " : " +
model.getValueAt(row, col));
            }

        });
        return new ULCScrollPane(table);
    }

    public void start() {
        ULCFrame frame = new ULCFrame("ULCTableUpdateModeSnippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        ULCBoxPane content = new ULCBoxPane(true);
        content.add(ULCBoxPane.BOX_EXPAND_EXPAND, createContent());

        frame.add(content);
        frame.setSize(200, 200);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(ULCTableUpdateModeSnippet.clas
s);
        DevelopmentRunner.main(args);
    }

    private static class CheckBoxRenderer extends ULCCheckBox implements
ITableCellRenderer {
        public IRendererComponent getTableCellRendererComponent(ULCTable
table, Object value, boolean isSelected,
                boolean hasFocus, int row) {
            return this;
        }
    }

    private static class CheckBoxEditor extends ULCCheckBox implements
ITableCellEditor {
        public IEditorComponent getTableCellEditorComponent(ULCTable table,
Object value, int row) {
            return this;
        }
    }

}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to