Skip to main content

Realizing data only - plus a bit more...

3 replies [Last post]
Anonymous

What I want to do:

- realize a tabularDataModel
- realize a columnModel

I can do so with two markup files. Is there a way to do it in one? Some
imaginary

...

...

The reason is that I want to read only data-related and shareable
visual-related items from the markup and use them in custom components.
A brute force is to markup a table, realize it, get the table- and
columnModel and then throw the comps away... a bit wasteful :-)

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.
rameshgupta
Offline
Joined: 2004-06-04

>
> What I want to do:
>
> - realize a tabularDataModel
> - realize a columnModel
>
> I can do so with two markup files. Is there a way to
> do it in one? Some
> imaginary
>
>
>
> ...
>

>
> ...
>

>

>
>
> The reason is that I want to read only data-related
> and shareable
> visual-related items from the markup and use them in
> custom components.
> A brute force is to markup a table, realize it, get
> the table- and
> columnModel and then throw the comps away... a bit
> wasteful :-)
>
> Greetings
> Jeanette

In the early access release, column models are not shareable -- but *you* already know that :-) As such, part of your question is moot. Now that we have agreed to make column models shareable between tables, we will have to make small changes in our tag library to support that in XML.

In general, elements that *are* shareable may be put inside a element, as follows (namespaces not shown):




...

...

Then, assuming that the URL of this XML document is "foo/bar/definitions.xml, you could get a handle to the tabularData object by calling:

ObjectRealizer or = Application.getObjectRealizer();
Object dataModel = or.getObject("foo/bar/definitions.xml#myData");
Object font = or.getObject("foo/bar/definitions.xml#myFont");

and so on.

Of course, you will need to cast dataModel and font to the appropriate type. If you are sure that your XML is valid, just cast the objects inside a try/catch block. Otherwise, use instanceof checks before casting.

Ramesh

Kleopatra

jdnc-interest@javadesktop.org wrote:
>
> In the early access release, column models are not shareable -- but *you* already know that :-) As such, part of your question is moot. Now that we have agreed to make column models shareable between tables, we will have to make small changes in our tag library to support that in XML.

yeah - but I had (quite naively) expected that sharing or not would not
have any impact on the tags as such. But looking at the sources there
are some (I discovered 2) unguarded getParent().getParent() in the
TableColumnXX markup. For now, I can simply take them out without much
impact :-)

>
>
>
>
> ...
>

>
>
>
>

> ...
>
>
>
> Then, assuming that the URL of this XML document is "foo/bar/definitions.xml, you could get a handle to the tabularData object by calling:
>
> ObjectRealizer or = Application.getObjectRealizer();
> Object dataModel = or.getObject("foo/bar/definitions.xml#myData");
> Object font = or.getObject("foo/bar/definitions.xml#myFont");
>
> and so on.

thanks, that's exactly what I have been looking for... unfortunately I
cannot make it work. Taking f.i. the masterDetail.jdnc, deleting the
section and loading with

dataModel = or.getObject("jdnc/demo/masterDetail.jdnc#bugdata")

returns null without throwing any exceptions. Any ideas why it's not
working?

Greetings
Jeanette

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

rameshgupta
Offline
Joined: 2004-06-04

> > In the early access release, column models are not
> > shareable -- but *you* already know that :-) As such,
> > part of your question is moot. Now that we have
> > agreed to make column models shareable between
> > tables, we will have to make small changes in our tag
> > library to support that in XML.
>
> yeah - but I had (quite naively) expected that sharing or not
> would not have any impact on the tags as such.

Actually, sharing is tangentially related to this issue, because it enabled us to make some simplifying assumptions (hence the unguarded getParentNode().getParentNode()).

Because table columns and column models were not supposed to be sharable, the JDNC markup language only allows column elements inside columns elements, which, in turn, are allowed only inside table elements. To really fix this, we also have to make changes to the language grammar so that column and columns may appear inside defs elements as well.

This, then, opens up a can of worms, mostly related to column binding by name. See TableColumnAttributes.getModelIndex for the gory details :-). This is where we backtrack from column to the *nearest* table ancestor, from where we jump to the data model so that we can determine the *model* index for the column from its name in the *view* column model. Even though there are no more backpointers from TableColumnExt to JXTable, there are backpointers from TableColumnElement to TableColumnsElement to TableElement... Sheesh!!!

If column and columns are allowed inside defs, all of this code will be impacted. As you can see, the impact of TableColumnAttributes.getModelIndex() extends to filters and highlighters as well.

See, what you've done by getting us to concede that column sharing is a good thing :-)

>
> >
> >
> >
> >
> > ...
> >

> >
> >
> >
> >

> > ...
> >
> >
> >
> > Then, assuming that the URL of this XML document is
> "foo/bar/definitions.xml, you could get a handle to
> the tabularData object by calling:
> >
> > ObjectRealizer or =
> Application.getObjectRealizer();
> > Object dataModel =
> or.getObject("foo/bar/definitions.xml#myData");
> > Object font =
> or.getObject("foo/bar/definitions.xml#myFont");
> >
> > and so on.
>
> thanks, that's exactly what I have been looking
> for... unfortunately I
> cannot make it work. Taking f.i. the
> masterDetail.jdnc, deleting the
> section and loading with
>
> dataModel =
> or.getObject("jdnc/demo/masterDetail.jdnc#bugdata")
>
> returns null without throwing any exceptions. Any
> ideas why it's not
> working?
>
> Greetings
> Jeanette

That should've worked. At the very least, there is a bug in the error reporting system. Are you sure that the data file (data/bugdata.tsv) exists in the right location relative to the JDNC document? If this still doesn't work then that sounds like another bug. Could you please file the reports?

Thanks.

Ramesh