I guess his code just uses Wicket's CookieUtils class.
See
https://github.com/apache/isis/blob/master/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/themepicker/ThemeChooser.java#L94-L105
for example.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Dec 17, 2014 at 10:05 AM, Hasan Çelik <hsnclk1...@gmail.com> wrote:
>
> Thanks for reply,
>
> Can you give detail about getCookieUtils() and CCA_LANGUAGE_COOKIE_NAME in
> your CcaWebApplication class
>
> Regards,
>
>
>
> On 17 December 2014 at 09:06, Richter, Marvin <
> marvin.rich...@freenetdigital.com> wrote:
> >
> > Hey, I have something like that implemented in the following way:
> >
> >         @Override
> >                 protected List<AbstractLink> newSubMenuButtons(String
> > buttonMarkupId) {
> >                     List<AbstractLink> languages = new
> > ArrayList<AbstractLink>();
> >                     languages.add(newLanguageOption(buttonMarkupId,
> "de"));
> >                     languages.add(newLanguageOption(buttonMarkupId,
> "en"));
> >                     return languages;
> >                 }
> >
> > And the newLanguageOption method looks like this:
> >
> > private Link<Void> newLanguageOption(final String buttonMarkupId, final
> > String localeString) {
> >         Link<Void> languageOptionLink = new Link<Void>(buttonMarkupId) {
> >
> >                 private static final long serialVersionUID =
> > -1704794810431937803L;
> >
> >                 @Override
> >                 public void onClick() {
> >                     Locale locale = new Locale(localeString);
> >
> >
> CcaWebApplication.get().getCookieUtils().save(CcaWebApplication.CCA_LANGUAGE_COOKIE_NAME,
> >                         locale.toString());
> >                     getSession().setLocale(locale);
> >                 }
> >
> >                 @Override
> >                 public void onComponentTagBody(MarkupStream markupStream,
> > ComponentTag openTag) {
> >                     replaceComponentTagBody(markupStream, openTag,
> > getString(localeString));
> >                 }
> >             };
> >         return languageOptionLink;
> >     }
> >
> > Hope that helps.
> >
> > Best,
> > Marvin
> >
> > -----Original Message-----
> > From: Hasan Çelik [mailto:hsnclk1...@gmail.com]
> > Sent: Wednesday, December 17, 2014 7:46 AM
> > To: users@wicket.apache.org
> > Subject: submenu in NavbarDropDownButton
> >
> > Hi,
> >
> > I have a question about usage of navbar components.. I tried to make
> > Multilingual website, actually I did... when I put language buttons in a
> > wicket panel, It works...In this example I try to put these language
> > buttons into dropdown submenu.. First I did one Multilanguage class and
> > this class was taking a parameter...This parameter was about Locale
> > String(like "en")..In this way I didn't succeed to take parameter in the
> > submenu declaration,like that
> >
> > subMenu.add(new MenuBookmarkablePageLink<Void>(new
> > MultiLanguage("en"),
> > Model.of("Turkish")).setIconType(GlyphIconType.refresh));
> >
> > I know that declaration (new MultiLanguage("en")) is wrong but I wanted
> to
> > do like that...Anyway After that I have changed the method construction
> as
> > the following.. But in this way I have to create different  Multilanguage
> > class for every diffent language. My question is, Is there a way to
> create
> > construction for submenu declaration like that..(*subMenu.add(new
> > MenuBookmarkablePageLink<Void>(new
> > MultiLanguage("en"),
> > Model.of("Turkish")).setIconType(GlyphIconType.refresh));*)
> >
> >
> > DropDownButton dropdown = new NavbarDropDownButton(Model.of("Choose
> > Language")) {
> >     @Override
> >     public boolean isActive(Component item) {
> >         return false;
> >     }
> >
> >     @Override
> >     protected List<AbstractLink> newSubMenuButtons(final String
> > buttonMarkupId) {
> >         final List<AbstractLink> subMenu = new ArrayList<AbstractLink>();
> >         subMenu.add(new
> > MenuBookmarkablePageLink<Void>(MultiLanguage.class,
> > Model.of("Turkish")).setIconType(GlyphIconType.*flag*));
> >         subMenu.add(new
> > MenuBookmarkablePageLink<Void>(MultiLanguage2.class,
> > Model.of("English")).setIconType(GlyphIconType.*flag*));
> >
> >         return subMenu;
> >      }
> >  }.setIconType(GlyphIconType.book);
> >
> >  navbar.addComponents(new ImmutableNavbarComponent(dropdown,
> > Navbar.ComponentPosition.RIGHT));
> >
> >  return navbar;
> >
> >
> > --------------------------------------------------
> >
> >
> > public class MultiLanguage extends BasePage2 {
> >     public MultiLanguage(){
> >         super(new PageParameters());
> >         changeUserLocaleTo("en");
> >     }
> >     private void changeUserLocaleTo(String localeString) {
> >         getSession().setLocale(new Locale(localeString));
> >
> >         Cookie languageCookie = new
> > Cookie(WicketApplication.LANGUAGE_COOKIE_NAME, localeString);
> >         languageCookie.setMaxAge(WicketApplication.LANGUAGE_COOKIE_AGE);
> >         ((WebResponse)getResponse()).addCookie(languageCookie);
> >     }
> > }
> >
> > public class MultiLanguage1 extends BasePage2 {
> >     public MultiLanguage(){
> >         super(new PageParameters());
> >         changeUserLocaleTo("tr");
> >     }
> >     private void changeUserLocaleTo(String localeString) {
> >         getSession().setLocale(new Locale(localeString));
> >
> >         Cookie languageCookie = new
> > Cookie(WicketApplication.LANGUAGE_COOKIE_NAME, localeString);
> >         languageCookie.setMaxAge(WicketApplication.LANGUAGE_COOKIE_AGE);
> >         ((WebResponse)getResponse()).addCookie(languageCookie);
> >     }
> > }
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>

Reply via email to