package ${package_name};

import com.sap.mbs.core.api.BOList;
import com.sap.mbs.core.api.BOException;
import com.sap.mbs.core.api.Context;
import com.sap.mbs.core.api.Forward;
import com.sap.mbs.core.api.Forwards;
import com.sap.mbs.core.api.NamingService;
import com.sap.mbs.core.control.AbstractViewController;
import ${bo_interface_package_name}.*;

public class ${class_name} extends ${abstract_class_name} {

    private static final NamingService	naming = NamingService.getInstance();
    private static final String		${top_bo_name_upper}_MANAGER_NAME
	= ${bo_manager_name}.class.getName();

    public ${class_name}() {
	super();
    }

    public Forward onLoad(Forwards forwards) {
	${top_bo_name}Custom	custom = get${top_bo_name}Custom();

	// get cached mam010 list from custom controller
	try {
	    BOList	items = custom.get${top_bo_name}s();

	    Context	context = getContext();
	    context.setValues("keys", new Object[] {});
	    // mapping to context
	    for (int i = 0; i < items.size(); i++) {
		${top_bo_name}	item = (${top_bo_name})items.get(i);
		context.addValue("keys", item.getKey());
	    }
	} catch (BOException e) {
	    forwards.findForward("error");
	}

	return	forwards.findForward("default");
    }

    public Forward onItemSelected(Forwards forwards) {

	try {
	    Context	context = getContext();
	    String	key = (String)context.getValue("key");

	    ${top_bo_name}Custom	custom = get${top_bo_name}Custom();
	    custom.setSelected${top_bo_name}(key);
	} catch (BOException e) {
	    forwards.findForward("error");
	}

	return	forwards.findForward("default");
    }
}
