You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marius Kreis <ma...@nulldevice.org> on 2005/10/12 10:13:14 UTC

HtmlCommandLink ActionListener throwing Exception

I'm trying to dynamically building a list of links whereas each of them 
has an ActionListener.

The code is like this:

while(...) {
         HtmlCommandLink link = new HtmlCommandLink();
         link.setValue("link text");
         link.addActionListener(new PropertyPageListener());
         panel.getChildren().add(link);
}
(PropertyPageListener is implementing the ActionListener interface)

The code is generating the links but when I click on one of them an 
exception is thrown (see bottom of the mail).

Any idea what's going wrong?
Is is correct to call the method addActionListener with an anonymous object?

- Marius



    exception
javax.servlet.ServletException: 
org.apache.myfaces.component.html.ext.HtmlCommandLink
javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

    root cause
javax.faces.FacesException: 
org.apache.myfaces.component.html.ext.HtmlCommandLink
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421) 
org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219) 
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:330)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

Re: HtmlCommandLink ActionListener throwing Exception

Posted by Marius Kreis <ma...@nulldevice.org>.
i thought i could use the method addActionListener... but 
setActionListener isn't working either.
it seems as if the error is not dependent of the actionListener but 
thrown if an HtmlOutputLink is clicked itself.... i just described the 
problem in another mail...

Mike Kienenberger wrote:
> setActionListener takes a MethodBinding which references an
> ActionListener, and not an ActionListener directly.   Create a custom
> MethodBinding pointing to your PropertyPageListener.
> 
> I think I made an example of doing this as an attachment to
> 
> http://issues.apache.org/jira/browse/MYFACES-331
> 
> On 10/12/05, Marius Kreis <ma...@nulldevice.org> wrote:
> 
>>I'm trying to dynamically building a list of links whereas each of them
>>has an ActionListener.
>>
>>The code is like this:
>>
>>while(...) {
>>         HtmlCommandLink link = new HtmlCommandLink();
>>         link.setValue("link text");
>>         link.addActionListener(new PropertyPageListener());
>>         panel.getChildren().add(link);
>>}
>>(PropertyPageListener is implementing the ActionListener interface)
>>
>>The code is generating the links but when I click on one of them an
>>exception is thrown (see bottom of the mail).
>>
>>Any idea what's going wrong?
>>Is is correct to call the method addActionListener with an anonymous object?
>>
>>- Marius
>>
>>
>>
>>    exception
>>javax.servlet.ServletException:
>>org.apache.myfaces.component.html.ext.HtmlCommandLink
>>javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
>>org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
>>
>>    root cause
>>javax.faces.FacesException:
>>org.apache.myfaces.component.html.ext.HtmlCommandLink
>>org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421)
>>org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
>>org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
>>org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:330)
>>javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
>>org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
>>
> 
> 


Re: HtmlCommandLink ActionListener throwing Exception

Posted by Mike Kienenberger <mk...@gmail.com>.
setActionListener takes a MethodBinding which references an
ActionListener, and not an ActionListener directly.   Create a custom
MethodBinding pointing to your PropertyPageListener.

I think I made an example of doing this as an attachment to

http://issues.apache.org/jira/browse/MYFACES-331

On 10/12/05, Marius Kreis <ma...@nulldevice.org> wrote:
> I'm trying to dynamically building a list of links whereas each of them
> has an ActionListener.
>
> The code is like this:
>
> while(...) {
>          HtmlCommandLink link = new HtmlCommandLink();
>          link.setValue("link text");
>          link.addActionListener(new PropertyPageListener());
>          panel.getChildren().add(link);
> }
> (PropertyPageListener is implementing the ActionListener interface)
>
> The code is generating the links but when I click on one of them an
> exception is thrown (see bottom of the mail).
>
> Any idea what's going wrong?
> Is is correct to call the method addActionListener with an anonymous object?
>
> - Marius
>
>
>
>     exception
> javax.servlet.ServletException:
> org.apache.myfaces.component.html.ext.HtmlCommandLink
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
> org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
>
>     root cause
> javax.faces.FacesException:
> org.apache.myfaces.component.html.ext.HtmlCommandLink
> org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421)
> org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
> org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:330)
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
> org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
>