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

I18N of caption and messages #23

Closed
dmicol opened this issue Oct 20, 2017 · 17 comments
Closed

I18N of caption and messages #23

dmicol opened this issue Oct 20, 2017 · 17 comments

Comments

@dmicol
Copy link
Contributor

dmicol commented Oct 20, 2017

The buttons caption need to support I18N, and also error messages.
I can help on this.

@alejandro-du
Copy link
Owner

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().

@dmicol
Copy link
Contributor Author

dmicol commented Oct 21, 2017

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

@alejandro-du
Copy link
Owner

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.

@dmicol
Copy link
Contributor Author

dmicol commented Nov 1, 2017

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.

@alejandro-du
Copy link
Owner

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.

@alabotski
Copy link

How I can change DefaultCrudFormFactory caption
Update Add etc...

@alejandro-du
Copy link
Owner

How I can change DefaultCrudFormFactory caption
Update Add etc...

With the setButtonCaption(CrudOperation, String) method.

@alabotski
Copy link

@alejandro-du Not button caption
Form title!!!

@alabotski
Copy link

image

@alejandro-du
Copy link
Owner

alejandro-du commented Oct 29, 2018

In that case, use the WindowBasedCrudLayout::setWindowCaption(CrudOperation, String) method.

@alabotski
Copy link

Thanks!

@alabotski
Copy link

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");

@alejandro-du
Copy link
Owner

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.

@alabotski
Copy link

image
What about this hint?

@alejandro-du
Copy link
Owner

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.

@alejandro-du
Copy link
Owner

Please, let's use the forum for questions instead of using issues which are intended to be identified bugs or feature requests.

@alejandro-du
Copy link
Owner

Closing this for now. If there's any text in the UI that cannot be changed via API, please open a new issue.

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

3 participants