Forum Stats

  • 3,851,967 Users
  • 2,264,055 Discussions
  • 7,904,918 Comments

Discussions

need to change portal language from a bean

user611775
user611775 Member Posts: 278
edited Nov 14, 2019 1:01AM in WebCenter Portal

i need to add a button on portal template to change portal language

I have tried the below class but it does not help

        Locale locale = (Locale) JSFUtils.resolveExpression("#{facesContext.viewRoot.locale}");

        return locale != null && locale.getLanguage()

                                       .toLowerCase()

                                       .contains("ar");

is there any sample code that i can use to change the langue other than using portal task flow.

User_112YD

Best Answer

  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Nov 13, 2019 3:17AM Answer ✓

    Hi,

    I am assuming you are in Oracle WebCenter Portal 12.x.x.x (Please, always share your Portal version)

    You have multiple choices for it.

    1. Your own implementation for managing the Locale and link it to the f:view locale attribute of your pages
    2. Out-of-the-box Portal solution
    3. Re-plicate the Out-of-the-box solution manually <- I think you are chasing this one.

    So let's explain solution 3)

    1. In Oracle WebCentere Portal, there is a Managed Bean available which can be consumed via EL Expression (#{o_w_wa_chooseLanguage})
    2. Using that Managed Bean you can switch your Portal Locale within a button like (I wrote the code by memory, maybe has issues)
    <af:button partialSubmit="true" id="arabic"                          actionListener="#{o_w_wa_chooseLanguage.changeLanguage}"                          text="Arabic">            <f:attribute name="wcLangId" value="ar"/></af:button>

    3. Also you can have your own managed bean which will call to changeLanguage EL Expression method with the Locale you want.

    I hope with this approach is enough for your solution .

    Kind regards.

    User_112YD

Answers

  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Nov 13, 2019 3:17AM Answer ✓

    Hi,

    I am assuming you are in Oracle WebCenter Portal 12.x.x.x (Please, always share your Portal version)

    You have multiple choices for it.

    1. Your own implementation for managing the Locale and link it to the f:view locale attribute of your pages
    2. Out-of-the-box Portal solution
    3. Re-plicate the Out-of-the-box solution manually <- I think you are chasing this one.

    So let's explain solution 3)

    1. In Oracle WebCentere Portal, there is a Managed Bean available which can be consumed via EL Expression (#{o_w_wa_chooseLanguage})
    2. Using that Managed Bean you can switch your Portal Locale within a button like (I wrote the code by memory, maybe has issues)
    <af:button partialSubmit="true" id="arabic"                          actionListener="#{o_w_wa_chooseLanguage.changeLanguage}"                          text="Arabic">            <f:attribute name="wcLangId" value="ar"/></af:button>

    3. Also you can have your own managed bean which will call to changeLanguage EL Expression method with the Locale you want.

    I hope with this approach is enough for your solution .

    Kind regards.

    User_112YD
  • user611775
    user611775 Member Posts: 278
    edited Nov 13, 2019 4:08AM

    thanks Daniel for your reply this helped me.

    i need to know from where you got this bean as i need to know how to override other portal functions and need to know how to get these beans to achieve other functions.

  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Nov 13, 2019 4:15AM

    Hi,


    This is just "long experience" with the product and strong knowlegde of the internal code of the product.

    Usually, people implements their own strategy custom by a LanguageBean to keep your locale and map it to f:view of the portal pages.

    However, I prefer this solution as it is aligned how the Product works. We can say... it is undocumented API you can use .

    Kind regards.

  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Nov 13, 2019 4:29AM
  • user611775
    user611775 Member Posts: 278
    edited Nov 14, 2019 1:01AM

    thanks Daniel for your reply.