You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@tu-dortmund.de> on 2011/01/06 10:59:37 UTC
5.2: How to handle deprecated ValidationMessagesSource
Hi!
Our migration to Tapestry 5.2 was very smooth with only a few glitches.
Now I am trying to resolve the last deprecation issues and stumbled upon
ValidationMessagesSource. I am using it like this:
validationMessages.getValidationMessages(locale).format("required",
fieldName));
I fetched this usage from FieldTranslatorSourceImpl but the one shipped
with Tapestry 5.2 still uses the deprecated ValidationMessagesSource.
According to the JavaDoc I should use ComponentMessagesSource but I
cannot figure out how to get the same output.
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by 9902468 <vi...@greenstreet.fi>.
This question has bugged me too. Anyone?
- Ville
--
View this message in context: http://tapestry.1045711.n5.nabble.com/5-2-How-to-handle-deprecated-ValidationMessagesSource-tp3330209p3330248.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: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 07.01.2011 11:14, Stephan Windmüller wrote:
>> However, if you contribute the ValidationMessages to
>> ComponentMessagesSource they're kind of cached twice in the system. I
>> looked up the path, try this:
>> String path = "org/apache/tapestry5/internal/ValidationMessages.properties"
> Thank you very much, I will try it.
Works perfectly, thanks again!
- Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 07.01.2011 11:02, Christian Riedel wrote:
> Ah ok, now I'm with you!
Good. :)
> I don't know the reason why you need to build the original messages
> yourself (why don't you let Tapestry build them?).
Tapestry does not support to disable client validation for some submit
buttons.
Imagine a page with a list of rows and a button to add more rows. I do
not want the Tapestry validation to trigger every time a row is inserted
for the rest of the form, so I have to do validation myself when the
correct submit button is selected. For this I am needing the validation
messages.
> However, if you contribute the ValidationMessages to
> ComponentMessagesSource they're kind of cached twice in the system. I
> looked up the path, try this:
>
> String path = "org/apache/tapestry5/internal/ValidationMessages.properties"
Thank you very much, I will try it.
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Christian Riedel <cr...@googlemail.com>.
Ah ok, now I'm with you!
The ValidationMessages bundle isn't contributed to the "global" messages (ComponentMessagesSource). Seems they can only be found if you use the old service directly. Since Tapestry is using this class internally there's no proper replacement for accessing these properties with a replacement service.
I don't know the reason why you need to build the original messages yourself (why don't you let Tapestry build them?). Any customization must be contributed in the way I proposed a mail earlier.
However, if you contribute the ValidationMessages to ComponentMessagesSource they're kind of cached twice in the system. I looked up the path, try this:
...
String path = "org/apache/tapestry5/internal/ValidationMessages.properties"
...
Am 07.01.2011 um 10:40 schrieb Stephan Windmüller:
> On 07.01.2011 10:32, Christian Riedel wrote:
>
>> Of course not, that should be the path to your validation.properties
>> that you would've had added with the ValidationMessages instead. Put
>> your properties somewhere under [...]
>
> I did not add any custom properties to ValidationMessages in the first
> place. All I want to do is have access to the standard validation
> messages of tapestry, in this case the one for "required".
>
> Regards
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 07.01.2011 10:32, Christian Riedel wrote:
> Of course not, that should be the path to your validation.properties
> that you would've had added with the ValidationMessages instead. Put
> your properties somewhere under [...]
I did not add any custom properties to ValidationMessages in the first
place. All I want to do is have access to the standard validation
messages of tapestry, in this case the one for "required".
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Christian Riedel <cr...@googlemail.com>.
Of course not, that should be the path to your validation.properties that you would've had added with the ValidationMessages instead. Put your properties somewhere under src/main/resources and set the path relative to that directory (src/main/java works as well as long as the directory is in the classpath...)
You just specify the base bundle, so no need to add customMessages_en.properties as well. Tapestry'll find them.
Am 07.01.2011 um 09:22 schrieb Stephan Windmüller:
> On 06.01.2011 21:54, Christian Riedel wrote:
>
>> Never used ValidationMessages but I can tell you how I add additional resources:
>
> Thanks, this looks exactly like that what I need. But the code does not
> work, "validation.properties" is not found. Is this not the one shipped
> with tapestry?
>
> Regards
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 06.01.2011 21:54, Christian Riedel wrote:
> Never used ValidationMessages but I can tell you how I add additional resources:
Thanks, this looks exactly like that what I need. But the code does not
work, "validation.properties" is not found. Is this not the one shipped
with tapestry?
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.2: How to handle deprecated ValidationMessagesSource
Posted by Christian Riedel <cr...@googlemail.com>.
Never used ValidationMessages but I can tell you how I add additional resources:
public static void contributeComponentMessagesSource(OrderedConfiguration<Resource> additionalBundles, TypeCoercer typeCoercer) {
String path = "validation.properties";
final Resource resource = typeCoercer.coerce(path, Resource.class);
if (resource.exists()) {
additionalBundles.add(key, resource);
} else {
// log or throw exceptions if you like
}
}
...
@Inject
private Messages messages;
...
messages.format("required", fieldName);
et voilá :-)
Am 06.01.2011 um 10:59 schrieb Stephan Windmüller:
> Hi!
>
> Our migration to Tapestry 5.2 was very smooth with only a few glitches.
> Now I am trying to resolve the last deprecation issues and stumbled upon
> ValidationMessagesSource. I am using it like this:
>
> validationMessages.getValidationMessages(locale).format("required",
> fieldName));
>
> I fetched this usage from FieldTranslatorSourceImpl but the one shipped
> with Tapestry 5.2 still uses the deprecated ValidationMessagesSource.
>
> According to the JavaDoc I should use ComponentMessagesSource but I
> cannot figure out how to get the same output.
>
> Regards
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org