myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Volker Weber" <weber.vol...@googlemail.com>
Subject Re: Set actionlistener in java code?
Date Tue, 07 Nov 2006 08:22:28 GMT
Hi,

you need to declare the method arguments on createMethodBinding.

try:
createMethodBinding("#{filter.addFilterToSubset}", new Class[]
{ActionEvent.class});

You can take a look into the tag sources for information how to set
any tag attribute value into the UIComponent object.

Regards,
  Volker



2006/11/7, Aneesha Govil <popcorn09@gmail.com>:
> Hi,
>
> I need to associate an actionlistener with an htmlcommandbutton in java
> code. I am using the following code snippet:
>
> HtmlCommandButton addButton = new HtmlCommandButton();
> addButton = new HtmlCommandButton();
>  MethodBinding mb =
> FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{filter.addFilterToSubset}",
> new Class[0]);
>  addButton.setActionListener(mb);
> addButton.setValue("Add");
>
> The signature of addFilterToSubset method is as follows:
>
> public void addFilterToSubset(ActionEvent event) {
>       //some code here
>     }
>
> The problem is, on clicking the button, it tries to look for a method
> addFilterToSubset() (no arguments). Shouldn't it be looking for one with
> actionevent?
>
> Please help. I don't know why something so simple isn't working.
>
> Thanks a lot.
> Regards,
> Aneesha
>
>

Mime
View raw message