Hi Janak,

Thanks for the info.  I had actually tried this before, but I had been using 
our table extension, of course.  I decided to make my code exactly like your 
code (ie - without the extension - just a plain ULCTable) and it worked!  After 
some investigation I realized that I was using a SortedTableModel (from the 
community site) and that it was on the SortedTableModel that I had to set the 
model update mode to SYNCHRONOUS.  And as soon as I did that, it worked 
perfectly!

Thanks so much for all your help recently, Janak!


Elizabeth Kliman, B.Sc., SCJP
Developer / Développeur
Information Technology / Technologie de l'information 
Farm Credit Canada / Financement agricole Canada 
1800 Hamilton Street, P.O. Box 4320 
1800, rue Hamilton, C.P. 4320 
Regina SK S4P 4L3 
Tel/Tél. : (306) 780-3382 Fax/Télec. : (306) 780-5655 
E-mail/Courriel : [EMAIL PROTECTED]
Agriculture. It's all we do. L'agriculture... notre raison d'être. 
This message may contain information that is privileged, protected, 
confidential or subject to copyright. Using, disclosing, copying or 
distributing such information by anyone other than the intended recipient is 
strictly prohibited. If you've received this message in error, please delete it 
and notify me immediately.
Le présent courriel contient des renseignements de nature privilégiée, 
protégée, confidentielle ou assujettie à des droits d'auteur. Toute 
utilisation, communication, reproduction ou distribution de l'information 
contenue dans ce courriel par toute personne autre que le destinataire visé est 
strictement interdite. Si vous avez reçu ce courriel par erreur, veuillez le 
supprimer et m'en informer immédiatement.


-----Original Message-----
From: Janak Mulani [mailto:[EMAIL PROTECTED]
Sent: August 17, 2006 9:31 AM
To: Kliman, Elizabeth
Cc: ULC Developer List (E-mail)
Subject: RE: [ULC-developer] Table setValueAt method


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