Closed dmicol closed 5 years ago
Which buttons? For the ones in the main layout, you can set the captions by getting the button. For example:
crud.getFindAllButton().setCaption("Update the list");
For the ones in the forms, you can use the setButtonCaption
and setCancelButtonCaption
methods of the AbstractAutoGeneratedCrudFormFactory
class. For example:
formFactory.setButtonCaption(CrudOperation.ADD, "Add new user");
Error handling can be custumized with formFactory.setErrorListener()
and formFactory.setValidationErrorMessage()
.
Hi
Yes, for the buttons of the form you're right. Can you explain me why the CrudFormFactory interface there are the setFieldCaptions methods but not the setButtonCaption?
The buttons of the crud aren't reachable througt Crud interface, they are only available on the GridCrud implementation. Also the buttons and the field in EditableGridCrud (or some new Crud implementation) needs to be translated.
I think that could be very useful if the setFieldCaption and setButtonCaption for form and crud are place in the main interface or in the abstract implementation. A possible use of this is the automatic generation of a whole application by analyze the jpa metadata to build a crud for each entity. The captions of the fields could be automatically fetched by some factory from standard Resources or database.
There are other messages that not support i18n, for example: GridCrud.rowCountCaption, the buttons and label in EditableGridCrud.deleteButtonClicked, .... These messages aren't specific of GridCrud or EditableGridCrud, but are common to every crud/form. In every implemeof ntation crud/form I need to ask for delete confirm.
bye
Can you explain me why the CrudFormFactory interface there are the setFieldCaptions methods but not the setButtonCaption?
Because CrudFormFactory
doesn't know about the kind of actions that a specific implementation can offer. For example, some implementation might not need a cancel button at all, or even a save button (for immediate saving). It cannot assume all implementations will have these methods. Button captions are an implementation detail.
Field captions, on the other hand, are common to all implementations because all forms by definition have input fields. But I'm open to continuing this discussion, feel free to challenge my point of view.
The buttons of the crud aren't reachable througt Crud interface, they are only available on the GridCrud implementation.
Same as before, a Crud
doesn't know about the kind of buttons an implementation will have. There may be implementations where the actions are invoked form something different than a button (like a browser event). I want to keep the interfaces as simple as possible while still offering a framework for developing CRUD-like views.
Also the buttons and the field in EditableGridCrud (or some new Crud implementation) needs to be translated.
EditableGridCrud
is under development and will include these methods at some point.
Yes, can be useful to build form without button.
What about a new interface CrudButtonFormFactory, that extends CrudFormFactory, to add better support to standard buttons caption (add, update, cancel). The implementation actually present can inplement this new interface. Similarly can be done with the buttons on crud (add, refresh, update delete).
Usually in B2B applications there are hundreds of crud UI all with save button, .... An explicit interface that support the setter methods for these buttons can be very useful.
Good point. I think there are currently some others flaws in the design. Let me have a look at it and then I'll post my findings here before implementing.
How I can change DefaultCrudFormFactory caption Update Add etc...
How I can change DefaultCrudFormFactory caption Update Add etc...
With the setButtonCaption(CrudOperation, String)
method.
@alejandro-du Not button caption Form title!!!
In that case, use the WindowBasedCrudLayout::setWindowCaption(CrudOperation, String)
method.
Thanks!
But how i can change it in real time?
WindowBasedCrudLayout windowBasedCrudLayout = new WindowBasedCrudLayout();
windowBasedCrudLayout.setWindowCaption(CrudOperation.UPDATE, "111");
GridCrud<T> gridCrud = new GridCrud<>(gridType, windowBasedCrudLayout);
Something like
getGridCrud().getCrudLayout().setWindowCaption(CrudOperation.UPDATE, "111");
Just like you did with the reference of type WindowBasedCrudLayout
. Forms in other implementations of CrudLayout
doesn't need a caption, so you need that specific reference or a cast.
What about this hint?
GridCrud.setSavedMessage(String)
. See https://github.com/alejandro-du/crudui/blob/master/src/test/java/org/vaadin/crudui/app/TestUI.java to learn more about the usage of the component.
Please, let's use the forum for questions instead of using issues which are intended to be identified bugs or feature requests.
Closing this for now. If there's any text in the UI that cannot be changed via API, please open a new issue.
The buttons caption need to support I18N, and also error messages. I can help on this.