You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Štefan Šimík <st...@gmail.com> on 2015/12/27 19:27:39 UTC
Properties file for *.jar full of custom validators
I have separate *.jar containing custom form-component validators.
(in the *.jar file, there are only validators - no other Components, no
WebPage(s),
no WebApplication)
MY QUESTION:
Which *.properties file should I create for these validators, so the
validator classes
and their default messages can be contained together in one *.jar?
Re: Properties file for *.jar full of custom validators
Posted by Štefan Šimík <st...@gmail.com>.
Thank you Tobias - you spotted the right problem and it works now.
Problem was, really default behavior in copying resources by maven.
After fixing that, everything works now as expected.
Thank you guys - Martin, Tobias for your precious time and help!
To help others with same problem:
There is one cause why my validation messages did not work: *.properties
files were missing in final *.jar artifact
And there are 2 possible solutions how to fix that:
1. Put *.utf8.properties file for wicket into
src/main/resources/yourpackage/YourValidator.utf8.properties
2. or put the same properties file directly near your validator *.java
file, but then you need to instruct Maven to copy these resources into
final artifact, because by default it skips them.
- Put the XML below into your pom.xml.
<build>
<!-- MAIN RESOURCES: COPY FILES OTHER THAN *.java -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<filtering>false</filtering>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<!-- TEST RESOURCES: COPY FILES OTHER THAN *.java -->
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
<testResource>
<directory>src/test/java</directory>
<filtering>false</filtering>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
On Mon, Dec 28, 2015 at 5:40 AM, Tobias Soloschenko <
tobiassoloschenko@googlemail.com> wrote:
> Hi,
>
> did you put the properties in src/main/java or src/main/resources?
>
> You have to but it into resources if no additional maven settings are
> applied.
>
> So create a package with the same name in resources and name the
> properties file the same as the class
>
> src/main/java/my/package/MyValidator.java
> src/main/resources/my/package/MyValidator.properties
>
> kind regards
>
> Tobias
>
> > Am 27.12.2015 um 21:24 schrieb Štefan Šimík <st...@gmail.com>:
> >
> > Thank you for tip Martin ...
> > I tried both YourValidator.properties or YourValidator.utf8.propertiesit
> > right now, but the feedback message was empty string ("") in both cases.
> >
> > I found one working solution:
> > Call setMessage(...) on validator, which provides validation message, if
> no
> > key is found in properties files.
> >
> > But solution with using standard *.properties file would be still nicer
> for
> > me, if possible.
> >
> > On Sun, Dec 27, 2015 at 8:25 PM, Martin Grigorov <
> martin.grigorov@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I don't have my IDE with me now, so I can't verify but
> >> YourValidator.properties staying next to YourValidator.class should
> work.
> >>> On Dec 27, 2015 8:28 PM, "Štefan Šimík" <st...@gmail.com>
> wrote:
> >>>
> >>> I have separate *.jar containing custom form-component validators.
> >>> (in the *.jar file, there are only validators - no other Components, no
> >>> WebPage(s),
> >>> no WebApplication)
> >>>
> >>> MY QUESTION:
> >>> Which *.properties file should I create for these validators, so the
> >>> validator classes
> >>> and their default messages can be contained together in one *.jar?
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Properties file for *.jar full of custom validators
Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,
did you put the properties in src/main/java or src/main/resources?
You have to but it into resources if no additional maven settings are applied.
So create a package with the same name in resources and name the properties file the same as the class
src/main/java/my/package/MyValidator.java
src/main/resources/my/package/MyValidator.properties
kind regards
Tobias
> Am 27.12.2015 um 21:24 schrieb Štefan Šimík <st...@gmail.com>:
>
> Thank you for tip Martin ...
> I tried both YourValidator.properties or YourValidator.utf8.propertiesit
> right now, but the feedback message was empty string ("") in both cases.
>
> I found one working solution:
> Call setMessage(...) on validator, which provides validation message, if no
> key is found in properties files.
>
> But solution with using standard *.properties file would be still nicer for
> me, if possible.
>
> On Sun, Dec 27, 2015 at 8:25 PM, Martin Grigorov <ma...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I don't have my IDE with me now, so I can't verify but
>> YourValidator.properties staying next to YourValidator.class should work.
>>> On Dec 27, 2015 8:28 PM, "Štefan Šimík" <st...@gmail.com> wrote:
>>>
>>> I have separate *.jar containing custom form-component validators.
>>> (in the *.jar file, there are only validators - no other Components, no
>>> WebPage(s),
>>> no WebApplication)
>>>
>>> MY QUESTION:
>>> Which *.properties file should I create for these validators, so the
>>> validator classes
>>> and their default messages can be contained together in one *.jar?
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Properties file for *.jar full of custom validators
Posted by Štefan Šimík <st...@gmail.com>.
Thank you for tip Martin ...
I tried both YourValidator.properties or YourValidator.utf8.propertiesit
right now, but the feedback message was empty string ("") in both cases.
I found one working solution:
Call setMessage(...) on validator, which provides validation message, if no
key is found in properties files.
But solution with using standard *.properties file would be still nicer for
me, if possible.
On Sun, Dec 27, 2015 at 8:25 PM, Martin Grigorov <ma...@gmail.com>
wrote:
> Hi,
>
> I don't have my IDE with me now, so I can't verify but
> YourValidator.properties staying next to YourValidator.class should work.
> On Dec 27, 2015 8:28 PM, "Štefan Šimík" <st...@gmail.com> wrote:
>
> > I have separate *.jar containing custom form-component validators.
> > (in the *.jar file, there are only validators - no other Components, no
> > WebPage(s),
> > no WebApplication)
> >
> > MY QUESTION:
> > Which *.properties file should I create for these validators, so the
> > validator classes
> > and their default messages can be contained together in one *.jar?
> >
>
Re: Properties file for *.jar full of custom validators
Posted by Martin Grigorov <ma...@gmail.com>.
Hi,
I don't have my IDE with me now, so I can't verify but
YourValidator.properties staying next to YourValidator.class should work.
On Dec 27, 2015 8:28 PM, "Štefan Šimík" <st...@gmail.com> wrote:
> I have separate *.jar containing custom form-component validators.
> (in the *.jar file, there are only validators - no other Components, no
> WebPage(s),
> no WebApplication)
>
> MY QUESTION:
> Which *.properties file should I create for these validators, so the
> validator classes
> and their default messages can be contained together in one *.jar?
>