Board index » jbuilder » JdbTable-TableDataSet Navigation technical Problem / Puzzle

JdbTable-TableDataSet Navigation technical Problem / Puzzle


2003-11-29 01:39:49 AM
jbuilder1
Hi all,
It will take you 10 minutes to read this email about this puzzling problem.
Maybe you know the solution off hand and you might help me. If you dont have
10 minutes to spare, thanks alot anyways for reading this far and sorry to
have bothered you.
I have a class, shown very simplified here... It uses a JdbTable and a
TableDataSet. I am implementing NavigationListener because every time there
is a navigation, i want to send the user back to row 0. So in method
Navigated(), unless i am already navigating backwards, i am raising the flag
and calling dataset.goToRow(0). While if this was already navigating
backwards, i simply lower the flag.
class MyClass implements NavigationListener
{
private JdbTable jdbTable;
private TableDataSet dataset;
private boolean navigatingBack = false;
public MyClass()
{
jdbTable.setDataSet(dataset);
dataset.addNavigationListener(this);
}
/**
* Method implementation of the navigation listener interface
* @param navigationEvent
*/
public void navigated(NavigationEvent navigationEvent)
{
System.out.println("------");
System.out.println("Navigated to " + this.dataset.getRow());
if (!navigatingBack)
{
//IF NOT NAVIGATING BACK
System.out.println("I will now send you back");
this.navigatingBack = true;
dataset.goToRow(0);
return;
}
else
{
//IF JUST NAVIGATED BACK
System.out.println("You were sent back here.");
this.navigatingBack = false;
}
}
}
So, when i run this class, and i navigate from one row to another (either by
using arrow keys, or by using a JdbNavToolBar, or by directly clicking on
the row i want to go) i can always see the following output:
--------
//pressed the down arrow key
Navigated to 1
I will now send you back
--------
Navigated to 0
You were sent back here.
--------
//Clicked with mouse on row 3714
Navigated to 3714
I will now send you back
--------
Navigated to 0
You were sent back here.
Ok, It looks like it works fine. And as far as the DataSet is concerned, it
does work fine. So what is my problem? It is the following. Whenever i
navigate using the arrow keys or the jdbNavToolBar, on screen the JdbTable
always highlights and selects back row 0, as desired. However, when i change
row using a mouse click, the JdbTable does not highlight and select back the
old row. Instead, the row that was clicked on remains selected and
highlighted (even if the dataset did actaully change the selected row as is
proved from the console output).
Anybody has Any Idea of what could be the source for this problem?
Regards,
Patrick
 
 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

i may be wrong about this but from my own experience with the jdbtable.
There seems to be some disconnection between keyboard and mouse
movements and in general the jdbtable seems a little poor at handling
cursor movements (you don't have a lot of control over this). They
aren't treated the same and definitely do not seem in sync with one
another. I can't give you an answer in regards to how to fix this, but
i can possibly give you a solution. Instead of using
dataset.gotorow(0)...you can try this with the jdbTable:
jdbTable.changeSelection(row, col, false, false);
where row and col are integers. Now i don't know if this will help and
i can't say that it will but it may give you a little insight. You may
also have to differentiate between the mouse click and the key press
event. Sorry i can't give you an answer but maybe the changeselection
will get you thinking in the right direction.
brandon
Patrick wrote:
Quote
Hi all,

It will take you 10 minutes to read this email about this puzzling problem.
Maybe you know the solution off hand and you might help me. If you dont have
10 minutes to spare, thanks alot anyways for reading this far and sorry to
have bothered you.

I have a class, shown very simplified here... It uses a JdbTable and a
TableDataSet. I am implementing NavigationListener because every time there
is a navigation, i want to send the user back to row 0. So in method
Navigated(), unless i am already navigating backwards, i am raising the flag
and calling dataset.goToRow(0). While if this was already navigating
backwards, i simply lower the flag.

class MyClass implements NavigationListener
{
private JdbTable jdbTable;
private TableDataSet dataset;
private boolean navigatingBack = false;

public MyClass()
{
jdbTable.setDataSet(dataset);
dataset.addNavigationListener(this);
}

/**
* Method implementation of the navigation listener interface
* @param navigationEvent
*/
public void navigated(NavigationEvent navigationEvent)
{
System.out.println("------");
System.out.println("Navigated to " + this.dataset.getRow());

if (!navigatingBack)
{
//IF NOT NAVIGATING BACK
System.out.println("I will now send you back");
this.navigatingBack = true;
dataset.goToRow(0);
return;
}
else
{
//IF JUST NAVIGATED BACK
System.out.println("You were sent back here.");
this.navigatingBack = false;
}
}
}

So, when i run this class, and i navigate from one row to another (either by
using arrow keys, or by using a JdbNavToolBar, or by directly clicking on
the row i want to go) i can always see the following output:

--------

//pressed the down arrow key

Navigated to 1

I will now send you back

--------

Navigated to 0

You were sent back here.

--------

//Clicked with mouse on row 3714

Navigated to 3714

I will now send you back

--------

Navigated to 0

You were sent back here.



Ok, It looks like it works fine. And as far as the DataSet is concerned, it
does work fine. So what is my problem? It is the following. Whenever i
navigate using the arrow keys or the jdbNavToolBar, on screen the JdbTable
always highlights and selects back row 0, as desired. However, when i change
row using a mouse click, the JdbTable does not highlight and select back the
old row. Instead, the row that was clicked on remains selected and
highlighted (even if the dataset did actaully change the selected row as is
proved from the console output).

Anybody has Any Idea of what could be the source for this problem?

Regards,

Patrick


 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

Yeah i tried using this method call as well... and again... it DOES WORK
from everywhere in the code.
Even from the Navigated() method itself. BUT it does not work properly
(highlighting the row i want) from the Navigated() method when it was called
due to a mouse click on a new row.
Internally within the DataSet, i navigate using dataset.goToRow(), which
works fine from everywhere. I think that this method (goToRow()) also calls
the JdbTable.ChangeSelection() automatically so that the JdbTable containing
the DataSet also reflects the new selection in the DataSet. All these
methods work properly from anywhere in the code. But when there is a change
of row using a mouse click, and the Navigated() method is therefore called,
the JdbTable.ChangeSelection() does not work entirely. The JdbTable actually
does Scroll to the row i want, but it does NOT highlight it.
:(
Thanks alot for your help
Regards
Patrick
"Brandon Fouts" < XXXX@XXXXX.COM >wrote in message
Quote
i may be wrong about this but from my own experience with the jdbtable.
There seems to be some disconnection between keyboard and mouse
movements and in general the jdbtable seems a little poor at handling
cursor movements (you don't have a lot of control over this). They
aren't treated the same and definitely do not seem in sync with one
another. I can't give you an answer in regards to how to fix this, but
i can possibly give you a solution. Instead of using
dataset.gotorow(0)...you can try this with the jdbTable:
jdbTable.changeSelection(row, col, false, false);

where row and col are integers. Now i don't know if this will help and
i can't say that it will but it may give you a little insight. You may
also have to differentiate between the mouse click and the key press
event. Sorry i can't give you an answer but maybe the changeselection
will get you thinking in the right direction.

brandon
Patrick wrote:

>Hi all,
>
>It will take you 10 minutes to read this email about this puzzling
problem.
>Maybe you know the solution off hand and you might help me. If you dont
have
>10 minutes to spare, thanks alot anyways for reading this far and sorry
to
>have bothered you.
>
>I have a class, shown very simplified here... It uses a JdbTable and a
>TableDataSet. I am implementing NavigationListener because every time
there
>is a navigation, i want to send the user back to row 0. So in method
>Navigated(), unless i am already navigating backwards, i am raising the
flag
>and calling dataset.goToRow(0). While if this was already navigating
>backwards, i simply lower the flag.
>
>class MyClass implements NavigationListener
>{
>private JdbTable jdbTable;
>private TableDataSet dataset;
>private boolean navigatingBack = false;
>
>public MyClass()
>{
>jdbTable.setDataSet(dataset);
>dataset.addNavigationListener(this);
>}
>
>/**
>* Method implementation of the navigation listener interface
>* @param navigationEvent
>*/
>public void navigated(NavigationEvent navigationEvent)
>{
>System.out.println("------");
>System.out.println("Navigated to " + this.dataset.getRow());
>
>if (!navigatingBack)
>{
>//IF NOT NAVIGATING BACK
>System.out.println("I will now send you back");
>this.navigatingBack = true;
>dataset.goToRow(0);
>return;
>}
>else
>{
>//IF JUST NAVIGATED BACK
>System.out.println("You were sent back here.");
>this.navigatingBack = false;
>}
>}
>}
>
>So, when i run this class, and i navigate from one row to another
(either by
>using arrow keys, or by using a JdbNavToolBar, or by directly clicking
on
>the row i want to go) i can always see the following output:
>
>--------
>
>//pressed the down arrow key
>
>Navigated to 1
>
>I will now send you back
>
>--------
>
>Navigated to 0
>
>You were sent back here.
>
>--------
>
>//Clicked with mouse on row 3714
>
>Navigated to 3714
>
>I will now send you back
>
>--------
>
>Navigated to 0
>
>You were sent back here.
>
>
>
>Ok, It looks like it works fine. And as far as the DataSet is concerned,
it
>does work fine. So what is my problem? It is the following. Whenever i
>navigate using the arrow keys or the jdbNavToolBar, on screen the
JdbTable
>always highlights and selects back row 0, as desired. However, when i
change
>row using a mouse click, the JdbTable does not highlight and select back
the
>old row. Instead, the row that was clicked on remains selected and
>highlighted (even if the dataset did actaully change the selected row as
is
>proved from the console output).
>
>Anybody has Any Idea of what could be the source for this problem?
>
>Regards,
>
>Patrick
>
>

 

{smallsort}

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

Patrick wrote:
Quote
Internally within the DataSet, i navigate using dataset.goToRow(), which
works fine from everywhere. I think that this method (goToRow()) also calls
the JdbTable.ChangeSelection() automatically so that the JdbTable containing
the DataSet also reflects the new selection in the DataSet. All these
methods work properly from anywhere in the code. But when there is a change
of row using a mouse click, and the Navigated() method is therefore called,
the JdbTable.ChangeSelection() does not work entirely. The JdbTable actually
does Scroll to the row i want, but it does NOT highlight it.
I'm wondering if the difference is that
with a mouse click, you may have entered
the editing mode. Have you tried stepping
through the "changeSelection()" method?
You may have to turn on debugging in the
appropriate classes/package, and compile
the dbSwing package with debugging symbols on.
There is a project in samples/dbSwing/dbswing
for doing just this. Read the "Project Notes"
which show in the editor pane when you open
the project. You'll have to make a separate
library and add it to your project, removing
the non-debuggable dbswing.jar library.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
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.
 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

Hi,
Thanks for your time Paul.
1) JdbTable.ChangeSelection() is inherited from JTable and is not overriden
in JdbTable. Therefore i would need to go through the source of JTable.
2) I just discovered that the problem also occurs when i use the UP arrow
key to navigate to the previous row. So now i know it works well when i
navigate with the JdbNavToolBar and when i navigate using the DOWN arrow
key. But it does not work well when i navigate using the mouse or using the
UP arrow key. It is getting weirder and weirder.
Any other help or suggestions anyone?
Regards
Patrick
"Paul Furbacher" < XXXX@XXXXX.COM >wrote in message
Quote
Patrick wrote:

>Internally within the DataSet, i navigate using dataset.goToRow(), which
>works fine from everywhere. I think that this method (goToRow()) also
calls
>the JdbTable.ChangeSelection() automatically so that the JdbTable
containing
>the DataSet also reflects the new selection in the DataSet. All these
>methods work properly from anywhere in the code. But when there is a
change
>of row using a mouse click, and the Navigated() method is therefore
called,
>the JdbTable.ChangeSelection() does not work entirely. The JdbTable
actually
>does Scroll to the row i want, but it does NOT highlight it.

I'm wondering if the difference is that
with a mouse click, you may have entered
the editing mode. Have you tried stepping
through the "changeSelection()" method?

You may have to turn on debugging in the
appropriate classes/package, and compile
the dbSwing package with debugging symbols on.
There is a project in samples/dbSwing/dbswing
for doing just this. Read the "Project Notes"
which show in the editor pane when you open
the project. You'll have to make a separate
library and add it to your project, removing
the non-debuggable dbswing.jar library.


--


Paul Furbacher (TeamB)

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

Is it in Joi Ellis's Faq-O-Matic?
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.

 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

Dear all,
Even A Further discovery. The bug also occurs when navigating using
SHIFT+DOWN.
So the code works well with navigation through JdbNavToolBar and through
DOWN arrow key...
But when row navigating using Mouse, UP key, or SHIFT+DOWN keys, the
mentioned bug occurs...
Does this give you any further clues on how to solve the problem?
Regards
Patrick
"Patrick" < XXXX@XXXXX.COM >wrote in message
Quote
Hi,

Thanks for your time Paul.

1) JdbTable.ChangeSelection() is inherited from JTable and is not
overriden
in JdbTable. Therefore i would need to go through the source of JTable.

2) I just discovered that the problem also occurs when i use the UP arrow
key to navigate to the previous row. So now i know it works well when i
navigate with the JdbNavToolBar and when i navigate using the DOWN arrow
key. But it does not work well when i navigate using the mouse or using
the
UP arrow key. It is getting weirder and weirder.

Any other help or suggestions anyone?

Regards
Patrick

"Paul Furbacher" < XXXX@XXXXX.COM >wrote in message
news:3fcc8b9b$ XXXX@XXXXX.COM ...
>Patrick wrote:
>
>>Internally within the DataSet, i navigate using dataset.goToRow(),
which
>>works fine from everywhere. I think that this method (goToRow()) also
calls
>>the JdbTable.ChangeSelection() automatically so that the JdbTable
containing
>>the DataSet also reflects the new selection in the DataSet. All these
>>methods work properly from anywhere in the code. But when there is a
change
>>of row using a mouse click, and the Navigated() method is therefore
called,
>>the JdbTable.ChangeSelection() does not work entirely. The JdbTable
actually
>>does Scroll to the row i want, but it does NOT highlight it.
>
>I'm wondering if the difference is that
>with a mouse click, you may have entered
>the editing mode. Have you tried stepping
>through the "changeSelection()" method?
>
>You may have to turn on debugging in the
>appropriate classes/package, and compile
>the dbSwing package with debugging symbols on.
>There is a project in samples/dbSwing/dbswing
>for doing just this. Read the "Project Notes"
>which show in the editor pane when you open
>the project. You'll have to make a separate
>library and add it to your project, removing
>the non-debuggable dbswing.jar library.
>
>
>--
>
>
>Paul Furbacher (TeamB)
>
>Save time, search the archives:
>www.borland.com/newsgroups/ngsearch.html
>
>Is it in Joi Ellis's Faq-O-Matic?
>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.
>


 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

I found out that i can implement EditListener in my class for my dataset.
This gives me loads of options including a method called updating() which is
called before a row posting. And which also gives me the chance to veto the
posting, and therefore veto also the navigation which triggered the posting.
class MyClass implements NavigationListener, EditListener
{
private JdbTable jdbTable;
private TableDataSet dataset;
private boolean navigatingBack = false;
public MyClass()
{
jdbTable.setDataSet(dataset);
dataset.addNavigationListener(this);
}
/**
* Method implementation of the navigation listener interface
* @param navigationEvent
*/
public void navigated(NavigationEvent navigationEvent)
{
System.out.println("------");
System.out.println("Navigated to " + this.dataset.getRow());
}
public void updating(DataSet arg0, ReadWriteRow arg1, ReadRow arg2) throws
Exception
{
try
{
//DO ANY VALIDATION YOU WANT HERE
if (5>0)
{
throw new Exception();
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,
"VALIDATION FAILED... PLEASE FIX ", "Error",
JOptionPane.ERROR_MESSAGE);
throw new VetoException("Sorry Validation Failed");
}
}
}
Also Some Clarifications you might find useful
// --------------
//
// - POSTING IS A DIFFERENT THING THAN SAVING
//
// - POSTING MEANS COMMITING THE CHANGES MADE FROM
// THE USER INTERFACE To THE DATASET
//
// - SAVING MEANS COMMITING THE DATASET TO
// THE BACKEND (DATABASE OR WHATEVER)
//
// - POSTING HAPPENS EITHER
// o MANUALLY WHEN THE USER CLICKS THE VERY-GOOD BUTTON AFTER
// BUTTON AFTER EDITING SOME FIELDS IN A ROW/
// OR
// o AUTOMATICALLY WHEN A ROW TO WHICH ONE OR MORE FIELDS
// WERE EDITED,IS BEING NAVIGATED AWAY FROM, BY THE USER
//
// - SAVING HAPPENS WHEN THE USER PRESSES THE "SAVE CHANGES"
// BUTTON IN THE JdbNavToolBar
Regards
Patrick
"Patrick" < XXXX@XXXXX.COM >wrote in message
Quote
Dear all,

Even A Further discovery. The bug also occurs when navigating using
SHIFT+DOWN.

So the code works well with navigation through JdbNavToolBar and through
DOWN arrow key...
But when row navigating using Mouse, UP key, or SHIFT+DOWN keys, the
mentioned bug occurs...

Does this give you any further clues on how to solve the problem?

Regards
Patrick


"Patrick" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Hi,
>
>Thanks for your time Paul.
>
>1) JdbTable.ChangeSelection() is inherited from JTable and is not
overriden
>in JdbTable. Therefore i would need to go through the source of JTable.
>
>2) I just discovered that the problem also occurs when i use the UP
arrow
>key to navigate to the previous row. So now i know it works well when i
>navigate with the JdbNavToolBar and when i navigate using the DOWN arrow
>key. But it does not work well when i navigate using the mouse or using
the
>UP arrow key. It is getting weirder and weirder.
>
>Any other help or suggestions anyone?
>
>Regards
>Patrick
>
>"Paul Furbacher" < XXXX@XXXXX.COM >wrote in message
>news:3fcc8b9b$ XXXX@XXXXX.COM ...
>>Patrick wrote:
>>
>>>Internally within the DataSet, i navigate using dataset.goToRow(),
which
>>>works fine from everywhere. I think that this method (goToRow())
also
>calls
>>>the JdbTable.ChangeSelection() automatically so that the JdbTable
>containing
>>>the DataSet also reflects the new selection in the DataSet. All
these
>>>methods work properly from anywhere in the code. But when there is a
>change
>>>of row using a mouse click, and the Navigated() method is therefore
>called,
>>>the JdbTable.ChangeSelection() does not work entirely. The JdbTable
>actually
>>>does Scroll to the row i want, but it does NOT highlight it.
>>
>>I'm wondering if the difference is that
>>with a mouse click, you may have entered
>>the editing mode. Have you tried stepping
>>through the "changeSelection()" method?
>>
>>You may have to turn on debugging in the
>>appropriate classes/package, and compile
>>the dbSwing package with debugging symbols on.
>>There is a project in samples/dbSwing/dbswing
>>for doing just this. Read the "Project Notes"
>>which show in the editor pane when you open
>>the project. You'll have to make a separate
>>library and add it to your project, removing
>>the non-debuggable dbswing.jar library.
>>
>>
>>--
>>
>>
>>Paul Furbacher (TeamB)
>>
>>Save time, search the archives:
>>www.borland.com/newsgroups/ngsearch.html
>>
>>Is it in Joi Ellis's Faq-O-Matic?
>>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.
>>
>
>


 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

Patrick wrote:
Quote
1) JdbTable.ChangeSelection() is inherited from JTable and is not overriden
in JdbTable. Therefore i would need to go through the source of JTable.
You can turn on debugging in things like
JTable. When you run your app, go to the
Run menu, slide down to the "Classes with
tracing disabled". You can hand tune the
classes you want to debug into.
Quote
2) I just discovered that the problem also occurs when i use the UP arrow key
to navigate to the previous row. So now i know it works well when i navigate
with the JdbNavToolBar and when i navigate using the DOWN arrow key. But it
does not work well when i navigate using the mouse or using the UP arrow key.
It is getting weirder and weirder.
Sure is. I don't have anything more
to add but that you may have to do
a lot of tracing to figure out if
events are being sent and received
by the appropriate methods.
It almost seems as though under the
circumstances you have noted, the
table's selection model is not being
updated. (That observation doesn't add
much if anything to the discussion.
Sorry.)
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
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.
 

Re:JdbTable-TableDataSet Navigation technical Problem / Puzzle

Yeah thanks... i know it would need loads of boring debugging... fortunately
i found another way out.. using EditListener... as described in my previous
post.
THANKS ALOT
patrick
"Paul Furbacher" < XXXX@XXXXX.COM >wrote in message
Quote
Patrick wrote:

>1) JdbTable.ChangeSelection() is inherited from JTable and is not
overriden
>in JdbTable. Therefore i would need to go through the source of JTable.

You can turn on debugging in things like
JTable. When you run your app, go to the
Run menu, slide down to the "Classes with
tracing disabled". You can hand tune the
classes you want to debug into.

>2) I just discovered that the problem also occurs when i use the UP
arrow key
>to navigate to the previous row. So now i know it works well when i
navigate
>with the JdbNavToolBar and when i navigate using the DOWN arrow key. But
it
>does not work well when i navigate using the mouse or using the UP arrow
key.
>It is getting weirder and weirder.

Sure is. I don't have anything more
to add but that you may have to do
a lot of tracing to figure out if
events are being sent and received
by the appropriate methods.

It almost seems as though under the
circumstances you have noted, the
table's selection model is not being
updated. (That observation doesn't add
much if anything to the discussion.
Sorry.)


--


Paul Furbacher (TeamB)

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

Is it in Joi Ellis's Faq-O-Matic?
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.