Hi Mario,
ULC uses the IEditorComponent you provide in your ITableCellEditor only as a
template. ULC only reads the _visual_ attributes from these templates and
then sends them to the UIEngine if necessary. So all listeners attached to
your IEditorComponent are ignored by ULC.
When you change value on the editor, the editor sets value on the
client-side model when editing stops. The table model update event is then
propagated to the server side model. 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
DummyTableModel model = new DummyTableModel();
ULCTable table = new ULCTable(model);
ClientContext.setModelUpdateMode(model,
UlcEventConstants.SYNCHRONOUS_MODE);
I hope this helps.
Thanks and regards,
Janak
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Mario H.
>Castillo
>Sent: Tuesday, August 01, 2006 11:32 AM
>To: [EMAIL PROTECTED] Com
>Subject: [ULC-developer] CheckBoxRenderer sample with valuechanged
>listener
>
>
>
>Hi,
>
>I extended one of your examples in order to ask the following question:
>
>Can tell me how come the valuechanged listener that I added is never
>executed? I want to to know when the checkbox has been changed. The same
>applies for ULCTextField.
>
>==============
>
>import com.ulcjava.base.application.*;
>import com.ulcjava.base.application.event.IValueChangedListener;
>import com.ulcjava.base.application.border.ULCAbstractBorder;
>import com.ulcjava.base.application.border.ULCEmptyBorder;
>import com.ulcjava.base.application.table.DefaultTableModel;
>import com.ulcjava.base.application.table.ITableCellRenderer;
>import com.ulcjava.base.development.DevelopmentRunner;
>
>public class TestULCTextField extends AbstractApplication {
> private static final int CHECK_BOX_COLUMN = 2;
> // CLASS HERE
> class MyIValueChangedListener implements IValueChangedListener
> {
> public void
>valueChanged(com.ulcjava.base.application.event.ValueChangedEvent event){
> ULCCheckBox source = (ULCCheckBox)event.getSource();
> System.out.println("value changed for: " + source.getText()
> + ". new value is: " + source.isSelected());
> }
> }
>
> public void start() {
> ULCTable table = new ULCTable(new DummyTableModel());
>
>
>
>table.getColumnModel().getColumn(CHECK_BOX_COLUMN).setCellRenderer(new
>CheckBoxRenderer());
>
> ULCCheckBox editorComponent = new ULCCheckBox();
> editorComponent.setBorderPainted(true);
> editorComponent.setHorizontalAlignment(ULCCheckBox.CENTER);
> editorComponent.setOpaque(true);
> editorComponent.setForeground(table.getSelectionForeground());
> editorComponent.setBackground(table.getSelectionBackground());
>
> MyIValueChangedListener listener = new MyIValueChangedListener();
>
> // LISTENER HERE
> // How come this value changed listerner is never called? ---
> editorComponent.addValueChangedListener(listener);
>
>
>editorComponent.setBorder(ClientContext.getBorder("Table.focusCellH
ighlightBorder"));
>
>table.getColumnModel().getColumn(CHECK_BOX_COLUMN).setCellEditor(new
> DefaultCellEditor(editorComponent));
>
> ULCFrame frame = new ULCFrame("TestULCTextField");
> frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
> frame.add(new ULCScrollPane(table));
> frame.setVisible(true);
> }
>
> public static void main(String[] args) {
>
> DevelopmentRunner.setApplicationClass(TestULCTextField.class);
> DevelopmentRunner.main(args);
> }
>
> private static class CheckBoxRenderer extends ULCCheckBox implements
>
> ITableCellRenderer {
> private ULCAbstractBorder fNoFocusBorder;
>
> public CheckBoxRenderer() {
> fNoFocusBorder = new ULCEmptyBorder(1, 1, 1, 1);
>
> setBorderPainted(true);
> setHorizontalAlignment(CENTER);
> setOpaque(true);
> }
>
> public IRendererComponent getTableCellRendererComponent(ULCTable
>table, Object value, boolean isSelected, boolean hasFocus, int row) {
> if (isSelected) {
> setForeground(table.getSelectionForeground());
> setBackground(table.getSelectionBackground());
> } else {
> setForeground(table.getForeground());
> setBackground(table.getBackground());
> }
>
> setBorder(hasFocus ?
>ClientContext.getBorder("Table.focusCellHighlightBorder") :
>fNoFocusBorder);
>
> return this;
> }
> }
>
> private static class DummyTableModel extends DefaultTableModel {
> public DummyTableModel() {
> super(new Object[0][5], new String[]{"one", "two",
>"three","four", "five"});
> for (int row = 0; row < 100; row++) {
> addRow(new Object[]{row + ":0", row + ":1", row %
>CHECK_BOX_COLUMN == 0 ? Boolean.TRUE : Boolean.FALSE, row + ":3", row
>+":4"});
> }
> }
> }
>}
>
>Mario
>
>_______________________________________________
>ULC-developer mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/ulc-developer
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer