Expand my Community achievements bar.

SOLVED

need i18n values in model class from dialog node

Avatar

Level 4

Hi All,

I am trying to fetch the i18n values passed via dialog to model class.

But i am not able to get the same.

here is my dialog nodes:

<suffix-title-business
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   allowBulkEdit="{Boolean}true"
   ignoreData="{Boolean}true"
   name="./businessAffix"
   value="page.title.business.affix"/>

<suffix-title-personal
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   allowBulkEdit="{Boolean}true"
   ignoreData="{Boolean}true"
   name="./personalAffix"
   value="page.title.personal.affix"/>

here is the code in my model class:

@Inject @Optional
private  String personalAffix;

@Inject @Optional
private  String businessAffix;

I am not able to get the value in model class.

Please help.

1 Accepted Solution

Avatar

Correct answer by
Level 4

I resolved it. Maybe useful for others.

@Model(adaptables = SlingHttpServletRequest.class)

public class MyModel {  

    @Self

    SlingHttpServletRequest request;

  private I18n i18n;

  if (request != null) {

        i18n=new I18n(request);

  business=i18n.getVar("page.title.business.affix");

  }

}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 4

I resolved it. Maybe useful for others.

@Model(adaptables = SlingHttpServletRequest.class)

public class MyModel {  

    @Self

    SlingHttpServletRequest request;

  private I18n i18n;

  if (request != null) {

        i18n=new I18n(request);

  business=i18n.getVar("page.title.business.affix");

  }

}