All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ajax4jsf.framework.renderer.compiler.SelectorElement Maven / Gradle / Ivy

/**
 * Licensed under the Common Development and Distribution License,
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.sun.com/cddl/
 *   
 * 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.ajax4jsf.framework.renderer.compiler;

import java.io.IOException;

import org.ajax4jsf.framework.util.message.Messages;
import org.xml.sax.SAXException;

/**
 * @author Maksim Kaszynski (latest modification by $Author: slava_kabanovich $)
 * @version $Revision: 1.2 $ $Date: 2006/07/12 09:45:58 $
 * CSS selector tag.
 * Works this way
 * 
 * 	
 * 		a bunch of 
 * 	
 * 
 * renders like this
 * 
 * 	.X{
 * 		styles...
 * 	}
 * 
 *
 */
public class SelectorElement extends ElementBase {

	private String name ;
	
	protected void encodeBegin(TemplateContext context) throws IOException {
		context.getWriter().write("\n" + getName() + "{\n");
	}
	
	protected void encodeEnd(TemplateContext context) throws IOException {
		context.getWriter().write("}");
	}


	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.renderer.compiler.PreparedTemplate#getTag()
	 */
	public String getTag() {
		// TODO Auto-generated method stub
		return HtmlCompiler.NS_PREFIX+HtmlCompiler.SELECTOR_TAG;
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.renderer.compiler.ElementBase#setParent(org.ajax4jsf.framework.renderer.compiler.PreparedTemplate)
	 */
	public void setParent(PreparedTemplate parent) throws SAXException {		
		super.setParent(parent);
		if (getName()==null) {
			throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy