Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with cell Editing of three columns

 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am having a problem in editing three columns,
My problem is , I am able to edit the three columns and able to get the values of three columns,

But if I won't edit any one of these three columns even though I am asigning the value manually ,the editor value is pointing to null

I am giving the code below,


The if statement which I had used in the code is not executing, and I am not getting any errors
Please can any one help me in this,
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which if statement is not executing?
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swastik Dey,

thanks for your quick reply

Not even one of th if is working

If editor value is null I am unable to asign the value through the if statements
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Now in the above case even if stepname is null, the ternary operator and if condition must execute.
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,



I had tried the code like this also ,

But even the Print statements is also not executing,

I am not understanding that where I had done a mistake,

Could you give me any Idea,

Thanks a lot,
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JTable.html#getCellEditor(int,%20int)

Is there any problem with the parameters passed to the method?

 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the entire code in a try catch handler and see if you get any exception. If you have three columns, this line is likely to throw some exception

 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,

No, I am printing the values also,

If we are not editing the value, then the cell is going to be blank,

In order to avoid this I am again passing the old value which is in the cell before editing,

But I am unable to do that, Still my cell is pointing to blank,

 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From where are you passing the old values?
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you just wish to retrieve values of the cells, I think its better to use getValueMethod of JTable class.

http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/table/TableModel.html#getValueAt(int,%20int)
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey,

I am getting the values from the before table,

and passing them here, But there is not at all a problem from the old values

Because I am Printing the values befor asigning them, So they are perfect,


Thank you very much for spending your valuable time
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by before table? Do you mean that you have two tables, and values retrieved from is assigned to another one? Sorry if I am wasting your time.
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey,

No Don't think like that of wasting my time,

Actually I am displaying a table and it is having "4" columns and some "x" number of rows,

columns names are(ID, Step Name, Step Type, DTSPackage)

if the user double clicks in the ID column of any row then a new sub screen is opened with the table of same row values,

So, to do this I am reading the values from the main table and displaying the single row with the edit mode inorder to edit the values

So I am assigning the same values which I had read from the main table when the user does not edit the value(as it is pointing null , if the user does not edit it),

for this I am using the code which I had send to you before,

If you want I will send the total java code what I am using,

Thanks a lot

 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you wish you can.
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey,



Here is the code, please have a look,

Thanks
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are probably getting the values from your previous table in the constructor, correct me if I am wrong. But which method is setting the values in the new table?
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,

Yes I am getting the values from my previous table,

and the method is

and actual method used is

and the code used for this method to get the data is

this one to set the values from the table,

Thanks a lot,
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at these three lines


Don't you think that when setDataSet(data) is called, the variable data has been just initialized( StorageDataSet data = new StorageDataSet(); ), but it does not contain any thing.

I think the code should be
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,

Well, I don't think so,

Because my getData() method is working perfectly and I am getting the data also,

My main problem is just to replace the unedited value with the previous value instead of null[code=java]


Thanks,
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you include a print statement in between, what does data print?

 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,



I am getting this value for the above print statement

Data value=com.borland.dx.dataset.StorageDataSet@1cd6d1f:ID=6:Step Name=Load Fact Table:Step Type=Transaction Data UploadTS Package=AM_OPS_CTRL_TX_OA_UPLOAD_OPS_DATA

This is the value which I am getting from the table,

Thanks,
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this data is set to the table, but the table cell values are still null??
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I am setting the data to my table

 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, even after calling the method you are getting a blank table, right? Probably the setDataSet method belongs to either of these two classes, CBRCommentedTable/CBRDefaultTable. Can you show the code of showDataSet method?
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, It does not belong to those 2 classes,

It belongs to class

 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't worked with this third party library, however I just went through the api doc of the class you mentioned, but I didn't find any method called setDataSet. Please have a look.

http://147.91.177.212/extra/java2/libs/dbswing/ref/dx/com.borland.dx.dataset.StorageDataSet.html
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More over your getTable() method is returning CBRDefaultTable, so the method should belong to this class, correct me if I am wrong.
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, you are right getTable() belongs to CBRDefaultTable
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you are calling setDatSet method on this, right?
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,

Apologies for the late reply!
Yes, I am calling ,


Thanks,
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need for the Apologies. Now the point is the data you are getting is not null. However after calling the setDataSet method with this data, you are getting a blank table. So it seems that there is something wrong with the setDataSet method, correct me if I am wrong.
 
Kushi Gadiparthi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Swastik Dey,

I don't think so because I am getting tha data for the table perfactly,

My problem is not related with this because I am getting the row values perfectly after getting the data in to the table, I just want to substitute this values if the related cell is not edited


Thanks

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic