[ExtVal]Custom error messages

View: New views
2 Messages — Rating Filter:   Alert me  

[ExtVal]Custom error messages

by Ricardo Rog :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello,

 

I’m using Extval with Trinidad. It works fine but I have one problem:

I don’t want to use the ExtVal annotations in my entities, so I set the required fields with

JPA annotations like this:    

@Column(nullable = false, length = 20)

      private String someString;

 

My trinidad tags looks like this:

 

<tr:inputText value=”#{someBean.someEntity.someString}” label=”some String” />

 

Now I want to add a custom error message for this field if the required validation fails. I know that Trinidad has a requiredMessageDetail property for that but it doesn’t work here. How can this be done?

 

Thank you

 

Ricardo Rog


Parent Message unknown Re: [ExtVal]Custom error messages

by Gerhard Petracek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hello,

if you are using the client-side validation feature of trinidad, it should just work as expected.
(extval just initializes the component and marks it as required (in such a case). it doesn't change the behavior of trinidad)

if you are using server-side validation only:
here are 3 of the easiest approaches to do it:

#1) provide a custom and global required message for jpa annotations
      an example which illustrates one of the possibilities to do that is available at [1]
#2) write a custom ValidationExceptionInterceptor which changes the message
      you have access to a reference to the component - so you will get all information of it
#3) use the advanced meta-data add-on to keep your entities clean [2]
      (or implement a similar custom add-on (it's quite easy))

regards,
gerhard

[1] http://code.google.com/p/os890/source/browse/#svn/tags/java/web/jsf/extval/examples_1.2.2/basic/demo_001
[2] http://os890.blogspot.com/2009/06/myfaces-extval-add-on-advanced-metadata.html

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2009/10/9 Ricardo Rog <ricardo.rog@...>

Hello,

 

I’m using Extval with Trinidad. It works fine but I have one problem:

I don’t want to use the ExtVal annotations in my entities, so I set the required fields with

JPA annotations like this:    

@Column(nullable = false, length = 20)

      private String someString;

 

My trinidad tags looks like this:

 

<tr:inputText value=”#{someBean.someEntity.someString}” label=”some String” />

 

Now I want to add a custom error message for this field if the required validation fails. I know that Trinidad has a requiredMessageDetail property for that but it doesn’t work here. How can this be done?

 

Thank you

 

Ricardo Rog