We have a specific test about Interpolator usage...Please try to recreate
your problem and if you can recreate it with the last released version,
please create a new JIRA ticket attaching the test.
Thanks.

2009/2/16 Gustavo Ringel <[email protected]>

> Can you open a JIRA with a failing test which fails with the trunk? Follow
> Fabio's link to the JIRA
>
>
> On Mon, Feb 16, 2009 at 10:28 AM, Gustavo Ringel <[email protected]
> > wrote:
>
>> Which version of NHV are you using?
>>
>>
>> On Mon, Feb 16, 2009 at 9:30 AM, knut <[email protected]> wrote:
>>
>>>
>>> In my previous reply I showed you that I have implemented my own
>>> IMessageInterpolator. My implementation of the IMessageInterpolator
>>> (EntityMessageInterpolator) is supposed to return "Hello World!" for
>>> all interpolations. I have also configured NHV to use my
>>> EntityMessageInterpolator as you can see in my pasted code. The
>>> problem is that I never see the validation message "Hello World!".
>>>
>>>  - What am I doing wrong?
>>>  - Do you know of any documentation regarding the interpolation
>>> mechanism? I have not been able to find any.
>>>  - Should I take a look at the Java version to learn how it is
>>> supposed to be done?
>>>
>>> On 16 Feb, 01:07, Fabio Maulo <[email protected]> wrote:
>>> > This is the example I'm talking about  public class
>>> > PrefixMessageInterpolator : IMessageInterpolator
>>> > {
>>> > public string Interpolate(string message, IValidator validator,
>>> > IMessageInterpolator defaultInterpolator)
>>> > {
>>> > return "prefix_" + defaultInterpolator.Interpolate(message, validator,
>>> > defaultInterpolator);
>>> >
>>> > }
>>> > }
>>> >
>>> > The JIRA is thishttp://jira.nhforge.org/
>>> >
>>> > 2009/2/15 knut <[email protected]>
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > I tried to use a custom interpolator:
>>> >
>>> > > ...
>>> > >    public class EntityMessageInterpolator : IMessageInterpolator
>>> > >    {
>>> > >        public string Interpolate(string message, IValidator
>>> > > validator,
>>> > >            IMessageInterpolator defaultInterpolator)
>>> > >        {
>>> > >            return "Hello World!";
>>> > >        }
>>> > >    }
>>> > > ...
>>> > > ...
>>> > >                    // NHibernate Validation...
>>> > >                    NHVConfiguration nhvConfiguration = new
>>> > > NHVConfiguration();
>>> > >                    nhvConfiguration.Properties.Add(
>>> >
>>> > > NHibernate.Validator.Cfg.Environment.ValidatorMode,
>>> > >                        "UseAttribute");
>>> > >                    nhvConfiguration.Properties.Add
>>> > > (NHibernate.Validator.Cfg.
>>> > >                        Environment.MessageInterpolatorClass,
>>> > >                        typeof(EntityMessageInterpolator).
>>> > >                        AssemblyQualifiedName);
>>> > >                    nhvConfiguration.Mappings.Add(new
>>> > >                        MappingConfiguration(GetEntityAssemblyName(),
>>> > > null));
>>> > >                    ValidatorEngine engine = new ValidatorEngine();
>>> > >                    engine.Configure(nhvConfiguration);
>>> > >                    ValidatorInitializer.Initialize(configuration,
>>> > > engine);
>>> > > ...
>>> >
>>> > > Questions:
>>> >
>>> > > 1) I was expecting to get the validation message "Hello World!" for
>>> > > all validations, but I get the default ones. What am I missing?
>>> > > 2) What do you mean by "use our JIRABTW NHV accept custom
>>> > > ResourceManager"?
>>> > > 3) I want to use different validation messages for the same type of
>>> > > validation in different entitites. Example: For the Name property in
>>> a
>>> > > Person class with a NotNullNotEmpty constraint I would like to say:
>>> > > "You need to specify a name for the person...". For the Name property
>>> > > in a Employee class with a NotNullNotEmpty constraint I would like to
>>> > > say: "The employee needs a name...". Is this possible with the
>>> > > ResourceManager approach?
>>> >
>>> > > <span style="color:gray;font-size:80%;">Need to know if HTML is
>>> > > enabled&hellip;</span>
>>> >
>>> > > On 15 Feb, 22:30, Fabio Maulo <[email protected]> wrote:
>>> > > > 1) in theory you don't need to do nothing because we are hosting
>>> > > translation
>>> > > > for various languages; if you have a new one use our JIRABTW NHV
>>> accept
>>> > > > custom ResourceManager... we only need to add a configuration
>>> property
>>> >
>>> > > > 2) an example of a simple custom interpolator is in our tests
>>> > > > (see PrefixMessageInterpolator). The Message interpolator can be
>>> > > configured
>>> > > > (is one of the properties of NHV configuration)
>>> >
>>> > > > 2009/2/15 knut <[email protected]>
>>> >
>>> > > > > I want to be able to read validation messages from resource
>>> files. I
>>> > > > > think I need to choose one of these solutions:
>>> >
>>> > > > > "Alternatively you can provide a ResourceManager while checking
>>> > > > > programmatically the validation rules on a bean or if you want a
>>> > > > > completly different interpolation mechanism, you can provide an
>>> > > > > implementation of
>>> NHibernate.Validator.Engine.IMessageInterpolator."
>>> > > > > ---http://nhforge.org/doc/nhv/en/:3.3. Error messages
>>> >
>>> > > > > The problem is that I don't know how to do what has been
>>> suggested.
>>> >
>>> > > > > 1) How do I provide a new ResourceManager?
>>> > > > > 2) How do I provide an implementation of
>>> > > > > NHibernate.Validator.Engine.IMessageInterpolator
>>> >
>>> > > > > Best regards!
>>> > > > > Knut
>>> >
>>> > > > --
>>> > > > Fabio Maulo
>>> >
>>> > --
>>> > Fabio Maulo
>>>
>>>
>>
>
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to