[BLOSSOM-207] TabFactory annotation shouldn't set tab label Created: 19/May/15  Updated: 29/Jun/18  Resolved: 13/Nov/15

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: 3.0.6
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Samuel Zihlmann Assignee: Tobias Mattsson
Resolution: Duplicate Votes: 0
Labels: i18n
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
duplicates BLOSSOM-228 Compatibility with new I18n API Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Visible to:
Peter Mohn

 Description   

The label of a dialog tab shouldn't be set during creation. Because if the label is missing you can set it with standard i18n property files. This is now not possible with blossom TabFactory annotation.

DefaultDialogCreator:135

for (Method tabFactory : classMetaData.getTabFactories()) {
	TabFactory annotation = tabFactory.getAnnotation(TabFactory.class);
	TabBuilder tabBuilder = new TabBuilder(annotation.value()).label(annotation.value());
	dialogBuilder.form().definition().getTabs().add(tabPosition++, tabBuilder.definition());

	ParameterResolver parameters = getTabFactoryParameters(metaData, context, tabBuilder);
	MethodInvocationUtils.invoke(tabFactory, metaData.getFactoryObject(), parameters);
}


 Comments   
Comment by Samuel Zihlmann [ 19/May/15 ]

Ok I have a workaround:

    @TabFactory("content")
    public void contentTab(final UiConfig cfg, final TabBuilder tab) {
        tab.label(null); // reset label to set with properties
        tab.fields(
                cfg.fields.text("copyright")
                , cfg.fields.text("adress")
                );
    }
Comment by Samuel Zihlmann [ 20/May/15 ]

Another problem is with @TabOrder annotation.

It's not possible to use magnolia i18n features and sorting tabs with @TabOrder, because this annotation take labels as argument.

Comment by Tobias Mattsson [ 22/May/15 ]

I18n labels can be set directly in the annotations and can then be used for sorting in the TabOrder annotation.

If you wish to implement custom sorting or make changes to the definitions after Blossom have populated them you can create a customized DialogCreator by extending DefaultDialogCreator and override the createDialog method. In your case you could set label to null for all templates for instance, if you do not want to specify i18n labels explicitly.

Comment by Samuel Zihlmann [ 26/May/15 ]

Thats correct, but I've tried to use the new i18n API (https://documentation.magnolia-cms.com/display/DOCS/New+and+old+i18n+API)
It's not really possible to use Blossom without setting i18nBasename which indicates the old API... But I found a way to use the same key pattern:
So the property files are then stored in /src/main/resources/ch/example/messages_**.properties

@DialogFactory(value = "example:components/content/exTextBoxDialog")
@TabOrder({ "content", "social" })
@I18nBasename("ch.example.messages")
@Component
public class TextBoxDialog {

    @TabFactory("content")
    public void contentTab(final UiConfig cfg, final TabBuilder tab) {
        tab.fields(
                cfg.fields.text("subtitle").i18n()
                , cfg.fields.richText("text").i18n()
                );
    }

    @TabFactory("social")
    public void socialTab(final UiConfig cfg, final TabBuilder tab) {
        tab.fields(
                cfg.fields.text("facebookLink")
                , cfg.fields.text("googleplusLink")
                , cfg.fields.text("twitterLink")
                );
    }
}

And the keys looks like:

example.components.content.exTextBoxDialog.label=Text Box
example.components.content.exTextBoxDialog.content.subtitle.label=Subtitle
example.components.content.exTextBoxDialog.content.text.label=Text
example.components.content.exTextBoxDialog.social.facebookLink.label=Facebook Link
example.components.content.exTextBoxDialog.social.facebookLink.description=Some text
...
Comment by Samuel Zihlmann [ 26/May/15 ]

Ok it's not a full workaround because tab-label is now not i18n:

example.components.content.exTextBoxDialog.content.label=Content

this would work, but key is too generic

content=Content
Comment by Frank Sommer [ 17/Jun/15 ]

This is not a new topic, see BLOSSOM-202. I didn't understand why this should not be a bug in blossom.

Comment by Tobias Mattsson [ 13/Nov/15 ]

BLOSSOM-228 proposes a fix to this issue that should make it straight forward to use the new I18n API.

Generated at Sun Feb 11 23:31:12 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.