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 20:08:09 GMT
On Tue, Jan 4, 2011 at 11:45 AM, Greg Brown <gk_brown@verizon.net> wrote:

> > 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.
>
>
> It will still have a GUI - by default, TableView contains an empty column
> sequence, which is perfectly valid. Calling setColumns(Class<?>) would
> simply create a new (non-empty) sequence.
>
> 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);
>                     ....
> }
>
>
> Why not just put the initialize() code in the setter? Nothing else needs to
> call it.
>
>
> If setter is invoked twice, i will initialize twice (although we can use
> some flag to avoid this, but I think it is ugly)
>
>
> Why would the setter be invoked twice?
>
> So conceptually, it is better to pass class object at the time of instance
> creation.
>
>
> That isn't supported in BXML. Anything instantiated in BXML needs a default
> no-arg constructor - all properties are specified via setters.
>

I prefer to use final for cls property in the generic class so that it won't
be changed, also this is not ordinary property of Java beans, conceptually
it is better to hide from user.
But if you cannot change BXML to support calling constructor with parameters
or just want to use current BXML, setBeanType would work. As I said this is
some purity issue of implementation.

Also if we want to use final properties which is assigned during
constructor, setBeanType approach will have restriction.



>
> G
>
>
>


-- 
Cheers,
calathus

Mime
View raw message