BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to find out on which row JDBTable is working when callin

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder DB Swing
View previous topic :: View next topic  
Author Message
Alexander Pohl
Guest





PostPosted: Wed Dec 03, 2003 1:19 pm    Post subject: how to find out on which row JDBTable is working when callin Reply with quote



Hi all,

I have a problem with JDBTable. Environment is Oracle8i, JBuilder9 with
dbswing-lib of JBuilder7, JDK1.4.

The problem: I have a table A of let's say hobbies which stores an id of
another table B of humans OR C of aliens. When I display a record of table A
the user shall not see the id but a name constructed of of the appropriate B
or C forename and surname. So I implemented a JComboBox deriven component
which has a method setValue() called by JDBTable. Now, when setValue() is
called, I have to know the current row each time setValue() is called to get
the table's primary key of the current row and to be able to create the
display value (which is internally mapped to the id and rewritten when
calling my components getValue() method. When I call
jdbTable.getDataSet.getRow() in my setValue() method BEFORE the JDBTable is
visible (i.e. at construction time) the returned row id is allways 0, as if
it would not navigate through the dataset at construction time. When I call
jdbTable.getDataSet.getRow() after JDBTable is initialized and visible, e.g.
when navigating with the mouse or keyboard, the row id is correct.

Any idea anyone? Please do not propose to change my datamodel as this is not
possible.

Regards,

Alexander Pohl


Back to top
Paul Furbacher
Guest





PostPosted: Wed Dec 03, 2003 7:16 pm    Post subject: Re: how to find out on which row JDBTable is working when ca Reply with quote



Alexander Pohl wrote:

Quote:
The problem: I have a table A of let's say hobbies which stores an id of
another table B of humans OR C of aliens. When I display a record of table A
the user shall not see the id but a name constructed of of the appropriate B
or C forename and surname. So I implemented a JComboBox deriven component
which has a method setValue() called by JDBTable. Now, when setValue() is
called, I have to know the current row each time setValue() is called to get
the table's primary key of the current row and to be able to create the
display value (which is internally mapped to the id and rewritten when
calling my components getValue() method. When I call
jdbTable.getDataSet.getRow() in my setValue() method BEFORE the JDBTable is
visible (i.e. at construction time) the returned row id is allways 0, as if
it would not navigate through the dataset at construction time. When I call
jdbTable.getDataSet.getRow() after JDBTable is initialized and visible, e.g.
when navigating with the mouse or keyboard, the row id is correct.

Any idea anyone? Please do not propose to change my datamodel as this is not
possible.

Okay, no such proposal here, especially since it
doesn't look as though there's anything peculiar
about the database structure.

From you description, it's not clear as to whether
you are simply displaying data in this table, or
offering the user the opportunity to edit.

If it's just for display, why not create a column
which has the "calcType" property set to "CalcType.CALC".
Add a CalcFieldsListener to the dataset and implement
the "calcFields()" method in which you get the names
from the respective fields and set the "dataRow" field
appropriately (i.e., concatenate the first and last names).
Your dataset's SQL will have to include those name fields
from tables B and C, as in

select * from a, b, c
where a.id = b.id
and a.id = c.id

or something like that.

See the "orderLineItemDataSet_calcFields()" method
in the class "AppDataModule" found in
samples/dbSwing/MultiLingual/src/.../application/
(the IntlDemo).


If you are allowing the user to edit, that gets
quite a bit trickier. You would want to use
a picklist, but how would you get one with the first
and last names (based on whether it's an alien
or human?) in each choice item in the list?! You
might want to take a look at the "SizeColorEditor"
in the IntlDemo to get some inspiration.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.


Back to top
Alexander Pohl
Guest





PostPosted: Thu Dec 04, 2003 11:25 am    Post subject: Re: how to find out on which row JDBTable is working when ca Reply with quote



Hi Paul,

thanks for your reply.

Things are more complicated than it may look. First: I have to display the
table in both
modes, editable and non-editable. The problem is, that my JDBTable and the
QueryDataSet
are created dynamically for different tables with different structures. The
basic concept
of the project is to separate the GUI from the database structure. That
means no hardcoding
like 'if tablename=A' is allowed. The aim is to have a GUI which is capable
to work with
different database versions. So I have to put the business logic mainly into
the database
and use callable statements if possible.

There are two ways of editing data: in a panel representing only one record
or in a table
displaying several records. In panel mode I can get the records id, but in
table mode I can not.
Due to the overall concept I can not use calculateable columns. I can only
read and write
'real' columns and due to other internal reasons I can not enhance the table
and add a column
holding the name because the name may not be unique. What I actually do is
the following:
if a record is displayed, the component's setValue() method is called. It
reads the possible
target records, which may be located in different target tables, from the
database using
several column's values from the record to be displayed. Then it stores each
target records
id and name in a hashtable and fills the combo box with the names to be
displayed.
If the user picks a name from the combo box and the record is inserted or
updated, the
getMethod() translates the name selected in the combobox and stores the
associated id
from the hastable in the column. So the column allways holds an id, but
displayed is the
associated name. All this works fine, if I use the mechanism in panel mode,
because then
I know the record id and can determine, which callable statement is to be
executed in the
database.
So, doing the same in table mode assumes setValue() can get the correct row
id, else
the callable statement can not be executed and the id can not be translated.
My way to solve the problem depends on whether it is possible to get the row
id
at creation time or not. If it is possible I can use my component to resolve
the id in the
column to be displayed, if not I have to think of a different approach in
general.

I know, this is quite tricky... What I like to know is if my assumption, the
JDBTable
should navigate through the dataset constructing the view is correct or not.
If it is
correct, I should get the correct row id at any time, right? If not, I can
tell my customer,
it's a bug and this would help me too :-)

Regards,

Alexander Pohl



"Paul Furbacher" <pfurbacher (AT) mac (DOT) com> schrieb im Newsbeitrag
news:3fce36ac (AT) newsgroups (DOT) borland.com...
Quote:
Alexander Pohl wrote:

The problem: I have a table A of let's say hobbies which stores an id of
another table B of humans OR C of aliens. When I display a record of
table A
the user shall not see the id but a name constructed of of the
appropriate B
or C forename and surname. So I implemented a JComboBox deriven
component
which has a method setValue() called by JDBTable. Now, when setValue()
is
called, I have to know the current row each time setValue() is called to
get
the table's primary key of the current row and to be able to create the
display value (which is internally mapped to the id and rewritten when
calling my components getValue() method. When I call
jdbTable.getDataSet.getRow() in my setValue() method BEFORE the JDBTable
is
visible (i.e. at construction time) the returned row id is allways 0, as
if
it would not navigate through the dataset at construction time. When I
call
jdbTable.getDataSet.getRow() after JDBTable is initialized and visible,
e.g.
when navigating with the mouse or keyboard, the row id is correct.

Any idea anyone? Please do not propose to change my datamodel as this is
not
possible.

Okay, no such proposal here, especially since it
doesn't look as though there's anything peculiar
about the database structure.

From you description, it's not clear as to whether
you are simply displaying data in this table, or
offering the user the opportunity to edit.

If it's just for display, why not create a column
which has the "calcType" property set to "CalcType.CALC".
Add a CalcFieldsListener to the dataset and implement
the "calcFields()" method in which you get the names
from the respective fields and set the "dataRow" field
appropriately (i.e., concatenate the first and last names).
Your dataset's SQL will have to include those name fields
from tables B and C, as in

select * from a, b, c
where a.id = b.id
and a.id = c.id

or something like that.

See the "orderLineItemDataSet_calcFields()" method
in the class "AppDataModule" found in
samples/dbSwing/MultiLingual/src/.../application/
(the IntlDemo).


If you are allowing the user to edit, that gets
quite a bit trickier. You would want to use
a picklist, but how would you get one with the first
and last names (based on whether it's an alien
or human?) in each choice item in the list?! You
might want to take a look at the "SizeColorEditor"
in the IntlDemo to get some inspiration.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder DB Swing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.