package org.apache.wicket.examples.forminput;
import java.awt.Font;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import org.apache.wicket.Page;
import org.apache.wicket.Session;
import org.apache.wicket.SharedResources;
import org.apache.wicket.examples.WicketExampleApplication;
import org.apache.wicket.markup.html.image.resource.DefaultButtonImageResource;
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
@author
public class FormInputApplication extends WicketExampleApplication
{
public static final List<Locale> LOCALES = Arrays.asList(Locale.ENGLISH,
new Locale("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE,
new Locale("pt", "BR"), new Locale("fa", "IR"), new Locale("da", "DK"),
new Locale("th", "TH"), new Locale("ru"), new Locale("ko", "KR"));
@Override
public Class<? extends Page> getHomePage()
{
return FormInput.class;
}
@Override
public Session newSession(Request request, Response response)
{
WebSession session = new WebSession(request);
Locale locale = session.getLocale();
if (!LOCALES.contains(locale))
{
session.setLocale(Locale.ENGLISH);
}
return session;
}
@Override
protected void init()
{
super.init();
getResourceSettings().setThrowExceptionOnMissingResource(false);
Font font = new Font("SimSun", Font.BOLD, 16);
DefaultButtonImageResource imgSave = new DefaultButtonImageResource("\u4FDD\u5B58");
imgSave.setFont(font);
DefaultButtonImageResource imgReset = new DefaultButtonImageResource("\u91CD\u7F6E");
imgReset.setFont(font);
SharedResources sharedResources = getSharedResources();
sharedResources.add("save", Locale.SIMPLIFIED_CHINESE, imgSave);
sharedResources.add("reset", Locale.SIMPLIFIED_CHINESE, imgReset);
Font fontJa = new Font("Serif", Font.BOLD, 16);
DefaultButtonImageResource imgSaveJa = new DefaultButtonImageResource("\u4fdd\u5b58");
imgSaveJa.setFont(fontJa);
DefaultButtonImageResource imgResetJa = new DefaultButtonImageResource(
"\u30ea\u30bb\u30c3\u30c8");
imgResetJa.setFont(fontJa);
sharedResources.add("save", Locale.JAPANESE, imgSaveJa);
sharedResources.add("reset", Locale.JAPANESE, imgResetJa);
Font fontFa = new Font("Serif", Font.BOLD, 16);
Locale farsi = new Locale("fa", "IR");
DefaultButtonImageResource imgSaveFa = new DefaultButtonImageResource(
"\u0630\u062e\u064a\u0631\u0647");
imgSaveFa.setFont(fontFa);
DefaultButtonImageResource imgResetFa = new DefaultButtonImageResource(
"\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u064a");
imgResetFa.setFont(fontFa);
getSharedResources().add("save", farsi, imgSaveFa);
getSharedResources().add("reset", farsi, imgResetFa);
}
}