1 16 17 package org.springframework.web.servlet.tags.form; 18 19 import javax.servlet.jsp.PageContext ; 20 21 33 final class TagIdGenerator { 34 35 38 private static final String PAGE_CONTEXT_ATTRIBUTE_PREFIX = TagIdGenerator.class.getName(); 39 40 43 private TagIdGenerator() { 44 45 } 46 47 50 public static String nextId(String name, PageContext pageContext) { 51 String attributeName = PAGE_CONTEXT_ATTRIBUTE_PREFIX + "." + name; 52 Integer currentCount = (Integer ) pageContext.getAttribute(attributeName); 53 currentCount = (currentCount == null ? new Integer (1) : new Integer (currentCount.intValue() + 1)); 54 pageContext.setAttribute(attributeName, currentCount); 55 return name + currentCount.intValue(); 56 } 57 } 58 | Popular Tags |