package org.ajax4jsf.bean;

import javax.faces.event.ActionEvent;

public class A4JSupport {
	
	private String data = null;
	
	/** property for testUpdatingValue */
	private String inputValue = A4JSupport.Messages.INPUT_VALUE;
	
	
	
	public static final String BEAN_NAME = "ajaxSupport";
	
	public static class Messages {
		public static final String FOR_LINK = "Link onclick passed";
		
		public static final String FOR_CHECKBOX = "Checkbox onchange passed";
		
		public static final String FOR_COMMAND = "Command onclick passed";
		
		public static final String FOR_SUBMIT = "Default listener";
		
		public static final String NO_DATA = "nodata";
		
		public static final String TEST_PASSED = "test passed";
		
		public static final String VALID_MESSAGE = "field is required";
		
		public static final String INPUT_VALUE = "test";
	}
	
	public void linkListener (ActionEvent event) {
		data = Messages.TEST_PASSED;
	}
	
	public void checkBoxListener (ActionEvent event) {
		data = Messages.TEST_PASSED;
	}
	
	public void commandListener (ActionEvent event) {
		data = Messages.FOR_COMMAND;
	}

	public void listener (ActionEvent event) {
		data = Messages.FOR_SUBMIT;
	}
	
	public void updatingValueAction() {
		data = inputValue;
	}

	/**
	 * @return the data
	 */
	public String getData() {
		return (data != null) ? data : Messages.NO_DATA;
	}

	/**
	 * @param data the data to set
	 */
	public void setData(String data) {
		this.data = data;
	}

	public String getInputValue() {
		return inputValue;
	}

	public void setInputValue(String inputValue) {
		this.inputValue = inputValue;
	}

}
