Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 46655 invoked from network); 27 Sep 2007 12:08:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Sep 2007 12:08:23 -0000 Received: (qmail 12701 invoked by uid 500); 27 Sep 2007 12:08:06 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 12655 invoked by uid 500); 27 Sep 2007 12:08:06 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 12626 invoked by uid 99); 27 Sep 2007 12:08:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2007 05:08:06 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2007 12:08:15 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0320E71420C for ; Thu, 27 Sep 2007 05:07:55 -0700 (PDT) Message-ID: <27513707.1190894875010.JavaMail.jira@brutus> Date: Thu, 27 Sep 2007 05:07:55 -0700 (PDT) From: "Thomas Fischer (JIRA)" To: dev@myfaces.apache.org Subject: [jira] Updated: (MYFACES-1734) In a custom validator method, the Message in the thrown ValidatorException is not used In-Reply-To: <293177.1190894873726.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MYFACES-1734?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Fischer updated MYFACES-1734: ------------------------------------ Status: Patch Available (was: Open) > In a custom validator method, the Message in the thrown ValidatorException is not used > -------------------------------------------------------------------------------------- > > Key: MYFACES-1734 > URL: https://issues.apache.org/jira/browse/MYFACES-1734 > Project: MyFaces Core > Issue Type: Bug > Components: General > Affects Versions: 1.2.0 > Reporter: Thomas Fischer > > Situation: A custom validator is defined in a jsp, e.g. > > The error message from validation is displayed on the same page by . For testing reasons, the validate method always throws an error: > public void validate(FacesContext context, UIComponent component, Object value) > { > FacesMessage message > = new FacesMessage(FacesMessage.SEVERITY_ERROR, "message summary", "message detail"); > throw new ValidatorException(message); > } > Expected behaviour: After a form submit, the error message "message summary" should be displayed by the tag. > Observed behaviour: An empty message is displayed by the tag. > Reason: in javax.faces.validator.MethodExpressionValidator#validate(FacesContext, UIComponent, Object), all ELExceptions are caught, and a ValidationException with a empty message is thrown. This empty message is then displayed by > Resolution: The original ValidatorException is still contained as cause of the ElException. This is required by the contract of MethodExpression.invoke: > > ... throws ELException - if an exception was thrown while performing property or variable resolution. The thrown exception must be included as the cause property of this exception, if available... > > So one should retrieve the cause of the ELException and check whether it is a ValidatorException. If yes, the cause(containing the original message) should be rethrown. If no, the error is not a validation error but something else, then the ELException should be rethrown (Reason for this: In the current implementation, if another error (no validation error) occurs, e.g. the user mistypes the method name in the jsp, no exception stack trace is displayd but only an empty faces message is added. It is very difficult to find the error. Re-throwing the EL exception removes this problem.) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.