Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending the FormFactory annotation #114

Closed
rodsnjr opened this issue Oct 30, 2015 · 5 comments
Closed

Extending the FormFactory annotation #114

rodsnjr opened this issue Oct 30, 2015 · 5 comments
Assignees

Comments

@rodsnjr
Copy link

rodsnjr commented Oct 30, 2015

Hello there, first of all. The project is a lifesaver, and amazing.

I would very much like to contribute with it, we're currently implementing some custom form components using the controlsfx Controls. But our components need a little more information.

Is there anyway for us to implement, or extend the way of using the FormFactory annotation based for some fields, where we can use some extra parameters to it?

Those would go to the FieldFactories, so they can build the controls properly.

I was looking for a way to do it, but I felt quite lost with some part of the code, what classes should
I extend for implementing this feature?

Thanks for the support, and for helping the JavaFX community!

@amischler amischler self-assigned this Nov 2, 2015
@amischler
Copy link
Member

Hi Rodney,

Extending an annotation is not possible in Java, so another approach would consist of using another annotation to provide the additional data you need on the field.

Then, you can read your custom annotation in the init method of your FXFormNode. In the init method you have access to the Element which encapsulates the field on which the control is being used. There, you can call #getAnnotation on the element to retrieve your custom annotation if defined on this field.

I have updated the CustomFactoryForm sample with an example demonstrating how to do this (see TextFieldWithPromptTextFactory), tell me if this fits your needs.

Feel free to submit a pull request if you want to contribute to FXForm and to share some custom form components !

amischler added a commit that referenced this issue Nov 2, 2015
@rodsnjr
Copy link
Author

rodsnjr commented Nov 11, 2015

Hello Amischler,
I think that would do! Kind of exactly what I need!
I will take a look on that, and certainly will contribute with the pull requests!
Thanks a lot!

@rodsnjr
Copy link
Author

rodsnjr commented Nov 12, 2015

Hello Again.

I'm receiving this error with simpleObjectProperties

ADVERTÊNCIA: No adapter between types class javafx.beans.property.adapter.JavaBeanObjectProperty and class javafx.beans.property.SimpleObjectProperty was found (to adapt com.dooapp.fxform.model.impl.java.JavaBeanObjectPropertyElement@261bff6e and FXFormNodeWrapper{node=PopOverField[id=testeModel-form-editor, styleClass=text-input text-field custom-text-field form-editor], property=ObjectProperty [value: João]})
Make sure to register the required adapter in DefaultAdapterProvider either in the global or in the user map. See FXForm#setAdapterProvider

What should I do?

Thanks for the help!

@amischler
Copy link
Member

Hi,

FXForm uses adapters to convert values between the property exposed by the view and the model property. In your case, the view property is an ObjectProperty and the model property seems to be an Object wrapped automatically by FXForm into a JavaBeanObjectProperty.

For your case there is no explicit adapter registered, so FXForm is using the default adapter which is a one to one adapter, performing non conversion. This is just a warning and it should work in your case.

However, I would recommend you to use JavaFX properties in your model instead of simple Objects, because the JavaBeanObjectProperty can not listen to the field and thus changes in your model won't be reflected into the view.

@amischler
Copy link
Member

I'm closing this issue, feel free to open other issues if you encounter other difficulties implementing your factories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants