We have recently upgraded from ULC 6.0.3 to ULC 2008-b3.  We had to make a few 
minor changes, but nothing major.  However, when we call setValueAt on the 
client, it is not pumping the events to the client immediately from a cell 
editor. 

(When writing these classes originally, we couldn't get all of the 
functionality we needed using ULC editors/renderers, so they were written using 
Swing renderers/editors.  I now maintain this code, but I'm not sure what 
functionality we needed that wasn't available.) 

Here is the scenario, we have a table which contains schedule information for 
employees.  when you select a cell we begin editing that cell.  we setup the 
cell editors as the table is being created: 


public class WFMUITable extends UITable { 

... 
private JTable table ; 
... 
private void setCellEditor() { 


JTextField textField = new JTextField(); 
         
table.getColumnModel().getColumn(WeeklyTableModel.SUN_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
         
table.getColumnModel().getColumn(WeeklyTableModel.MON_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
         
table.getColumnModel().getColumn(WeeklyTableModel.TUE_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
         
table.getColumnModel().getColumn(WeeklyTableModel.WED_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
         
table.getColumnModel().getColumn(WeeklyTableModel.THU_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
         
table.getColumnModel().getColumn(WeeklyTableModel.FRI_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
         
table.getColumnModel().getColumn(WeeklyTableModel.SAT_COLUMN).setCellEditor(new 
WFMUITableCellEditor(this, textField)); 
} 
... 
} 


The editor then registers a keyboard action for the text field: 



public class WFMUITableCellEditor extends DefaultCellEditor { 


public WFMUITable uiTable; 
public JTextField text; 
public String textStr; 
public WFMUITableCellEditor(WFMUITable uiTable, JTextField text){ 
super(text); 
this.uiTable = uiTable; 
this.text = text; 
text.setBorder(BorderFactory.createMatteBorder(1, 2, 1, 1, Color.red)); 
text.addKeyListener(new WeeklyUITableCellKeyListener(uiTable)); 
setTextTabListeners(text); 
} 

private void setTextTabListeners(JTextField text2) { 
text.registerKeyboardAction(new ActionListener(){ //<-- register action when 
the tab key is pressed 
public void actionPerformed(ActionEvent arg0) { 
uiTable.setNextFieldToEdit(text.getText()); 
uiTable.tabKeyPressed = true; 
} 
},KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), 0); 
} 


public Component getTableCellEditorComponent(JTable table, Object value, 
boolean isSelected,  int row, int column) { 
table.repaint(); 
if(uiTable.empIDs != null && uiTable.uniqueEmpIds[row] != -1) { 
textStr = value.toString(); 
text.setText(textStr); 
text.selectAll(); 
text.revalidate(); 
text.repaint(); 
text.requestFocus(); 
uiTable.editMode = true; 
uiTable.updateMode(true); 
} else { 
return null; 
} 
return text; 
} 


When the "Tab" key is pressed, it calls the method in our table class which 
calls "setValueAt" on the table: 


public class WFMUITable extends UITable { 


... 
private JTable table ; 
... 
public void setNextFieldToEdit(String value) {  
currRow = table.getSelectedRow();  
currCol = table.getSelectedColumn();  
valueValidCount = 0;  
System.out.println("setNextFieldToEdit: table "+ currRow + " " + currCol + " 
value "+ value);  
table.requestFocus();  
table. setValueAt(value, currRow, currCol);  //<-- Not being called on the 
server side 
System.out.println("table.setValueAt() called");  
} 

... 
} 


I am seeing the above System.out's in the java console, but the table models 
"setValueAt" method is not being called until I either leave the page or click 
on a different cell with the mouse.  I searched through the Jira issues, but 
was unable to find any information as to why this may be happening.  As I 
originally stated, this started happening when we upgraded to a newer version 
(the latest at the time we did our upgrade.) but works fine when we go back to 
version 6.0.3. 


Please let me know if you need any more information. 
Thanks. 


BJ Tenney 
--------------------- 
Java Developer 
Tomax Corporation 
[email protected]

Reply via email to