0
JSF 2.0 및 tomahawk-lib를 사용하여 동적으로 html 요소를 만듭니다. HtmlCommandButton에 액션 명령을 추가하고 싶지만 끝내지 못합니다. 귀하의 도움에 미리 감사드립니다. 버튼과 onclick이 트리거되는 것을 볼 수 있으므로 메서드 표현식과 관련된 실수가 있어야합니다.commandButton에 동적으로 동작 추가
HtmlCommandButton submitLogin = new HtmlCommandButton();
FacesContext fc = FacesContext.getCurrentInstance();
ELContext ctx = fc.getELContext();
String expression = "#{hangmanController.login}";
Class[] parameterTypes = new Class[0];
MethodExpression me = fc.getApplication().getExpressionFactory().
createMethodExpression(ctx, expression, String.class, parameterTypes);
submitLogin.setActionExpression(me);
submitLogin.setOnclick("alert('BP');");