IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
  • 1.  Validation Error

    Posted Mon February 22, 2016 12:38 PM

    Hi everyone

    I have some issues with my validation messages since I use 9.7 instead of 7.1.3.

    If I set on my text input field required = true. The validation message shows the id of the text input field. Is it possible to remove this id in the validation message?

    My other problem is with a custom validator. In 9.7 the mws set to the validation message the css class “portlet-msg-info” instead of “portlet-msg-alert”. So the message is grey and not red like the is required message.

    I hope someone can help me with this topic.

    Kind regards
    Andrin
    standardvalidation.png


    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 2.  RE: Validation Error

    Posted Mon February 22, 2016 01:28 PM

    The default “required” message uses this pattern: “{0}: Validation Error: Value is required.” Where {0} is replaced by the label associated with that input control. If no label attribute is specified, then it uses the clientId as the label.

    Alternatively, JSF 2.x supports supplying your own custom message via the “requiredMessage” property of the input control that is used instead of the default message.

    For your custom validator, can you provide a snippet of how you are raising the ValidatorException? The FacesMessage you pass to the ValidatorException constructor has the ability to specify the Severity (see [1]).

    1. [url]FacesMessage (JavaServer Faces API (2.0))

    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 3.  RE: Validation Error

    Posted Wed February 24, 2016 05:32 AM

    Thank you for your fast reply.

    Do you know if it’s possible to change the pattern of the default message?

    This is my snippet from the custom validator.

    throw new ValidatorException(new FacesMessage(msg));

    msg is a String with a localized message.


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 4.  RE: Validation Error

    Posted Wed February 24, 2016 01:00 PM

    Supplying your own custom message via the “requiredMessage” property of the control is the best practice way of changing the message as it would ensure that both the client-side validation and server-side validation use your custom text.

    I haven’t tested this, but you may try raising the ValidatorException with a different severity (the default is FacesMessage.SEVERITY_INFO) with something like this to affect how it is displayed:

    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));

    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 5.  RE: Validation Error

    Posted Wed February 24, 2016 01:24 PM

    Of course that would be a solution but than I have to change every text input that is required. I will try to avoid this because I have tons of portlets :roll:

    So maybe someone has an idea to change the default is required message. I found that post [url]https://mobiarch.wordpress.com/2013/07/18/user-friendly-validation-error-message-in-jsf-2/[/url] but for my portlet that solution doesn’t work.

    The problem with the custom validation is solved. Thank you for your help.


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 6.  RE: Validation Error

    Posted Wed February 24, 2016 01:26 PM

    Well, sometimes you’ll have to actually do some work.


    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 7.  RE: Validation Error

    Posted Thu February 25, 2016 10:01 AM

    I found a solution for my problem.

    Add

    javax.faces.component.UIInput.REQUIRED =Validation Error: Value is required.

    to the AppResources.properties to customize the “is required” message.

    So I have to adjust every portlet but this is easier than to modify every single text input field.


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS