How to display a confirmation dialog(Primefaces) from backing bean

前端 未结 4 1614
名媛妹妹
名媛妹妹 2021-01-12 12:04

I have an import function which will parse the XML file which contains the version information of the document and save it in database. If user try to upload the already exi

相关标签:
4条回答
  • 2021-01-12 12:33

    You are facing in typical Primefaces Problem.

    When your page is displayed and buttonBean.showConfirm = false, this element is not rendered. This means, it will not appear in the DOM-Tree. No matter what you do afterwards, a non existing element cannot be shown or hidden.

    There are actually two ways to solve you problem.

    1. Use a remote command, so that the not rendered HTML-Code will be transmitted from you server.
    2. Use css "display: none" instead of rendered="false".
    0 讨论(0)
  • 2021-01-12 12:39

    I faced very similar question. The solution I came up with was to split the logic into 2 - first, when the button is pressed use 'action' to prepare the data for the validation and use 'oncomplete' to run a remote command which displays the confirmation dialog in which 'OK' is the real action.

    0 讨论(0)
  • 2021-01-12 12:49

    Case

    Validate that there is a selected item by pressing the Delete button. If you open a popup, if not shown in the error message, growl.

    Alternative: (Sorry I had trouble posting the code)

    XHTML: View xhtml

    TestManageBean: Manage bean

    MORE INFO: www.primefaces.org/showcase/ui/dialogLogin.jsf

    0 讨论(0)
  • 2021-01-12 12:51

    It's not possible to get confirmation from the client during processing on server.

    You have two options:

    1. Get overwrite permission before calling your action method e.g. with a checkbox "Overwrite file if exists?" or

    2. You have to stop processing, set a flag and return null to reload current page in browser. Then you could display the p:dialog depending on flag status.

    0 讨论(0)
提交回复
热议问题