Problems with BeanPathAdapter

213 views
Skip to first unread message

chaosk...@gmail.com

unread,
Apr 10, 2013, 1:07:27 PM4/10/13
to jfxtra...@googlegroups.com
Hello,

besides my posted request to add support for enums https://github.com/JFXtras/jfxtras-labs/issues/25 I've found several other problems when using BeanPathAdapter:
  • Binding to custom types with non trivial constructors (for example java.io.File) doesn't work. The adapter tries to create a new instance of this class and fails with an exception
  • A very trivial binding seems to be ignored / not working:
            beanPathAdapter.bindBidirectional("template", templates.valueProperty(), Template.class);
            beanPathAdapter.bindBidirectional("template.title", uploadTitle.textProperty()); 
    Pojo:
    public class UploadViewVO {
        private Template    template; 
    ......
    }
    templates is a combobox containing "Template"s. However changes aren't displayed once the user selection is changed. 

Is there any way to get the second problem working?

Possible solutions for the first point:

  • Add a possibility to set a default value for custom types
    OR
    Use as default value "null" instead of newInstance(). This will automatically add support for enums and custom data types with non trivial constructors.

Regards,

Dennis

ugate...@gmail.com

unread,
May 11, 2013, 8:03:15 PM5/11/13
to jfxtra...@googlegroups.com
Hi Dennis,

You bring up some interesting points. Adding the ability to set custom types seems like it would solve most of the problems you describe. You have any design solutions in mind? Maybe some kind of factory pattern? Setting the default value to null instead of newInstance() would require every traversal path used for binding to be instantiated prior to calling any binding operations. Failure to do so would result in null pointer exceptions. Can you provide me with a skeletal app representing the issue you're having with the Templates?

Dennis Fischer

unread,
May 25, 2013, 7:51:10 AM5/25/13
to jfxtra...@googlegroups.com, ugate...@gmail.com
Hello,
I hadn't had the time to responde until now. I currently can't imagine how a generic factory-like pattern will look like and what it will be able to solve.

First - let's assume we dont want so support custom types, but enums.
The easiest implementation would be code block 3 of my initial request. This will ensure that enums are working without breaking anything.

Next - if we want to have custom types - I'd let it "newInstance()". This should be okay.
Just the Java Type Enum was missing.

A "working" example is currently very hard to produce. My timetable is overcrowded, but I'll take a look at what I can send you :D

Reply all
Reply to author
Forward
0 new messages