package org.ajax4jsf;

import java.util.Map;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class A4jTestBean {

	private String param = "Not set yet";
	private boolean checked;

	public String getParam() {
		return param;
	}

	public void setParam(String param) {
		this.param = param;
	}
	
	private void checkMap() {
		Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
		for (String key : params.keySet()) {
			System.out.println(key + "=" + params.get(key));
		}
	}
	
	public void perform(ActionEvent actionEvent) {
		System.out.println("A4jTestBean.perform(ActionEvent) = " + param);
		checkMap();
	}

	public void perform() {
		System.out.println("A4jTestBean.perform() = " + param);
		checkMap();
	}
	
	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}
}
