1

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.

Matt
  • 144
  • 15
  • Have you tried converting `action` into `actionListener`? – WoAiNii Jun 08 '23 at 07:21
  • As far as i can see the commandbutton would always process the whole form. Try using process="@this" – Pascal P. Jun 09 '23 at 08:53
  • @WoAiNii changing into actionListener didn't work – Matt Jun 09 '23 at 14:31
  • @PascalP. process="@this" also didn't solve the issue – Matt Jun 09 '23 at 14:31
  • 1
    @Matt it is impossible for me to tell from your code why its closing your modal. Can you put together a small PrimeFaces Test reproducer showing the issue: https://github.com/primefaces/primefaces-test – Melloware Jun 12 '23 at 12:44
  • @Melloware I wasn't able to reproduce the problem in a separate project, I've tried, believe me, can't share the code either because it has too much company code – Matt Jun 13 '23 at 13:39
  • 1
    That stinks but I understand. Makes it impossible for me to help! – Melloware Jun 13 '23 at 20:10
  • You can workaround by oncomplete=myModalWidgetVar.show() ? Also you can specify update in button? – Nikola Jun 15 '23 at 13:06

0 Answers0