/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.wicket.security.examples.multilogin.pages; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.security.examples.multilogin.components.navigation.ButtonContainer; import org.apache.wicket.security.examples.multilogin.entities.Entry; /** * Page for showing the balance of a bank account. * * @author marrink */ public class BankAccountBalancePage extends SecurePage { /** * */ private static final long serialVersionUID = 1L; /** * Construct. */ public BankAccountBalancePage() { add(new ButtonContainer("buttoncontainer", ButtonContainer.BUTTON_OVERVIEW)); add(new ListView<Entry>("transactions", generateData()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Entry> item) { item.add(new Label("when")); item.add(new Label("from")); item.add(new Label("to")); item.add(new Label("description")); item.add(new Label("amount")); if (item.getIndex() % 2 == 0) item.add(new SimpleAttributeModifier("class", "outside halfhour")); } @Override protected IModel<Entry> getListItemModel(IModel< ? extends List<Entry>> listViewModel, int index) { return new CompoundPropertyModel<Entry>(super .getListItemModel(listViewModel, index)); } }); } /** * Generate some random data * * @return */ private List<Entry> generateData() { int size = (int) (Math.random() * 90) + 10; List<Entry> data = new ArrayList<Entry>(size); String to = "" + System.currentTimeMillis(); for (int i = 0; i < size; i++) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, (-1 * size) + i); cal.add(Calendar.HOUR_OF_DAY, (int) Math.random() * 12); data.add(new Entry("" + cal.getTimeInMillis(), to, cal.getTime().toString(), "foobar", "$" + (Math.random() * 2546.789))); } return data; } }