You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shale.apache.org by "Wendy Smoak (JIRA)" <ji...@apache.org> on 2006/11/06 23:24:57 UTC

[jira] Created: (SHALE-325) Add a custom validation example to the Use Cases example app

Add a custom validation example to the Use Cases example app
------------------------------------------------------------

                 Key: SHALE-325
                 URL: http://issues.apache.org/struts/browse/SHALE-325
             Project: Shale
          Issue Type: Improvement
          Components: Validator
            Reporter: Wendy Smoak
            Priority: Minor
             Fix For: 1.0.4-SNAPSHOT


Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (SHALE-325) Add a custom validation example to the Use Cases example app

Posted by "Gary VanMatre (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/struts/browse/SHALE-325?page=comments#action_38603 ] 
            
Gary VanMatre commented on SHALE-325:
-------------------------------------

I think your problem is that the CommonsValidator can't find the message.
There are a couple of places that you can register a custom message.
You can load the resource bundle within the page and use the msg attribute.


<val:commonsValidator
                   type="evenInteger"
                   msg="#{messages['validate.test.not.even']}"
                   server="true"
                   client="false"/>


-- or ---

Register the resource bundle in the faces-config.xml

<application>
    <locale-config>
      <default-locale>en</default-locale>
      <supported-locale>en</supported-locale>
      <supported-locale>fr</supported-locale>
      <supported-locale>de</supported-locale>
      <supported-locale>es</supported-locale>
    </locale-config>

    <message-bundle>org.apache.shale.usecases.view.Bundle</message-bundle>
</application>



> Add a custom validation example to the Use Cases example app
> ------------------------------------------------------------
>
>                 Key: SHALE-325
>                 URL: http://issues.apache.org/struts/browse/SHALE-325
>             Project: Shale
>          Issue Type: Improvement
>          Components: Validator
>            Reporter: Wendy Smoak
>            Priority: Minor
>             Fix For: 1.0.4-SNAPSHOT
>
>
> Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (SHALE-325) Add a custom validation example to the Use Cases example app

Posted by "Craig McClanahan (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/struts/browse/SHALE-325?page=all ]

Craig McClanahan resolved SHALE-325.
------------------------------------

    Resolution: Fixed

Looks like no other comments, so I'll go ahead and close this as FIXED.



> Add a custom validation example to the Use Cases example app
> ------------------------------------------------------------
>
>                 Key: SHALE-325
>                 URL: http://issues.apache.org/struts/browse/SHALE-325
>             Project: Shale
>          Issue Type: Improvement
>          Components: Validator
>            Reporter: Wendy Smoak
>            Priority: Minor
>             Fix For: 1.0.4-SNAPSHOT
>
>
> Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (SHALE-325) Add a custom validation example to the Use Cases example app

Posted by "Wendy Smoak (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/struts/browse/SHALE-325?page=comments#action_38605 ] 
            
Wendy Smoak commented on SHALE-325:
-----------------------------------


The error message key is specified in the rule itself, in custom-rules.xml.

   <global>
       <validator name="evenInteger"
             classname="org.apache.shale.usecases.validator.CustomValidationUtil"
             method="isEven"
             methodParams="int"
             msg="validate.test.not.even">
       </validator>
   </global>

There is no <message-bundle> tag in faces-config, and adding it didn't help.

The attribute for val:commonsValidator is 'message' (not msg).  Adding that fixes the NPE, but see above-- the message is specified in the rule, I shouldn't have to say it again.

What do I need to do so that CommonsValidator.getErrorMessage can "see" the resource bundle?


> Add a custom validation example to the Use Cases example app
> ------------------------------------------------------------
>
>                 Key: SHALE-325
>                 URL: http://issues.apache.org/struts/browse/SHALE-325
>             Project: Shale
>          Issue Type: Improvement
>          Components: Validator
>            Reporter: Wendy Smoak
>            Priority: Minor
>             Fix For: 1.0.4-SNAPSHOT
>
>
> Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (SHALE-325) Add a custom validation example to the Use Cases example app

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/struts/browse/SHALE-325?page=comments#action_38607 ] 
            
Rahul Akolkar commented on SHALE-325:
-------------------------------------

Try again, it works for me. And adding <message-bundle> should, since the method in question looks up the application's message bundle for the "msg" attribute of (in this case, the custom) <validator>. The "message" attribute of <val:commonsValidator> gets priority, if present (which is nice, since it allows to change the "default" error message for the custom, or "built-in", validator).

On a separate note, we could do better than an NPE here, let me take a stab at that.


> Add a custom validation example to the Use Cases example app
> ------------------------------------------------------------
>
>                 Key: SHALE-325
>                 URL: http://issues.apache.org/struts/browse/SHALE-325
>             Project: Shale
>          Issue Type: Improvement
>          Components: Validator
>            Reporter: Wendy Smoak
>            Priority: Minor
>             Fix For: 1.0.4-SNAPSHOT
>
>
> Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (SHALE-325) Add a custom validation example to the Use Cases example app

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/struts/browse/SHALE-325?page=comments#action_38796 ] 
            
Rahul Akolkar commented on SHALE-325:
-------------------------------------

Per my last comment, I've committed a fix for this (one of Gary's suggestions), see:
  http://svn.apache.org/viewvc?view=rev&rev=476703
If there are no other comments in a couple of days, I will resolve this issue.


> Add a custom validation example to the Use Cases example app
> ------------------------------------------------------------
>
>                 Key: SHALE-325
>                 URL: http://issues.apache.org/struts/browse/SHALE-325
>             Project: Shale
>          Issue Type: Improvement
>          Components: Validator
>            Reporter: Wendy Smoak
>            Priority: Minor
>             Fix For: 1.0.4-SNAPSHOT
>
>
> Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (SHALE-325) Add a custom validation example to the Use Cases example app

Posted by "Wendy Smoak (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/struts/browse/SHALE-325?page=comments#action_38601 ] 
            
Wendy Smoak commented on SHALE-325:
-----------------------------------

See:  http://svn.apache.org/viewvc?view=rev&rev=471907

This is incomplete.  I added a third section on the 'Commons Validator Integration' page.  If you enter an odd number for 'Priority', you get:

java.lang.NullPointerException
	java.text.MessageFormat.applyPattern(MessageFormat.java:414)
	java.text.MessageFormat.<init>(MessageFormat.java:368)
	org.apache.shale.validator.CommonsValidator.getErrorMessage(CommonsValidator.java:965)
	org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:849)
	javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:157)
	javax.faces.component.UIInput.validateValue(UIInput.java:312)
	javax.faces.component.UIInput.validate(UIInput.java:353)
	javax.faces.component.UIInput.processValidators(UIInput.java:183)
	javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
	javax.faces.component.UIForm.processValidators(UIForm.java:70)
	javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
	javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
	javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:146)
	org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:262)
	org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
	org.apache.shale.application.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:267)



> Add a custom validation example to the Use Cases example app
> ------------------------------------------------------------
>
>                 Key: SHALE-325
>                 URL: http://issues.apache.org/struts/browse/SHALE-325
>             Project: Shale
>          Issue Type: Improvement
>          Components: Validator
>            Reporter: Wendy Smoak
>            Priority: Minor
>             Fix For: 1.0.4-SNAPSHOT
>
>
> Add an example of using a custom validator to the Commons Validator  Integration section of the  use-cases example app.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira