All pastes #651083 Raw Edit

Stuff

public text v1 · immutable
#651083 ·published 2007-08-09 13:35 UTC
rendered paste body
// Command action
	@CommandAction()
	public String navConnect() {
		return "CLIENT_connect.jsp";
	}


// "UnknownCommandActionException" is thrown and action.getAnnotations().length is 0, but action is navConnect
public String execute() throws UnknownCommandActionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
		String actParam = getRequest().getParameter("act");
		Method action = null;
		
		try {
			action = this.getClass().getMethod(actParam);
		}  catch (NoSuchMethodException e) {
			throw new UnknownCommandActionException();
		}
		
		System.out.println(action.getName()); // prints out the right method name
		
		if (action.getAnnotation(CommandAction.class) == null) {
			throw new UnknownCommandActionException("execute() access to nonCommandAction attempted");
		}
		
		return (String) action.invoke(this);
	}