You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kleanthis <kl...@gmail.com> on 2011/08/12 09:26:19 UTC

Tapestry and JSR-303

Hello all. I am facing a problem and have not been able to find a solution. I
want to integrate JSR-303 with tapestry 2.5.6.
The problem is that some of my beans/entities come from a diferent domain
model, so i cannot annotate them with tapestry's @validate annotation.
That's why i want to annotate them with JSR-303 annotations. 

Steps I have taken so far are: 

added dipedencies:

<dependency>
	<groupId>org.apache.tapestry</groupId>
	<artifactId>tapestry-beanvalidator</artifactId>
	<version>${tapestry-release-version}</version>
</dependency>
to gain acess to bean validator

<dependency>
	<groupId>org.apache.bval</groupId>
	<artifactId>org.apache.bval.bundle</artifactId>
	<version>0.3-incubating</version>
</dependency>

<dependency>
	<groupId>org.apache.poi</groupId>
	<artifactId>poi</artifactId>
	<version>3.6</version>
	<scope>runtime</scope>
</dependency>
and these two are the implementation of JSR-303 from apache

in my appmodule :

 public static void contributeBeanValidatorSource(
		      OrderedConfiguration<BeanValidatorConfigurer> conf) {
		      BeanValidatorConfigurer configurer = new BeanValidatorConfigurer() {
		         @Override
				public void configure(
		             javax.validation.Configuration<?> aConf) {
		            aConf.ignoreXmlConfiguration();
		         }
		      };
		      conf.add("MyConfigurer", configurer);
		   }

and in my card bean 

...
@NotNull
@NotEmpty
@Min(value=1,message="asfdsafdasd")
private Integer cardId;
...

and the tml is 

....
 <form t:type="form" t:id="createCardForm" validate="this">
....
 <tr>
	      		<td><t:label for="cardId"/></td>
	      		<td><input t:type="TextField" t:id="cardId"
t:label="${message:cardId}*"  value="card.cardId"  size="22"/</td>	  		
</tr>

this however does not work.Any ideas why?


-----
Do not confuse motion for action.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-and-JSR-303-tp4692368p4692368.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry and JSR-303

Posted by Igor Drobiazko <ig...@gmail.com>.
You placed the annotations on the card bean, but you are passing the page
instance to the form's validate parameter (validate="this"). That's why the
validator doesn't see any validation constrains.

On Fri, Aug 12, 2011 at 9:26 AM, kleanthis <kl...@gmail.com> wrote:

> Hello all. I am facing a problem and have not been able to find a solution.
> I
> want to integrate JSR-303 with tapestry 2.5.6.
> The problem is that some of my beans/entities come from a diferent domain
> model, so i cannot annotate them with tapestry's @validate annotation.
> That's why i want to annotate them with JSR-303 annotations.
>
> Steps I have taken so far are:
>
> added dipedencies:
>
> <dependency>
>        <groupId>org.apache.tapestry</groupId>
>        <artifactId>tapestry-beanvalidator</artifactId>
>        <version>${tapestry-release-version}</version>
> </dependency>
> to gain acess to bean validator
>
> <dependency>
>        <groupId>org.apache.bval</groupId>
>        <artifactId>org.apache.bval.bundle</artifactId>
>        <version>0.3-incubating</version>
> </dependency>
>
> <dependency>
>        <groupId>org.apache.poi</groupId>
>        <artifactId>poi</artifactId>
>        <version>3.6</version>
>        <scope>runtime</scope>
> </dependency>
> and these two are the implementation of JSR-303 from apache
>
> in my appmodule :
>
>  public static void contributeBeanValidatorSource(
>                      OrderedConfiguration<BeanValidatorConfigurer> conf) {
>                      BeanValidatorConfigurer configurer = new
> BeanValidatorConfigurer() {
>                         @Override
>                                public void configure(
>                             javax.validation.Configuration<?> aConf) {
>                            aConf.ignoreXmlConfiguration();
>                         }
>                      };
>                      conf.add("MyConfigurer", configurer);
>                   }
>
> and in my card bean
>
> ...
> @NotNull
> @NotEmpty
> @Min(value=1,message="asfdsafdasd")
> private Integer cardId;
> ...
>
> and the tml is
>
> ....
>  <form t:type="form" t:id="createCardForm" validate="this">
> ....
>  <tr>
>                        <td><t:label for="cardId"/></td>
>                        <td><input t:type="TextField" t:id="cardId"
> t:label="${message:cardId}*"  value="card.cardId"  size="22"/</td>
> </tr>
>
> this however does not work.Any ideas why?
>
>
> -----
> Do not confuse motion for action.
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Tapestry-and-JSR-303-tp4692368p4692368.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Re: Tapestry and JSR-303

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 12 Aug 2011 09:13:22 -0300, Igor Drobiazko  
<ig...@gmail.com> wrote:

> The tapestry-beanvalidator module doesn't has a dependency to any
> implementation of the JSR 303. The app developer needs to choose one and
> drop it on the classpath.  So, the dependency to org.apache.bval.bundle  
> is correct.

Thanks for the info, Igor! I stand corrected.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry and JSR-303

Posted by Igor Drobiazko <ig...@gmail.com>.
On Fri, Aug 12, 2011 at 1:45 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:
>
>
> You don't need these dependencies, as Tapestry-BeanValidator already uses
> Hibernate Validator 4 for that.
>
>
The tapestry-beanvalidator module doesn't has a dependency to any
implementation of the JSR 303. The app developer needs to choose one and
drop it on the classpath.  So, the dependency to org.apache.bval.bundle is
correct.


-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Re: Tapestry and JSR-303

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 12 Aug 2011 04:26:19 -0300, kleanthis <kl...@gmail.com> wrote:

> Hello all.

Hi!

> I am facing a problem and have not been able to find a solution. I want  
> to integrate JSR-303 with tapestry 2.5.6.
> The problem is that some of my beans/entities come from a diferent domain
> model, so i cannot annotate them with tapestry's @validate annotation.
> That's why i want to annotate them with JSR-303 annotations.

You don't need @Validate. Just add the Tapestry-BeanValidator JAR into  
your classpath.

> <dependency>
> 	<groupId>org.apache.bval</groupId>
> 	<artifactId>org.apache.bval.bundle</artifactId>
> 	<version>0.3-incubating</version>
> </dependency>
>
> <dependency>
> 	<groupId>org.apache.poi</groupId>
> 	<artifactId>poi</artifactId>
> 	<version>3.6</version>
> 	<scope>runtime</scope>
> </dependency>
> and these two are the implementation of JSR-303 from apache

You don't need these dependencies, as Tapestry-BeanValidator already uses  
Hibernate Validator 4 for that. There may be a conflict between the two  
JSR 303 implementations. Please remove them org.apache.bval.bundle and try  
again.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry and JSR-303

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 12 Aug 2011 06:19:31 -0300, nillehammer  
<ta...@winfonet.eu> wrote:

> Hi kleanthis,
>
> try t:value="card.cardId" instead of value="card.cardId".

I prefer to use the t: prefix in any parameter which isn't a normal  
attribute of the HTML tag used, but it won't make any difference for  
Tapestry.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry and JSR-303

Posted by kleanthis <kl...@gmail.com>.
I changed value to t:value and nothing changed. It seems tapestry cannot
create the necessary validators for the annotations. Removed @NotEampty from
the variable. It was left there while expirementing. Any other ideas? 
Did anyone got this to work at least?

-----
Do not confuse motion for action.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-and-JSR-303-tp4692368p4692904.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry and JSR-303

Posted by nillehammer <ta...@winfonet.eu>.
Hi kleanthis,

try t:value="card.cardId" instead of value="card.cardId". And the annotation
@NotEmpty is not necessary in my opinion.



-----
http://www.winfonet.eu
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-and-JSR-303-tp4692368p4692609.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org