Skip to main content

extending JDNC markup questions

4 replies [Last post]
pberndt
Offline
Joined: 2004-12-15
Points: 0

Hello!

I am trying to extend JDNC markup by some elements without touching any of the JDNC code.
Is that possible?

Can JDNC Elements and extensions be used together, i.e. in the same rootPane?

Can the extensions have their own namespace?

I have subclassed Application and added my own Vocabulary (with it's own xml namespace)
to the ObjectRealizer as described in

http://wiki.java.net/bin/view/Javadesktop/JDNCxml

However I have no idea of how to put one of my own Elements in a JDNC rootPane.

When I try I get:
WARNING Element assimilator not found: "foo" into "rootPane"

Do I need to subclass rootPane and add new handlers?

I've tried using my own rootPane but that only makes things worse.

Also I am not sure what the .jdnc file should look like.

Has anybody successfully extended JDNC markup and could supply a working example of how to do it, or supply some more information to the wiki or at least give some hints?

Any help appreciated!

phil

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pberndt
Offline
Joined: 2004-12-15
Points: 0

> If you want to go beyond this, for example, to embed
> as a child element of an existing JDNC element,
> say , and expect the root pane instance to
> do something special with your instance of Foo, you
> do not have to modify JXRootPane, but you still need
> to register an element assimilator with
> RootPaneElement that knows how to process a child
> FooElement inside a parent RootPaneElement.

It would be nice if you didn't have to explicitly register each content element with each container element.

How about a mechanism where in a each element you provide a method to assimilate elements which realize objects that implement a certain interface.
In such a way that i.e. if RootPaneElement has a method
assimilate(java.awt.Component c),
RootPaneElement's handlerMap will automatically be filled with all the handlers needed to assimilate SplitPaneElement, TableElement, TreeTableElement and so on.
This could be done when the object realizer is set up with the vocabulary by looking (with reflection) for special methods in all Elements and adding the respective handlerMap entries for all child elements that realize elements that implement that interface.

As a consequence new and old container elements would work with new and old content component elements, new/old views would work with new/old datamodels without anyone of them knowing any other personally.

--Phil

rameshgupta
Offline
Joined: 2004-06-04
Points: 0

> I am trying to extend JDNC markup by some elements
> without touching any of the JDNC code.
> Is that possible?
>
That depends on what you want to accomplish.

If all you want to do is use your own tag to realize an instance of your custom bean class Foo, then all you have to do is implement FooElement (which extends ElementProxy to represent in the DOM at run time), and implement attribute appliers for any attributes of . If also supports child elements, you have to implement the element classes and attribute appliers for the child element types as well. In addition, you have to provide an element assimilator for assimilating each child element type into foo.

Thus, if you have a document that contains:



then, realizing this will yield an instance of Foo.

If you want to go beyond this, for example, to embed as a child element of an existing JDNC element, say , and expect the root pane instance to do something special with your instance of Foo, you do not have to modify JXRootPane, but you still need to register an element assimilator with RootPaneElement that knows how to process a child FooElement inside a parent RootPaneElement.

> Can JDNC Elements and extensions be used together,
> i.e. in the same rootPane?
>
Yes.

> Can the extensions have their own namespace?
>
Yes.

> I have subclassed Application and added my own
> Vocabulary (with it's own xml namespace)
> to the ObjectRealizer as described in
>
> http://wiki.java.net/bin/view/Javadesktop/JDNCxml
>
> However I have no idea of how to put one of my own
> Elements in a JDNC rootPane.
>
> When I try I get:
> WARNING Element assimilator not found: "foo" into
> "rootPane"
>
> Do I need to subclass rootPane and add new handlers?
>
No. Please see above.

> I've tried using my own rootPane but that only makes
> things worse.
>
> Also I am not sure what the .jdnc file should look
> like.
>
If you show me what you have, and tell me what you want to accomplish, I might be able to help.

> Has anybody successfully extended JDNC markup and
> could supply a working example of how to do it, or
> supply some more information to the wiki or at least
> give some hints?
>
> Any help appreciated!
>
> phil

Let me know if you need more help.

Ramesh Gupta

rameshgupta
Offline
Joined: 2004-06-04
Points: 0

> > I am trying to extend JDNC markup by some elements
> > without touching any of the JDNC code.
> > Is that possible?
> >
> > Do I need to subclass rootPane and add new
> > handlers?
> >
> No. Please see above.
>

I just checked the API, and sadly, there is no public method to register your own element handler to an existing element implementation class at present :-( This needs to be fixed.

Sorry for any confusion that my earlier message might have caused.

Ramesh Gupta

pberndt
Offline
Joined: 2004-12-15
Points: 0

Thanks!

Phil