Java tutorial
/** * Copyright 2014-2015 SHAF-WORK * * 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 org.shaf.server.controller; import org.springframework.web.servlet.ModelAndView; /** * The view panel. * * @author Mykola Galushka */ public class ViewPanel<V extends ModelAndView> extends ModelAndView { /** * The attribute name for the navigation icon. */ public final static String NAVIGATION_ICON = "navigation-icon"; /** * The attribute name for the navigation text. */ public final static String NAVIGATION_TEXT = "navigation-text"; /** * The attribute name for the status icon. */ public final static String STATUS_ICON = "status-icon"; /** * The attribute name for the navigation text. */ public final static String STATUS_TEXT = "status-text"; /** * Constructs a new view panel. * * @param name * the view panel name. */ protected ViewPanel(final String name) { super(name); } /** * Adds the navigation message. * * @param icon * the navigation icon. * @param text * the navigation text. * @return an itself. */ @SuppressWarnings("unchecked") public final V header(final String icon, final String text) { return (V) this.addObject(NAVIGATION_ICON, icon).addObject(NAVIGATION_TEXT, text); } /** * Adds the information status message. * * @param text * the status text. * @return an itself. */ @SuppressWarnings("unchecked") public final V info(final String text) { return (V) this.addObject(STATUS_ICON, "info").addObject(STATUS_TEXT, text); } /** * Adds the warning status message. * * @param text * the status text. * @return an itself. */ @SuppressWarnings("unchecked") public final V warn(final String text) { return (V) this.addObject(STATUS_ICON, "warn").addObject(STATUS_TEXT, text); } /** * Adds the error status message. * * @param text * the status text. * @return an itself. */ @SuppressWarnings("unchecked") public final V error(final String text) { return (V) this.addObject(STATUS_ICON, "error").addObject(STATUS_TEXT, text); } }