pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Brown (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (PIVOT-542) enable the serializer to initialize components written in java code
Date Wed, 23 Jun 2010 17:05:51 GMT

     [ https://issues.apache.org/jira/browse/PIVOT-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Greg Brown resolved PIVOT-542.
------------------------------

    Resolution: Won't Fix

OK, thanks for the example. I hate to say it, but even after seeing how it might be used in
practice, I'm still not a fan of the approach. As I mentioned in another thread, the recommended
way to create a custom component is to also create a custom skin that goes with it. So, I'd
expect to see an EditorSkin class that uses BXMLSerializer internally to load and bind() to
its content. Alternatively, you could have your Editor class implement Bindable and use <bxml:include>
to add it to the host component (Bindable is effectively the equivalent of "code-behind" in
Pivot).

If you don't want to create a custom skin and don't want to use an include, you could still
use BXMLSerializer in the Editor constructor to load the left and right panes and set them
via setLeft() and setRight(). After loading each pane, you could call bind() on the editor
instance (this) to attach any values declared in the includes to the Editor instance.

While what you suggest makes sense for frameworks that compile XML to classes (e.g. MXML,
XAML), it just isn't consistent with the serializer concept. Serializers take an input stream
and return an object. The object that creates the serializer isn't meant to also be the object
that is instantiated by the serializer. That's just a little too convoluted.

Thanks for the submission, though.


> enable the serializer to initialize components written in java code
> -------------------------------------------------------------------
>
>                 Key: PIVOT-542
>                 URL: https://issues.apache.org/jira/browse/PIVOT-542
>             Project: Pivot
>          Issue Type: Improvement
>            Reporter: Appddevvv
>         Attachments: initialize-examples.zip, WTKXSerializer-with-initialize.patch
>
>
> The current serializer performs two funtions: creating objects and initializing them.
The typical use case is to create your component (say java code) then call the serializer
to create the content. Then within your class, attach the content and initialize your object
in various application specific ways. However, since your object is typically a java object
and often a Component subclass, for those writing new components as composites of others,
you have to manually write some (not all) initialization code that could also be performed
in the BXML file. 
> To initialize your object using bxml content, you can use annotations etc. However, if
the bxml file also defines user data or other elements, you also have to manually bring that
in from the bxml and do some wiring. In addition, it is currently impossible to initialize
some pivot objects that you subclass from, say the splitpane, with content from bxml without
having to create an intermediate container or use two bxml files for the left and right child.
For example, if you subclass from SplitPane, an underlying bxml file that holds your content
must have another container in order to define your left and right children in or you have
to use two separate bxml files per child--this may or may not be a good thing and complicates
the implementation.
> To support the use case of creating subclasses of Components (and pivot likes to use
OO inheritance) and allowing the initialization of that component to be matched by a bxml
file, the serializer needs to be able to "apply" itself to the component as if the bxml file
and the subclassed component were a reflection of the other. Bindable was designed to help
with this, however, the bxml file is still considered at level below (the content) of the
Component you are writing.
> The benefits are:
> a) A cleaner code style that has implied semantics--i.e. this bxml file is the mirror
image of your subclassed component at the same logical tree level.
> b) More consistent coding conventions for novice programmers.
> The capability to do this can be implemented in different ways including the current
approaches of course. The small patch allows a new style of Component creation blending code
and bxml in a more seamless way. Its no longer something you instantiate to "get" content,
it is the content. It helps Component writers who want to simply subclass another component.
It looks like a trivial change but it is a different perspective on initialization that has
natural semantics for programmers. It also reduces complexity for creating subclasses of Components
that have properties representing the tree e.g. SplitPane.
> This is similar in spirit to "code-behind" in other frameworks.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message