pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calathus <calat...@gmail.com>
Subject Re: [pivot] are there any tools to convert bxml to Java?
Date Tue, 04 Jan 2011 19:39:13 GMT
On Tue, Jan 4, 2011 at 11:13 AM, Greg Brown <gk_brown@verizon.net> wrote:

> > But using setBeanType() may not be so good idea.
>
> Did you see my earlier suggestion to use setColumns() rather than
> setBeanType()?
>
Yes, Initially I thought setBeanType is better than setColumns for the
uniformity for generic class, but afterthought, setBeanType seems not so
good idea also.


>
> > Since these class info is used to initialize the internal attributes and
> elements of TableView instance, if this class info was set after the generic
> class instance is created, we need to call some initialization method at the
> timing.
>
> Can you elaborate on your concern here?
>

My concern is rather purity of implementation. If we don't call
setBeanType(cls), the created object don't have any specific GUI info since
it has no info to create it.
So the initialization must be taken place at the setter setBeanType(cls),
for instance it will be :

void setBeanType(Class<?> cls) {
    this.cls = cls;
    initialize();
}

void initialize() {
    for (final Field field: cls.getFields()) {
             final String fname = field.getName();
             getColumns().add(new TableView.Column() {{
             setName(fname);
                    setWidth(3, true);
                    ....
}

If setter is invoked twice, i will initialize twice (although we can use
some flag to avoid this, but I think it is ugly)

So conceptually, it is better to pass class object at the time of instance
creation.


>
> > I think BXML may support passing bean class object by extending the BXML
> syntax also(if that is required).
>
> Not a bad idea - we could add a String to Class<?> conversion in the
> coerce() method of BeanAdapter.
>
>
>
>


-- 
Cheers,
calathus

Mime
View raw message