Saturday, 15 June 2013

jsf - Display a dynamic message on p:confirmDialog without sending a request to the server -


me & lt; P: confirmDialog & gt; Need to display a confirmation message dynamically on This can be done by updating this component with AJAX after sending the request to the server. For example,

  & lt; P: column selection mode = "multiple" & gt; & Lt; F: aspect names = "footer" & gt; & Lt; P: CommandButton oncomplete = "confirmDeleteMultiple.show ()" Update = ": Appearance: confirmDialogDeleteMultiple" Process = ": Appearance: DataTable" ActionListener = "# {bean.deleteMultipleActionListener}" /> & Lt; / Ch: Aspect & gt; & Lt; / P: column & gt;   

The button on the lt footer, P: DataTable & gt; can update the message that is set in deleteMultipleActionListener (ActionEvent actionEvent) {...} and the updated confirmation dialog, confirmDialogDeleteMultiple Type is

  & lt; P:. ConfirmDialog ID = "confirmDialogDeleteMultiple" widgetVar = "confirmDeleteMultiple" Message = "# {bean.deleteMultipleMsg}" header = "header message" appendobody = "true" close-up = "true" & gt; & Lt; P: CommandButton id = "confirmDeleteMultiple" value = "yes" process = "@ this DataTable message" sang = "# {bean.renderedYesButtonMultipleDelete}" update = "DataTable Data" oncomplete = "confirmDeleteMultiple.hide ()" ActionListener = "# {Bean.deleteMultiple} "/> & Lt; P: CommandButton id = "declineDeleteMultiple" value = "# {bean.noButtonTextMultipleDelete}" onclick = "confirmDeleteMultiple.hide ()" type = "button" /> & Lt; / P: confirmDialog & gt;   

Managed Bean just looks like the following.

  @ManagedBean @RequestSecoped Public Ultimate Category Been {Personal String Removed MultipleMsg; // Gates only sang private boolean YESButtonMultipleDelete = true; //Geters Only Private String noButtonTextMultipleDelete = "No"; // GETS Only Public Zero DeleteMultipleActionListener (ActionEvent actionEvent) {if (selectedValues ​​= Null & amp;!! SelectedValues.isEmpty ()) {rendered YesButtonMultipleDelete = true noButtonTextMultipleDelete = "no"; DeleteMultipleMsg = "Confirmation message."; } And {noButtonTextMultipleDelete = "OK"; Rendered YesButtonMultipleDelete = false; DeleteMultipleMsg = "Line Selection Message."; }}}   

selected value is a list that contains the selected rows in the DataTable . deleteMultipleMsg is a message that is & lt; P: confirmDialog & gt; On an AJAX is displayed after request.


There is no question in it. It works as expected, so, I do not find it in length.

Nevertheless, to get a simple confirmation message, I need to send an AJAX request to the server. I think it is quite unnecessary

Therefore, I do this on client-side I'm exploring a way to do that, maybe using it, javascript confirmation ("message") with the usual JavaScript code OK and cancel / Code> As confirmation, can it be done as usual?

I am using Primeface 3.5. Now this is the final 4.0. Now it's 5.1 final.

The simple function is enough for you:

  & lt; Script & gt; JQuery ("confirmDeleteMultiple.p"). ReplaceWith (... & lt; / script & gt;    

No comments:

Post a Comment