>From org.apache.myfaces.taglib.UIComponentTagUtils: public static void setActionProperty(FacesContext context, UIComponent component, String action) { if (action != null) { if (!(component instanceof UICommand)) { throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no UICommand"); } MethodBinding mb; if (isValueReference(action)) { mb = context.getApplication().createMethodBinding(action, null); } else { mb = new SimpleActionMethodBinding(action); } ((UICommand)component).setAction(mb); } }
On 10/6/05, Jeroen Verhagen <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm working on a custom ViewHandler like is presented in Hans Bergsten > JSF book chapter 15. > For that I need to programmatically create a command button. I have > buttons that need method bindings to talk to method in my managed > beans. But I also need command buttons that simply return a String > value, for example "cancel" like this in JSP: > > <h:commandButton > value="Cancel" > action="cancel"/> > > > > using this code: > > UICommand command = new UICommand(); > command.setValue("Cancel"); > MethodBinding action = application.createMethodBinding("cancel", null); > command.setAction(action); > > but I get this exception: javax.faces.el.ReferenceSyntaxException: cancel > I know that cancel is not really a method but I don't know what other > method to call set the command button to return the String "cancel". > > Anybody any idea? > > Thanks and regards, > > Jeroen >