Qeustions about SortedSet and ListMultipleChoice (with and without Metagen)

2011-12-09 Thread Jablow, Eric R
In my project, for business reasons, we have classes with SortedSet members. 
The classes and their elements are all Serializable.  I'm having trouble 
working with a SortedSetMantechControl object; when I try creating a 
ListMultipleChoiceMantechControl object for it (and putting it into a 
FormComponentPanelSortedSetMantechControl), I get all sorts of compilation 
problems.  The MantechControlPanel has constructor:

   public MantechControlPanel(String id,
IModelSortedSetMantechControl model) {
super(id, model);
control = new ListMultipleChoiceMantechControl(
choices, new SetModelNonICDisseminationControl(choices),
choiceList, new ChoiceRendererMantechControl(
banner));
add(control);
onModelChanged();
}

The onModelChanged() method has (after I extracted some local objects in a 
futile attempt to fix things):

@Override
protected void onModelChanged() {
super.onModelChanged();
if (getModelObject()!= null) {
   control.setModel(getModel());
}

The problem is that the control.setModel() expects a Model of a Collection, 
while getModel() returns a  Model of a SortedSet:

The method setModel(IModelCollection MantechControl ) in the type 
FormComponentCollection MantechControl  is not applicable for the arguments 
(IModelSortedSet MantechControl ). I have good business reasons to use a 
sorted set, and what I think are good reasons to use a FormComponentPanel and a 
ListMultipleChoice. But should I do something different?

Meanwhile, I've created a wicket/metagen quickstart project and am running into 
a similar problem  there.  I can upload the project somewhere if you want more 
info.  Here I wrote a class ColorfulPerson that has a String name and a 
SortedSetColor colors.  In trying to write a FormComponentPanel for this, I 
have an obvious error at the indicated line:

public class ColorfulPersonPanel extends FormComponentPanelColorfulPerson {
private static final long serialVersionUID = -457616015428125432L;
private final FormComponentString name;
private final FormComponentCollectionColor colors;
private ListColor colorChoices = Arrays.asList(Color.values());
public ColorfulPersonPanel(String id, IModelColorfulPerson model) {
super(id, model);
name = new TextFieldString(name, new ModelString());
add(name);
colors = new ListMultipleChoiceColor(colors, new 
SetModelColor(), colorChoices);
add(colors);
onModelChanged();
}
@Override
protected void onModelChanged() {
super.onModelChanged();
ColorfulPerson colorfulPerson = getModelObject();
if (colorfulPerson != null) {

name.setModel(MetaModel.of(colorfulPerson).get(ColorfulPersonMeta.name));

colors.setModel(MetaModel.of(colorfulPerson).get(ColorfulPersonMeta.colors));
// Error as the model is one of 
SortedSetColor while the ListMultipleChioice expects a model of 
CollectionColor.

} else {
name.setModelObject(null);
colors.setModelObject(null);
}
}

Could there be a MetaModel.as(Class? castingClass) method?

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


RE: ValidationForm.addPropertyValidators sometimes looks for child properties in parent's model

2011-11-21 Thread Jablow, Eric R

Igorbut you can create a testcase, reproducing the bare bits of code in a
testcase just like you did in the email below. the advantage would be
that i would have something i can play with which makes it much easier
to find the problem.

I will work on a quick start tonight, when I'm not at work. But here's what I'd 
like to do, possibly extending Metagen. I have a Report object which includes 
an abstract Document object.  Document has 3 concrete subclasses, Book, 
Article, and Monograph. I have FormComponentPanels for each, which I'd like to 
swap in and out. I've used Metagen to create ReportMeta, DocumentMeta, 
BookMeta, etc.  I'd like to extend Metagen so I can write code like

IModelBook bookModel = 
MetaModel.of(report).get(ReportMeta.document).as(Book.class);

and

IModelString isbnModel = 
MetaModel.of(report).get(ReportMeta.document).as(Book.class).get(BookMeta.isbn);

Since I don't want to modify the MetaModel class on my own, I've written a 
SubClassModel class like so:

private static class SubClassModelT extends MetaModelT {
private static final long serialVersionUID = 
3511732306311269529L;

public SubClassModel(MetaModel? super T superModel, ClassT 
clazz) {
super(superModel);
}

@Override
public T getObject() {
return (T) super.getObject();
}
@Override
public void detach() {
super.detach();
}

public static T MetaModelT as(MetaModel? super T 
superModel, ClassT clazz) {
return new SubClassModelT(superModel, clazz);
}
}
}

Unfortunately, when the validation system gets its hands on this, it throws a 
NPE as it adds the property validators:

Caused by: java.lang.NullPointerException
at 
net.ftlines.wicket.validation.bean.ReflectableProperty.init(ReflectableProperty.java:46)
at 
net.ftlines.wicket.validation.bean.ReflectableProperty.init(ReflectableProperty.java:98)
at 
net.ftlines.wicket.validation.bean.ModelPropertyResolver.resolve(ModelPropertyResolver.java:35)
at 
net.ftlines.wicket.validation.bean.ValidationContext.resolveProperty(ValidationContext.java:80)
at 
net.ftlines.wicket.validation.bean.ValidationForm$1.component(ValidationForm.java:170)
at 
net.ftlines.wicket.validation.bean.ValidationForm$1.component(ValidationForm.java:163)
at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143)
at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:122)
at 
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:908)
at 
net.ftlines.wicket.validation.bean.ValidationForm.addPropertyValidators(ValidationForm.java:162)
at 
net.ftlines.wicket.validation.bean.ValidationForm.onBeforeRender(ValidationForm.java:155)
at org.apache.wicket.Component.internalBeforeRender(Component.java:981)
at org.apache.wicket.Component.beforeRender(Component.java:1015)
at 
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1785)
... 52 more

This happens when Model is that SubclassModelBook.

How would you use Metagen for this case?  Is it worth extending it?

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Added issue for assertFeedback

2011-11-19 Thread Jablow, Eric R
I've just submitted issue WICKET-4246 for the problem I found where 
WicketTester.assertFeedback required the actual feedback messages to be the 
expected messages in their exact order. Since the ftlines validation project 
through the Hibernate validator project returns messages in an unspecified and 
nondeterministic order, testing for the existence of messages is not very 
useful.

I'd provide a patch, but I'm not sure what is more Wicket-y; have 
assertFeedback compare a sorted version of the expected messages to a sorted 
version of the actual messages, or to add a 
WicketTester.assertFeedbackInAnyOrder method.

I did later attach a Maven quickstart project. This has a test class with two 
methods, one of which will fail in each run; the one that does cannot be 
predicted.

Respectfully,
Eric Jablow
This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: ValidationForm.addPropertyValidators sometimes looks for child properties in parent's model

2011-11-18 Thread Jablow, Eric R
Dear Igor,

(me) I get a call with expression being child, and target being the local 
test object.  Were expression parent.child, this would succeed, as it would 
call getParent().getChild(). However, I'm not sure whether this is my bug or 
the wicket-validation-bean library's.

(Igor)this is probably a misuse of the compound property model, which is
evil anyways. you have to create your components with ids that match
the path from the root object, so if you want to access person.address
property you cant put a text field with id address into a
webmarkupcontainer of id person, you have to add a text field with
component id person.address

I'm sorry that I can't send or post the problematic code; much of it is 
proprietary. Here's a censored précis.

I have a Report object for people to fill out. Report has a variable of type 
Publication, Publication being an interface.

public class Report implements Serializable {
@Valid
private Publication publication;
}

public interface Publication extends Serializable {}

public class Book implements Publication {}
public class Article implements Publication {}
public class Monograph implements Publication()

I have UI panels:

public class BookPanel extends FormComponentPanelBook {}
public class ArticlePanel extends FormComponentPanelArticle {}
public class MonographPanel extends FormComponentPanelMonograph {}

I'm trying to create a PublicationPanel:

public class PublicationPanel extends FormComponentPanelPublication {
private RadioChoiceString publicationTypeChoice;
private FormComponentPanel? extends Publication 
specificPublicationPanel;
}

I will swap a BookPanel, ArticlePanel, and MonographPanel in depending on the 
user's choice of type. If CompoundPropertyModels are evil (and I'd like a 
pointer to why), how can I take a IModelReport and turn it into a 
IModelPublication and IModelBook, and so on?  Does the metagen project 
handle the polymorphism?

Should I be using the single-argument constructor of FormComponentPanelT at 
all? Does it matter if I need to use the PublicationPanel more than once in the 
ReportForm?

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Metagen configuration issue

2011-11-18 Thread Jablow, Eric R
I've cut and pasted the Metagen configuration listed in 
https://github.com/42Lines/metagen into my project pom, and these declarations 
are generating the metamodels twice: in target/generated-sources/annotations, 
and in target/metamodel. What must I do to cut out one of the metamodel 
locations?  I'm a Maven novice.

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


RE: Metagen configuration issue

2011-11-18 Thread Jablow, Eric R
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Friday, November 18, 2011 2:21 PM
To: users@wicket.apache.org
Subject: Re: Metagen configuration issue

try removing the configuration block of the maven-processor-plugin and
change the source location of the helper plugin to
generated-sources/annotations

---

This didn't work.  Now, I have two identical directories, 
generated-sources/annotations, and generated-sources/apt.

I cleaned my project, and then I replaced generated-sources/annotations with 
generated-sources/apt in the build-helper-maven-plugin. That failed, so I put 
generated-sources/apt in the maven-processor-plugin. I still have 
generated-sources/annotations and generated-sources/apt

Eric
.
This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: Metagen configuration issue

2011-11-18 Thread Jablow, Eric R


-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Friday, November 18, 2011 2:43 PM
To: users@wicket.apache.org
Subject: Re: Metagen configuration issue

very strange. we are using the configuration on the github page and
its working great here.

try using the original configuration and add version2.0.5/version
to the maven processor plugin, maybe you are just using an old one.

also add this into your pom so you can get to 2.0.5

I think it's the version of the build-helper-maven-plugin.  You have 1.3.  I 
was using the latest, 1.7.  I just switched to 1.3 and ran. Now, a build gives 
me generated-sources/apt and target/generated-sources/annotations.

I then switched back to 1.7, and I removed the build-helper plugin. The 
maven-processor-plugin usage page claims that 

Sources will be generated into target/generated-sources/apt/main/java. 
Test sources into target/generated-sources/apt/test/java Both directories will 
be added to the compilation path

One thing we're missing is the code on the usage page:

plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-compiler-plugin/artifactId
configuration
compilerArgument-proc:none/compilerArgument
/configuration
/plugin

Perhaps the compiler was running the annotation processor itself.  And, it 
works!  So, with later versions of the compiler plugin, you need to keep it 
from running the annotation processor itself.

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: Metagen configuration issue

2011-11-18 Thread Jablow, Eric R

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Friday, November 18, 2011 4:04 PM
To: users@wicket.apache.org
Subject: Re: Metagen configuration issue

sweet, thanks. i will add it to the readme

-igor

 plugin
        groupIdorg.apache.maven.plugins/groupId
        artifactIdmaven-compiler-plugin/artifactId
        configuration
                compilerArgument-proc:none/compilerArgument
        /configuration
 /plugin

 Perhaps the compiler was running the annotation processor itself.  And, it 
 works!  So, with later versions of the compiler plugin, you need to keep it 
 from running the annotation processor itself.

 Respectfully,
 Eric Jablow

Note that Eclipse users will be unhappy unless one adds this to the pom:

plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-eclipse-plugin/artifactId
version2.8/version
configuration
sourceIncludestarget/generated-sources/apt/sourceIncludes
/configuration
/plugin

I have no idea about other IDEs.  Perhaps the plugin I removed would have 
handled that.

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Debugging a NPE from a ModelPropertyResolver

2011-11-17 Thread Jablow, Eric R
I am trying to use Igor's wicket-validation-bean project, and I've managed to 
make a mistake where I'm getting a NullPointerException from when 
ValidationForm attempts to add property validators. Unfortunately, I can't tell 
what property it's trying to attach validators for here, as the exception 
message does not say. Is there any way I can get a more useful message?  The 
stack trace of the cause is

(The resulting stack trace has proprietary information)

Caused by: java.lang.NullPointerException
at 
net.ftlines.wicket.validation.bean.ReflectableProperty.init(ReflectableProperty.java:46)
at 
net.ftlines.wicket.validation.bean.ReflectableProperty.init(ReflectableProperty.java:98)
at 
net.ftlines.wicket.validation.bean.ModelPropertyResolver.resolve(ModelPropertyResolver.java:35)
at 
net.ftlines.wicket.validation.bean.ValidationContext.resolveProperty(ValidationContext.java:80)
at 
net.ftlines.wicket.validation.bean.ValidationForm$1.component(ValidationForm.java:170)
at 
net.ftlines.wicket.validation.bean.ValidationForm$1.component(ValidationForm.java:163)
at 
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143)
at 
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:122)
at 
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:908)
at 
net.ftlines.wicket.validation.bean.ValidationForm.addPropertyValidators(ValidationForm.java:162)
at 
net.ftlines.wicket.validation.bean.ValidationForm.onBeforeRender(ValidationForm.java:155)
at 
org.apache.wicket.Component.internalBeforeRender(Component.java:981)
at org.apache.wicket.Component.beforeRender(Component.java:1015)
at 
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1785)
... 56 more

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


ValidationForm.addPropertyValidators sometimes looks for child properties in parent's model

2011-11-17 Thread Jablow, Eric R
I have some model classes with JSR 303 validation annotations, and I have some 
FormComponentPanels for each. Some of these will be nested. To test that the 
Wicket validation is correct, I'm creating a ValidationForm, which contains one 
of my panels, which contains another of my panels, and I am tying my form to a 
local minimal test object without the other fields I will be using later. I am 
using a CompoundPropertyModel. When I have the WicketTester initialize the 
ValidationForm, it looks for the 'parent' field in the minimal test object, 
which does exist.  Then, I get at line 302 of AbstractPropertyModel,

  return PropertyResolver.getPropertyGetter(expression, target);

I get a call with expression being child, and target being the local test 
object.  Were expression parent.child, this would succeed, as it would call 
getParent().getChild(). However, I'm not sure whether this is my bug or the 
wicket-validation-bean library's.

Incidentally, I'm getting an interesting misfeature from the validation; the 
order in which the validations are performed seems to be nondeterministic. This 
means that the test below fails sometimes.

tester.assertFeedback(path:to:panel, new String[] {messageA, 
messageB});

Often, when I reverse the order of messageA and messageB, the next test fails 
too! Perhaps Wicket 1.5.3 can have WicketTester.assertFeedback(String path, 
SetString messages).

Finally, I might need to avoid FormComponentPanels in the future, as some of 
the inner ones will be swapped in and out of the page depending on the user's 
choices.  I realize that the only panels that will be instrumented are the ones 
in the Form when it is originally configured.

Thanks in advance.

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


RE: Debugging a NPE from a ModelPropertyResolver

2011-11-17 Thread Jablow, Eric R
No, we are using only the stock models, I think. In any case, the particular 
test class uses CompoundPropertyModel.

From: Igor Vaynberg [igor.vaynb...@gmail.com]
Sent: Thursday, November 17, 2011 7:24 PM
To: users@wicket.apache.org
Subject: Re: Debugging a NPE from a ModelPropertyResolver

it seems like there is a buggy implementation of
IPropertyReflectionAwareModel somewhere. did you implement your own
model that implements that interface? seems like there is a model
somewhere that is a IPropertyReflectionAwareModel but it returns null
for all getSetter/Getter/Field() methods...

i will add an exception so it will be easier to flag where this is
happenning, maybe you can try with a snapshot

-igor
This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Configuration problem with net.ftlines.wicket-bean-validation

2011-11-16 Thread Jablow, Eric R
First, let me thank Igor Vaynberg for being so responsive updating the 
net.ftlines.wicket-bean-validationhttp://mvnrepository.com/artifact/net.ftlines.wicket-bean-validation
 project.

I still have one final problem configuring it. I have a test that checks that 
setting a field to a value that violates an @Size constraint should fail 
validation. I get the following stacktrace:

codeMustBeAtMost4Chars(com.example.wicket.components.classification.CategoryPanelTest)
  Time elapsed: 0.344 sec   ERROR!
org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface 
org.apache.wicket.markup.html.form.IFormSubmitListener targeted at 
[ValidationForm [Component id = form]] on component [ValidationForm [Component 
id = form]] threw an exception
  at 
org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:270)
  at 
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
  at 
org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
  at 
org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
  at 
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:750)
  at 
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
  at 
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:252)
  at 
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:209)
  at 
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:280)
  at 
org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:626)
  at 
org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:546)
  at 
org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:518)
  at 
org.apache.wicket.util.tester.BaseWicketTester.submitForm(BaseWicketTester.java:1900)
  at org.apache.wicket.util.tester.FormTester.submit(FormTester.java:755)
  at 
com.example.wicket.components.classification.CategoryPanelTest.codeMustBeAtMost4Chars(CategoryPanelTest.java:81)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
  at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
  at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
  at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
  at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
  at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
  at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
  at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
  at 
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
  at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
  at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
  at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
  at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at 

RE: Configuration problem with net.ftlines.wicket-bean-validation

2011-11-16 Thread Jablow, Eric R
From: Martin Grigorov [mailto:mgrigo...@apache.org] 

Hi,

Looking at the stacktrace I think you should add this line to Wicket's 
resource bundle. Just add it to YourApplication.properties and it should be 
fine.

That must be it. The library project tries to get its validation messages via 
the standard Wicket mechanisms. This does not know about the Hibernate 
Validator's scheme.  So, I'' copy my custom messages and the ones from the 
Hibernate validator jar into the application properties file.  I hope 
WicketTester can figure it out.

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


RE: Configuration problem with net.ftlines.wicket-bean-validation

2011-11-16 Thread Jablow, Eric R


From: Martin Grigorov [mailto:mgrigo...@apache.org] 
Hi,

Looking at the stacktrace I think you should add this line to Wicket's 
resource bundle. Just add it to YourApplication.properties and it should be 
fine.

I'm a lot closer to fine, now. However, I think I've exposed a usability 
problem with the net.ftlines.wicket-bean-validation project. I put  the 
Hibernate validation properties into the WicketTester's application in the test 
class (since it does not recognize the properties from the surrounding web 
project):

@BeforeClass
public static void initValidation() {
conf = new ValidationConfiguration();
}

@Before
public void initTester() {
tester = new WicketTester();
WebApplication application = tester.getApplication();
ListIStringResourceLoader stringResourceLoaders = 
application.getResourceSettings().getStringResourceLoaders();
// My custom messages from a project this depends on.
stringResourceLoaders.add(new 
BundleStringResourceLoader(ValidationMessages));
// The messages from the Hibernate Validator jar.
stringResourceLoaders.add(new 
BundleStringResourceLoader(org.hibernate.validator.ValidationMessages));
conf.configure(application);
tester.startPanel(NCategoryTestPanel.class);
formTester = tester.newFormTester(form);
}

When this validates a field that violates an @Size(min=3, max=4) annotation, 
the message that comes out is:
size must be between {min} and {max}

The Hibernate validator running on its own interpolates the values of min and 
max from the annotation, and it would give the error message.
size must be between 3 and 4
I'm verified that in testing of the POJOs and their HibernateValidator. I do 
have to suggest that the messages somehow be obtained from the Hibernate 
Validator framework, and not from pure Wicket. Also, the validator can be 
driven either by annotations or by an XML file, and so one cannot depend on the 
annotations to actually exist.

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


WicketStuff JSR-303 validation breaks in WicketTester

2011-11-15 Thread Jablow, Eric R
I'm trying to use the wicketstuff.org JSR-303 validation project to use 
Hibernate Validator in my
newish Wicket project.

I have a FormComponentPanel with a model object set up for JSR-303 validation, 
but we are
using vanilla Wicket Validators for it.  To test the FormComponentPanel, I 
wrote a test panel
which includes a form, which includes the FormComponentPanel.  When I add the 
WicketStuff
PropertyValidation behavior to the test panel (which I then use with a 
WicketTester
based JUnit test class):

//CategoryTestPanel
FormMarking form = new FormMarking(form, new 
CompoundPropertyModelMarking(marking));
form.add(new PropertyValidation());
add(form);
form.add(new CategoryPanel(category));
form.add(new Button(submit));

and

//CategoryPanelTest
@Before
public void initTester() {
  tester = new WicketTester();
  tester.startPanel(CategoryTestPanel.class);
  formTester = tester.newFormTester(form);
}

I get this exception:

org.apache.wicket.WicketRuntimeException: Cannot modify component hierarchy 
after render phase has started (page version cant change then anymore)
at 
org.apache.wicket.Component.checkHierarchyChange(Component.java:3521)
at 
org.apache.wicket.Component.addStateChange(Component.java:3450)
at org.apache.wicket.Behaviors.add(Behaviors.java:62)
at org.apache.wicket.Component.add(Component.java:4431)
at 
org.apache.wicket.markup.html.form.FormComponent.add(FormComponent.java:490)
at 
org.wicketstuff.jsr303.PropertyValidation.addValidator(PropertyValidation.java:76)
at 
org.wicketstuff.jsr303.PropertyValidation.access$000(PropertyValidation.java:17)
at 
org.wicketstuff.jsr303.PropertyValidation$JSR303ValidatorFormComponentVisitor.component(PropertyValidation.java:32)
at 
org.wicketstuff.jsr303.PropertyValidation$JSR303ValidatorFormComponentVisitor.component(PropertyValidation.java:22)
***redacted***

Note that vlaidators are already being added to the FormComponentPanel object, 
and they work fine. Where should I add the validation behavior? Is there a 
better JSR303 library to use (inside a public Maven repository)?

Respectfully,
Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.


RE: WicketStuff JSR-303 validation breaks in WicketTester

2011-11-15 Thread Jablow, Eric R
I took your advice and I am trying to use this project. I have some teething 
pains.

See https://github.com/42Lines/wicket-bean-validation
http://repo1.maven.org/maven2/net/ftlines/wicket-bean-validation/


I removed the wicketstuff.org jsr303 repository and added the ftlines one. I 
also noticed on the github site that it requires Wicket 1.5.2 and so I switched 
to that. When I checked the dependencies, I saw that the ftlines library 
depends on Wicket 1.4.18, which surprises me a little, especially because its 
parent depends on 1.5-SNAPSHOT. I set the test class by configuring its 
validation in a @Before method:

@BeforeClass
public static void initValidation() {
conf = new ValidationConfiguration();
}

@Before
public void initTester() {
tester = new WicketTester();
conf.configure(tester.getApplication());

tester.startPanel(CategoryTestPanel.class);
formTester = tester.newFormTester(form);
}

In the CategoryTestPanel, I created the Form as a ValidationForm. I received 
the following stack trace:

java.lang.NoSuchMethodError: 
net.ftlines.wicket.validation.bean.ValidationForm.visitChildren(Ljava/lang/Class;Lorg/apache/wicket/Component$IVisitor;)Ljava/lang/Object;
at 
net.ftlines.wicket.validation.bean.ValidationForm.addPropertyValidators(ValidationForm.java:160)
at 
net.ftlines.wicket.validation.bean.ValidationForm.onBeforeRender(ValidationForm.java:153)
at org.apache.wicket.Component.internalBeforeRender(Component.java:980)

I think the method may have disappeared between 1.4.18 and 1.5.

Then, I excluded the Wicket dependency from the ftlines library:

dependency
groupIdnet.ftlines.wicket-bean-validation/groupId
artifactIdcore/artifactId
version1.0/version
scopecompile/scope
exclusions
exclusion
artifactIdwicket/artifactId
groupIdorg.apache.wicket/groupId
/exclusion
/exclusions
/dependency
Now, I get this stack trace:

categoryStartsNull(gov.ic.dodiis.capco.wicket.components.category.CategoryPanelTest)
  Time elapsed: 0 sec   FAILURE!
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:48)
at 
org.apache.wicket.util.tester.BaseWicketTester.startComponentInPage(BaseWicketTester.java:1291)
at 
org.apache.wicket.util.tester.BaseWicketTester.startPanel(BaseWicketTester.java:1242)
at gov.ic.dodiis.capco.wicket.components. 
category.CategoryPanelTest.initTester(NonUSClassificationPanelTest.java:37)
***REDACTED***

I debugged to find that the fail comes from a NoClassDefFoundError:
java.lang.NoClassDefFoundError: org/apache/wicket/Component$IVisitor

In fact, I Visitor is an independent interface in 1.5. What is the proper way 
to set up my application?

Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.