001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.platform.forms.layout.service; 018 019import org.jboss.seam.ScopeType; 020import org.jboss.seam.annotations.Name; 021import org.jboss.seam.annotations.Scope; 022 023/** 024 * Helper component to count number of columns rendered in a layout context. 025 * <p> 026 * Useful when rendering listing layouts in a PDF table, where number of columns need to be known in advance. 027 * 028 * @since 5.4.2 029 */ 030// TODO: move this dependency to Seam elsewhere 031@Name("layoutColumnCounter") 032@Scope(ScopeType.EVENT) 033public class LayoutColumnCounter { 034 035 protected Integer index; 036 037 public Integer getCurrentIndex() { 038 return index; 039 } 040 041 public void setCurrentIndex(Integer index) { 042 this.index = index; 043 } 044 045 public void increment() { 046 if (index == null) { 047 index = new Integer(0); 048 } 049 this.index = new Integer(index.intValue() + 1); 050 } 051 052 public void decrement() { 053 if (index == null) { 054 index = new Integer(0); 055 } 056 this.index = new Integer(index.intValue() - 1); 057 } 058 059}