Java tutorial
/* * Copyright 2008-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package almira.sample.web; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Locale; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.model.ResourceModel; import org.apache.wicket.spring.injection.annot.SpringBean; import org.springframework.stereotype.Component; import almira.sample.web.panel.LocaleDropDownPanel; import almira.sample.web.service.TextService; /** * Wicket Base Page. */ @Component public abstract class AbstractBasePage extends WebPage { @SpringBean private TextService footerTextService; /** * Constructor. */ AbstractBasePage() { super(); // http://apache-wicket.1842946.n4.nabble.com/wicket-message-in-the-title-td1843627.html add(new Label("pageTitle", new ResourceModel("catapult.title"))); add(new BookmarkablePageLink<Void>("homeLink", IndexPage.class)); add(new BookmarkablePageLink<Void>("adminLink", AdminPage.class)); add(new LocaleDropDownPanel("localeSelectPanel", Arrays.asList(new Locale("es"), new Locale("de"), new Locale("en"), new Locale("fr"), new Locale("it")))); add(new Label("version", ((MainApplication) getApplication()).getVersion())); add(new Label("session", new PropertyModel<String>(this, "session.id"))); add(new SearchPanel("searchPanel")); add(new Label("footertext", footerTextService.getText())); // Page 87, Wicket in Action add(new Label("clock", new Model<String>() { @Override public String getObject() { final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy | HH:mm:ss.mmm", getSession().getLocale()); return dateFormat.format(new Date()); } })); } }