Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
License Agreement. Rich Faces - Natural Ajax for Java Server Faces (JSF) Copyright (C) 2007 Exadel, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 
 package org.ajax4jsf.templatecompiler.elements.vcp;
 
 import java.util.List;
 

Author(s):
Maksim Kaszynski Utility element for HeaderResourceRenderer-based templates Creates getXxx() methods with values set within it body Example <h:styles>/org/ajax4jsf/resource/style.css,/org/ajax4jsf/resource/style2.css</h:styles> results in
private final InternetResource[] styles = { getResource("/org/ajax4jsf/resource/style.css"), getResource(/org/ajax4jsf/resource/style2.css") }; protected InternetResource [] getStyles() { return styles; }
 
 public abstract class HeaderResourceElement extends TemplateElementBase {
 
 
 	private static final String TEMPLATE = .+"/headerResource.vm";
 
 	private static final String NEW = "new ";
 
 	private String[] keys;
 
 	private String[] resourcePaths;
 	
 	public HeaderResourceElement(Node elementCompilationContext componentBean)
 		super(elementcomponentBean);
 		String resourcesAsString = element.getTextContent();
 		if (resourcesAsString != null) {
 			resourcesAsString = resourcesAsString.trim();
 			StringTokenizer tokenizer = new StringTokenizer(resourcesAsString,
 					"\r\n\t,;");
 			List paths = new ArrayList(tokenizer.countTokens());
 			List keyz = new ArrayList(tokenizer.countTokens());
 			while (tokenizer.hasMoreTokens()) {
 				String token = tokenizer.nextToken().trim();
 				String path;
 				
 				if (token.startsWith()) {
 					keyz.add(token);
 					int idx = token.indexOf('(');
 					if (idx != -1) {
 						path = token.substring(0, idx).substring(.length()).trim();
 					} else {
 						path = token.substring(.length()).trim();
 					}
 				} else {
 					keyz.add("getResource(\"" + token + "\")");
 					path = token;
 				}
 
 				paths.add(path);
 			}
 			this. = (String[]) keyz.toArray(new String[keyz.size()]);
 			this. = (String[]) paths.toArray(new String[paths.size()]);
 		}
 		componentBean
 				.addToImport("org.ajax4jsf.resource.InternetResource");
 		componentBean.addToDeclaration(getContent());
	}
	private String getterMethodName(String propName) {
		return "get" + Character.toUpperCase(propName.charAt(0))
propName.substring(1);
	}
	protected String getGetterModifier() {
		return "protected";
	}
	protected abstract String getPropertyName();
	public String getBeginElement() {
		// TODO Auto-generated method stub
		return null;
	}
	private String getContent() throws CompilationException {
		VelocityContext context = new VelocityContext();
		String propertyName = getPropertyName();
		if (this. != null) {
			context.put("resourceKeys"this.);
		}
		context.put("propertyGetterName"getterMethodName(propertyName));
		context.put("property"propertyName);
		context.put("getterModifier"getGetterModifier());
	}

Returns:
	protected String getTemplateName() {
		return ;
	}
	public String getEndElement() {
		// TODO Auto-generated method stub
		return null;
	}
	public boolean isSkipBody() {
		// TODO Auto-generated method stub
		return true;
	}
	public String[] getResourcePaths() {
	}
New to GrepCode? Check out our FAQ X