package br.com.citframework.tld;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import br.com.citframework.util.SearchUtil;

public class Search extends BodyTagSupport {

	private static final long serialVersionUID = 259097494202966188L;

	private String id;
	private String searchName;
	private String formName;
	private int heigth;
	private String javascriptCode;
	private String htmlCode;
	private String checkbox;
	private String formCheckbox;
	private String distinct;

	@Override
	public int doStartTag() throws JspException {
		SearchUtil searchUtil = new SearchUtil();
		StringBuilder strBuff;
		try {
			strBuff = searchUtil.generate(pageContext.getRequest(), this);
		} catch (SecurityException e1) {
			e1.printStackTrace();
			throw new JspException(e1);
		} catch (IllegalArgumentException e1) {
			e1.printStackTrace();
			throw new JspException(e1);
		} catch (NoSuchMethodException e1) {
			e1.printStackTrace();
			throw new JspException(e1);
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
			throw new JspException(e1);
		}
		try {
			pageContext.getOut().println(strBuff.toString());
		} catch (IOException e) {
			e.printStackTrace();
			throw new JspException(e);
		}
		return SKIP_BODY;
	}

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	public String getSearchName() {
		return searchName;
	}

	public void setSearchName(String searchName) {
		this.searchName = searchName;
	}

	public String getFormName() {
		return formName;
	}

	public void setFormName(String formName) {
		this.formName = formName;
	}

	public int getHeigth() {
		return heigth;
	}

	public void setHeigth(int heigth) {
		this.heigth = heigth;
	}

	public String getJavascriptCode() {
		return javascriptCode;
	}

	public void setJavascriptCode(String javascriptCode) {
		this.javascriptCode = javascriptCode;
	}

	public String getHtmlCode() {
		return htmlCode;
	}

	public void setHtmlCode(String htmlCode) {
		this.htmlCode = htmlCode;
	}

	public String getCheckbox() {
		return checkbox;
	}

	public void setCheckbox(String checkbox) {
		this.checkbox = checkbox;
	}

	public String getFormCheckbox() {
		return formCheckbox;
	}

	public void setFormCheckbox(String formCheckbox) {
		this.formCheckbox = formCheckbox;
	}

	public String getDistinct() {
		return distinct;
	}

	public void setDistinct(String distinct) {
		this.distinct = distinct;
	}

}
