You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lbastil <ba...@gmx.de> on 2007/10/24 16:22:25 UTC
[S2] validation annotation problem
I use model driven actions and want to use validation by annotation.
so I have somethings like:
@Validation
public Class ...Action implements ...{
...
@VisitorFieldValidator(message = "", appendPrefix = false)
public TestModel getModel() {
return testModel;
}
...
in the model class TestModel I have:
@Validation
@Entity
@Table(name = "...")
public class TestModel implements IPersistable {
...
@VisitorFieldValidator(message = "")
public void setSubModel(SubModel subModel) {
this.subModel = subModel;
}
...
(beside validation you see some hibernate annotations)
Now the problem I see when debugging (JBoss 4.0.3SP1) is:
the first VisitorFieldValidator is recognized correctly, but within the
TestModel class no annotations at all are found!
when I write a simple unit tests which does pretty the same then in the
validation annotation logic of struts2 / xwork, I get the annotation!
What is difference / problem here?
the units tests found the Annotation (size of array = 1),
debugging real application shows size = 0
(yes I am sure I have deployed the same class which is used in Unit Test)
Part of Unit Tests (which works) is:
@Test
public void testGetAnnotation() {
TestModel testModel = new TestModel();
Method[] methods = testModel.getClass().getDeclaredMethods();
for (Method method : methods) {
if(method.getName().equals("setSubModel")){
System.out.println("method: " + method.getName());
Annotation[]annotations = method.getAnnotations();
System.out.println("annotation size: " +
annotations.length);
}
}
}
Any help highly appreciated,
thank you in davance
--
View this message in context: http://www.nabble.com/-S2--validation-annotation-problem-tf4684043.html#a13384745
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] validation annotation problem
Posted by lbastil <ba...@gmx.de>.
please help on this issue.
does nobody have any hints?
Thank you in advance,
basti
lbastil wrote:
>
> I use model driven actions and want to use validation by annotation.
>
> so I have somethings like:
>
> @Validation
> public Class ...Action implements ...{
>
> ...
>
> @VisitorFieldValidator(message = "", appendPrefix = false)
> public TestModel getModel() {
> return testModel;
> }
>
> ...
>
> in the model class TestModel I have:
>
> @Validation
> @Entity
> @Table(name = "...")
> public class TestModel implements IPersistable {
> ...
>
> @VisitorFieldValidator(message = "")
> public void setSubModel(SubModel subModel) {
> this.subModel = subModel;
> }
> ...
>
> (beside validation you see some hibernate annotations)
>
> Now the problem I see when debugging (JBoss 4.0.3SP1) is:
>
> the first VisitorFieldValidator is recognized correctly, but within the
> TestModel class no annotations at all are found!
>
> when I write a simple unit tests which does pretty the same then in the
> validation annotation logic of struts2 / xwork, I get the annotation!
>
> What is difference / problem here?
> the units tests found the Annotation (size of array = 1),
> debugging real application shows size = 0
> (yes I am sure I have deployed the same class which is used in Unit Test)
>
> Part of Unit Tests (which works) is:
>
> @Test
> public void testGetAnnotation() {
> TestModel testModel = new TestModel();
>
> Method[] methods = testModel.getClass().getDeclaredMethods();
> for (Method method : methods) {
> if(method.getName().equals("setSubModel")){
> System.out.println("method: " + method.getName());
> Annotation[]annotations = method.getAnnotations();
> System.out.println("annotation size: " +
> annotations.length);
> }
> }
> }
>
> Any help highly appreciated,
> thank you in davance
>
--
View this message in context: http://www.nabble.com/-S2--validation-annotation-problem-tf4684043.html#a13466737
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org