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

Handling dynamic source objects #30

Closed
usander opened this Issue Oct 9, 2013 · 8 comments

Comments

Projects
None yet
2 participants
@usander

usander commented Oct 9, 2013

I'm dealing with a bean which has a map property like

Map<String, String> userMap

Showing this map with FXForm2 using an adaptor and a factory is not a problem, but the user should be able to add or remove entries to or from the map such that I need to update the form after each operation. I can do this partial re-generation of the form by

  1. using a lot of code in the factory class or by
  2. re-generating the entire form, by which I would probably lose any input values that were not stored in the data model (because they were invalid, for instance).

Is there a recommended way for doing this? Or is this maybe a use case that FXForm2 does not want to address?

Cheers,
Uwe

@ghost ghost assigned amischler Oct 14, 2013

amischler added a commit that referenced this issue Oct 14, 2013

@amischler

This comment has been minimized.

Show comment
Hide comment
@amischler

amischler Oct 14, 2013

Member

I would suggest using a custom Control to display/edit the Map. You should avoid rebuilding the whole form in this case, sinceits not necessary and as you said it can have side effects such as losing invalid inputs.
To make it easier to implement, use a MapProperty rather than a Map, so that you won't need any adapters and you will be able to observe the content of the map.
See b4ce1a1 for an implementation example.

Member

amischler commented Oct 14, 2013

I would suggest using a custom Control to display/edit the Map. You should avoid rebuilding the whole form in this case, sinceits not necessary and as you said it can have side effects such as losing invalid inputs.
To make it easier to implement, use a MapProperty rather than a Map, so that you won't need any adapters and you will be able to observe the content of the map.
See b4ce1a1 for an implementation example.

@usander

This comment has been minimized.

Show comment
Hide comment
@usander

usander Oct 15, 2013

Thanks for your feedback, Antoine. Your solutions seems simpler than our current one.

usander commented Oct 15, 2013

Thanks for your feedback, Antoine. Your solutions seems simpler than our current one.

@usander usander closed this Oct 15, 2013

@usander

This comment has been minimized.

Show comment
Hide comment
@usander

usander Nov 5, 2013

I would like to reopen this issue because I would like to ask if it is possible to display the map entries in the same way regular properties are displayed, that is, take each key as a label and each value as the corresponding input text field, and put these two things right under the other property lines of the form.

In your solution proposed above, there's one label "userMap" and one complex input field that show the entries of the map. I would like to get rid of the "userMap" label and have the entries shown with exactly the same visual appearance as the properties above. The user should not see a difference between regular and custom properties. Is this possible?

Thanks,
Uwe

usander commented Nov 5, 2013

I would like to reopen this issue because I would like to ask if it is possible to display the map entries in the same way regular properties are displayed, that is, take each key as a label and each value as the corresponding input text field, and put these two things right under the other property lines of the form.

In your solution proposed above, there's one label "userMap" and one complex input field that show the entries of the map. I would like to get rid of the "userMap" label and have the entries shown with exactly the same visual appearance as the properties above. The user should not see a difference between regular and custom properties. Is this possible?

Thanks,
Uwe

@usander usander reopened this Nov 5, 2013

@amischler

This comment has been minimized.

Show comment
Hide comment
@amischler

amischler Nov 19, 2013

Member

I can see two approaches for your need:

  • The simple one (but not generic): Implement a custom skin to layout differently the control used for the map field (either a programmatic skin or an FXML skin)
  • The hard one (but generic): Modify FXForm to wrap all map entries into an Element, so that each map entry is treated by FXForm as a class field
Member

amischler commented Nov 19, 2013

I can see two approaches for your need:

  • The simple one (but not generic): Implement a custom skin to layout differently the control used for the map field (either a programmatic skin or an FXML skin)
  • The hard one (but generic): Modify FXForm to wrap all map entries into an Element, so that each map entry is treated by FXForm as a class field
@usander

This comment has been minimized.

Show comment
Hide comment
@usander

usander Nov 20, 2013

Thanks for your answer, Antoine. We may consider implementing the second option.

usander commented Nov 20, 2013

Thanks for your answer, Antoine. We may consider implementing the second option.

@usander usander closed this Nov 20, 2013

@amischler

This comment has been minimized.

Show comment
Hide comment
@amischler

amischler Dec 3, 2013

Member

The refactoring linked with Issue #57 makes it much easier to implement a dynamic behavior. You could tweak the DefaultElementProvider to add and remove Elements dynamically from the returned ListProperty for your MapProperty fields. The form will be automatically updated with the added/removed elements.

Member

amischler commented Dec 3, 2013

The refactoring linked with Issue #57 makes it much easier to implement a dynamic behavior. You could tweak the DefaultElementProvider to add and remove Elements dynamically from the returned ListProperty for your MapProperty fields. The form will be automatically updated with the added/removed elements.

@usander

This comment has been minimized.

Show comment
Hide comment
@usander

usander Dec 3, 2013

That is great news, thanks!

usander commented Dec 3, 2013

That is great news, thanks!

@amischler

This comment has been minimized.

Show comment
Hide comment
@amischler
Member

amischler commented Apr 24, 2015

#99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment