Forum Discussion

AKarandjeff's avatar
AKarandjeff
Contributor
14 years ago

Determine Object Type within JTable

I am working on a script where I need to populate values within a customer JTable.  I start by pulling data from a table.  I find the swP variable in the table, and then need to populate the adjacent cell with a value.  At this point, that cell can either be a comboBox or a text field.  When I click in the cell where I need to put the value, I need to dynamically figure out what kind of object it is, so I can set the name mapping variable accordingly via the switch {case} statement.  The current values in the case statement are based off a recorded example where I just clicked through the fields.  The *** section is the one where I'm stuck, in particular, the <Need Help with Getting Object Type> part.  The application is a Java application.  I am going through and am trying to find the Java method that I can use to set that objType variable, but if anyone knows off hand, would greatly appreciate some assistance.  Thanks!



     propertyTable = switchPropertySheet.TabbedPane1.Panel.Panel.ScrollPane.Viewport.PropertyTable;  

    var swPropQry = "select SWITCHID, PROPERTY, PROPERTYVALUE from zqa_switch_properties where switchid = '" + swID + "' ORDER BY controlindex";  

    var swProp = DDT.ADODriver(ConStr, swPropQry);

    while(!swProp.EOF())

    {

     var swP = swProp.Value(1)

     var swPVal = swProp.Value(2)

     RowIndex = propertyTable.FindRow(0, swP);

     if (RowIndex != -1)

     {

      propertyTable.ClickCell(RowIndex, 1);

   ***var objType = <Need Help with Getting Object Type>***

   ***switch objType

   ***{

   *** case PropTypeComboBox:

   ***   textField = propertyTable.PropTypeComboBox.TextField;

   ***   break;

   *** case PropTypeTextField:

   ***   textField = propertyTable.PropTypeTextField;

   ***   break;

   ***}

      textField.wText = swPVal;

      textField.Keys = ("[Enter]");

     }

     else

      Log.Message(swP + "not found in Properties Table");

     swProp.Next() 

    }

    //Click OK  to save switch

    switchPropertySheet.Panel.Panel.Panel.Panel.Button.ClickButton();

    swMain.Next()

1 Reply

  • As it turns out, there really isn't an easy way to do this, or a java method that I could find.  Outside of clicking or getting cell values, you can't really extend into individual cells and do much there from a java perspective.  Fortunately, our application has sets of tables that define the object types that are used on our various panels and screens as they're generated dynamically.  I was able to take the parameter for a row, and trace it back through our data base and get the object type for the value field from a table.  I then set my variable based on that.