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.FindFieldUtil;

public class FindField extends BodyTagSupport{

	private static final long serialVersionUID = 259097494202966188L;

	private String id;
	private String lockupName;
	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 {
		FindFieldUtil findField = new FindFieldUtil();
		StringBuilder strBuff;
		try {
			strBuff = findField.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 getLockupName() {
		return lockupName;
	}

	public void setLockupName(String lockupName) {
		this.lockupName = lockupName;
	}

	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;
	}

	/**
	 * 	Atributos que não estão sendo utilizados, já não são mais obrigatórios no
	 * 	componente. Quando retirar de todos os componentes (cit:findField) pode
	 * 	ser retirado aqui.
	 *
	 * @since 30/09/2015
	 * @author douglas.japiassu
	 */
	private int top;
	private int left;
	private int len;

	public int getTop() {
		return top;
	}

	public void setTop(int top) {
		this.top = top;
	}

	public int getLeft() {
		return left;
	}

	public void setLeft(int left) {
		this.left = left;
	}

	public int getLen() {
		return len;
	}

	public void setLen(int len) {
		this.len = len;
	}

}
