0

While upgrading a large project from Mojarra 2.1.13 to 2.1.28, we noticed that all action and actionEvent methods on h:commandButton in a page where being called for every ajax request that executed the form. We were able to narrow down the problem to commandButton with type="button". These were working fine in 2.1.13, but after the upgrade, a click of one button triggers the actions of all others.

Below is the code used to recreate the issue:

<h:form id="form">

        <h:commandButton type="button" value="Action1" action="#{page1.action1}">
            <f:ajax execute="@form" render="@form" />
        </h:commandButton>      
        <h:commandButton type="button" value="Action2" action="#{page1.action2}">
            <f:ajax execute="@form" render="@form" />
        </h:commandButton>
        <h:commandButton type="button" value="Action3" action="#{page1.action3}">
            <f:ajax execute="@form" render="@form" />
        </h:commandButton>

</h:form>

Note that this does not happen when the button type is not set or is set to "submit. It looks like this behavior was introduced with Mojarra 2.1.14.

Has anyone seen this before? Are there any considerations for removing the type="button" from these buttons, especially in regards to the request lifecycle (i.e - validation)?

Ali Cheaito
  • 3,746
  • 3
  • 25
  • 30
  • 1
    Despite this behaviour could be considered a bug in the framework, the `type="button"` is not intended to invoke an action method in the server side. It's generally used for invoking some client side related code, normally javascript. So in this case, this attribute is unecessary and misused. – Aritz Jul 25 '14 at 21:45
  • Makes sense. So the bug was in pre 2.1.14 in that it allowed this to work properly. The framework should throw an error though to prevent such code. – Ali Cheaito Jul 30 '14 at 17:45

1 Answers1

0

JAVASERVERFACES-3351 filed and addressed

Ali Cheaito
  • 3,746
  • 3
  • 25
  • 30