updateUICommand = (UICommand)
app.createComponent(UICommand.COMPONENT_TYPE);
        updateUICommand.setValue("Update");
        updateUICommand.setId("updateUICommand");

        updateUICommand.setActionListener(new YourListenMethodBinding());

You'll need to create your own MethodBinding subclass.   You can
probably have MethodBinding.invoke() directly call your listen method.
 Don't forget to implement StateHolder.

-Mike


On 11/17/05, Simon Kitching <[EMAIL PROTECTED]> wrote:
> Bobby Rosenberger wrote:
> > Hey everyone,
> >
> > I've floundered enough.
> >
> > I would like to dynamically create a link that has an associated
> > actionListener. I understand how to do it using the tags... but
> > dynamically, I'm getting stumped... could someone help me over the hump?
> > (my hump, my hump, ... ok shoot me.) I'm creating the link as follows:
> >
> > UICommand link = new UICommand();
> > link.setRendererType("javax.faces.Link");
> > link.setId("myLink");
> >
> > I've also defined the following method:
> >
> > public void listen(ActionEvent e){
> >         String id = e.getComponent().getClientId(getContext());
> >         System.out.println("Link Id: " + id);
> >     }
> >
> > Now the question is.. how the heck to I hood the two together? I would
> > like the "listen" method to be called when anyone clicks on the link...
> >
>
> I've not done this programmatically myself, but I believe that this all
> follows the generic listener pattern.
>
> The class containing the listen method needs to implement interface
> ActionListener - or you need to create a simple class that does
> implement that interface (eg as an inner class or an anonymous class),
> just like the standard listener pattern for Swing or other apps.
>
> You then call
>    link.addFacesListener(yourListenerObject)
>
> Regards,
>
> Simon
>

Reply via email to