user3091996
user3091996

Reputation:

How to prevent primefaces commandbutton from closing the modal

I have a modal that displays a table with some fields. In two columns, I added a feedback button that alters that registers the user's feedback about something in the business. However, when the user clicks the button, the modal is closed, which is not the behavior I want. I want the user to be able to give their feedback without the modal closing, but for some reason the action of clicking the button closes the modal, in addition to the desired behavior. The frontend is JSF, the button is PrimeFaces commandButton. The modal is a separate xhtml.

Button code inside modal code:

<td>
    <p:commandButton
        action="#{businessBean.setBusinessFeedback(param1, param2)}"
        styleClass="fa fa-thumbs-up"
        style="color: #{businessBean.chooseColor(param1)};"
        global="false">
    </p:commandButton>
</td>

And here is the code where the modal is added:

<b:modal id="business-modal-id" title="#{msg['business.label']}" styleClass="business-modal" rendered="#{menuBean.canEdit()}" style="z-index: 9999;">
    <b:row id="business-modal-content-id">
        <ui:include src="/businesses/business-edit-modal-redacted.xhtml"/>
    </b:row>
</b:modal>

I've tried adding global="false" as a button property to avoid triggering a global ajax request, I've also already tried adding onclick="event.stopPropagation()" to avoid propagating an update to a parent element. Any help/insights would be appreciated.

Upvotes: 1

Views: 87

Answers (0)

Related Questions