Skip to main content

Problem with DataModel recordIndex

5 replies [Last post]
Anonymous

Currently I'm playing around a bit with a simple master/detail scenario
in plain swingx code. Simply copying the code from the appropriate
realizer elements works fine: The RowSelector propagates selection
changes to dataModel recordIndex.

The problem is the other direction: changes in recordIndex should
propagate back to the table selection. I would expect that the
recordIndex were a bound property of dataModel, then I (or the
RowSelector :-) could listen and update the selectionModel accordingly.
As is, I don't see any way to be notified of recordIndex changes.

yeah, Ramesh, I have a use case for you: navigating in the details
form usually is done via some next/prev buttons in the scope of the
form. The form should be ignorant of the view representing the master,
it only knows about a dataModel, so any actions defined in the form
should work on this model only.

Any ideas?

Greetings
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Patrick Wright

> Kleopatra wrote:
>
>> The problem is the other direction: changes in recordIndex should
>> propagate back to the table selection. I would expect that the
>> recordIndex were a bound property of dataModel, then I (or the
>> RowSelector :-) could listen and update the selectionModel accordingly.
>> As is, I don't see any way to be notified of recordIndex changes.
>
> You are correct.
> We definitely need events when the recordIndex (aka 'cursor' in
> database speak) changes in the DataModel.

Suggest we also need a way to stop the selection from changing at all.
Consider having a list and a detail form linked together--the list has the
keys for the details shown for editing in the detail form. If the user
tries to change rows in the list, I may want to save, or validate or
otherwise handle changes to that row before leaving it. And if the
validation/save, etc. fails, I may want to stay on that row.

More generally--what I recall from when I did client/server work
exclusively--it can be useful to think of row events as occuring on two
different axes(?), one relating the the UI and one relating to data
processing. The trick is to find a model where the events are triggered in
a way that is both natural for a user of the UI, and where the developer
can achieve enough visibility and control into the events to handle
queries and updates.

I realize this may not be trappable depending on how the events are
processed for lists/selection, etc. Just would be good to have.

Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Patrick Wright wrote:
>
> Suggest we also need a way to stop the selection from changing at all.
> Consider having a list and a detail form linked together--the list has the
> keys for the details shown for editing in the detail form. If the user
> tries to change rows in the list, I may want to save, or validate or
> otherwise handle changes to that row before leaving it. And if the
> validation/save, etc. fails, I may want to stay on that row.

[snip]

> I realize this may not be trappable depending on how the events are
> processed for lists/selection, etc. Just would be good to have.
>

Good points. The way I solve such requirements is to use a custom
VetoableSelectionModel which only change the selection if none if its
listeners do object. That can be easily adapted to any
validators/transaction handlers.

Greetings
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Patrick Wright

> [snip]
>
>> I realize this may not be trappable depending on how the events are
>> processed for lists/selection, etc. Just would be good to have.
>>
>
> Good points. The way I solve such requirements is to use a custom
> VetoableSelectionModel which only change the selection if none if its
> listeners do object. That can be easily adapted to any
> validators/transaction handlers.

That seems like a clean way to approach it. However, I wonder if there
shouldn't be some automatic routing to methods like preZZZ that could hide
the details of using a VetoableSelectionModel. It's partly a question of
which abstractions you want to work with for what programming task.
Perhaps the concept of 'linked models' includes a concept of 'synchronize
movements (on approval)' which the API should expose.

Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Amy Fowler

Kleopatra wrote:

> The problem is the other direction: changes in recordIndex should
> propagate back to the table selection. I would expect that the
> recordIndex were a bound property of dataModel, then I (or the
> RowSelector :-) could listen and update the selectionModel accordingly.
> As is, I don't see any way to be notified of recordIndex changes.

You are correct.
We definitely need events when the recordIndex (aka 'cursor' in
database speak) changes in the DataModel.

RowSet supports a single listener for both cursor changes AND
rowset data modifications. I'm inclined to detangle the two
types of events for better efficiencies. I like your suggestion
of just implemented it as a bound property change event.

Aim

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Amy Fowler wrote:

> We definitely need events when the recordIndex (aka 'cursor' in
> database speak) changes in the DataModel.
>
> RowSet supports a single listener for both cursor changes AND
> rowset data modifications. I'm inclined to detangle the two
> types of events for better efficiencies. I like your suggestion
> of just implemented it as a bound property change event.
>

I just discovered that I would like notification on cahnges in
recordCount as well - which will bring us very near to JGoodies
SelectionInList (without actually exposing the "list" part of it)

Greetings
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net