Sunday 15 January 2012

jsf 2 - Prevent confirmation dialogue from opening when there's a validation error -


I have a text area inside a tab in the Eordion panel, which is a description. I am trying to edit and save a description. I am validating the text field so that the maximum character does not exceed 1000 characters. To display the verification message I & lt; P: Message & gt; before being saved, a confirmed conversation will be shown to confirm the save.

  & lt; P: Message showDetail = "true" autoupdate = "true" /> & Lt; P: accordionPanel dynamic = "true" & gt; & Lt; P: tab id = "_ 0" header = "description" & gt; & Lt; P: inputTextarea styleClass = "max" id = "editDesc1" widgetVar = "txtBox" value = "# {testBean.description}" rows = "6" cols = "150" validator message = "# {msg.AddSystem_validationMsg5}" autoresize = "False" & gt; & Lt; F: validateLength max = "1000" & gt; & Lt; / F: Valid Lang & gt; & Lt; / P: inputTextarea & gt; & Lt; P: command button value = "save" incomplete = "saveDialog.show ()" /> & Lt; P: confirmDialog message = "# {msg.EditSystem_confirmMsg1}" width = "200" showEffect = "explosion" hide effect = "explosion" header = "confirm" seriousness = "alert" widgetVar = "saveDialog" & gt; & Lt; P: command button value = "# {msg.EditSystem_confirmAnswer1}" action = "# {testBean.saveEdit}" process = "@ this" /> & Lt; P: command button value = "# {msg.EditSystem_confirmAnswer2}" onclick = "saveDialog.hide ()" type = "button" />   

If a user enters more than 1000 characters and tries to save it, the verification message appears for a short time and then the confirmation dialogue pops, The message disappears. How do I stop confirmation talks when popping up a verification error?

You must check if the verification has failed, then the incomplete In. In the primaryface javascript scope, enter the global args objects in which a boolean validationFailed is the property you can use:

  & lt ; P: value of the command button = "save" incomplete = "If (RGS & amp;! Args.validationFailed) saveDialog.show ()" />   

This confirmation dialog will only be shown if the verification has not failed.

No comments:

Post a Comment