1

I have an <a4j:commandLink> which I need to fire an action on my controller,

<h:form>
    <a4j:commandLink
        actionListener="#{controller.send(viewBean.id, cc.attrs.guid)}"
        onbegin="$.efc.busy($.messages.sending);"
        oncomplete="$.efc.busy('', true);">
        Send offer to this dealer
    </a4j:commandLink>
</h:form>

When I click on the link, the onbegin javascript is successfully fired but the action is never called. Here is my action from my controller:

public void send(String id, String guid) {
    if (id != null && guid != null) {
        ...
    }
}

My viewBean is view scoped and the guid comes from the component... What am I missing here?

EDIT

If I change the link to a button it works... but I need a link:

<a4j:commandButton
    action="#{controller.send(viewBean.id, cc.attrs.guid)}"
    onbegin="$.efc.busy($.messages.sending);"
    oncomplete="$.efc.busy('', true);"
    value="Send offer to this dealer">
</a4j:commandButton>
ferics2
  • 5,241
  • 7
  • 30
  • 46
  • 2
    You cannot pass values using actionlistner, use action. see http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener for more details – Johny T Koshy Mar 15 '14 at 04:21

1 Answers1

0

According to documentation :

"MethodExpression representing an action listener method that will be notified when this component is activated by the user. The expression must evaluate to a public method that takes an ActionEvent parameter, with a return type of void."

javax.el.MethodExpression (signature must match void actionListener(javax.faces.event.ActionEvent))

chopper
  • 6,649
  • 7
  • 36
  • 53
Kasper Ziemianek
  • 1,329
  • 8
  • 15
  • So is it possible to accomplish what I want using an ``? I tried using an action instead of an action listener and could not get that to work either. I eventually just switched to a `
    ` styled like a like and called a `` onClick.
    – ferics2 Mar 17 '14 at 12:48
  • Not elegant solution is to have both link and button. Button with style display:none will be hidden. a4j:commandLink with onClick javascript which will fire onclick event on button and trigger round trip. – Kasper Ziemianek Mar 17 '14 at 13:03
  • Action attribute of a4j:commandLink must evaluate public method that takes no arguments and returns Object. It's used for navigation purposes. – Kasper Ziemianek Mar 17 '14 at 18:08