New Posts New Posts RSS Feed: Localization Clarification
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Localization Clarification

 Post Reply Post Reply
Author
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Topic: Localization Clarification
    Posted: 21-Jan-2011 at 5:29pm
It should if you have override the validation attributes using the metadata buddy class and regenerated your code.
Back to Top
yimbot View Drop Down
Newbie
Newbie


Joined: 15-Jan-2011
Posts: 10
Post Options Post Options   Quote yimbot Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jan-2011 at 5:06pm
Thanks, I look forward to the release.

Do you know if the implementation I have described above will work as it is?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jan-2011 at 10:21am
Hi yimbot;

I've got some updates regarding the override of validation attributes using a metadata buddy class.

You can override your validation attributes but before it can be used, you need to regenerate your model first so that the code generation can replace the old validation attributes with your new validation attributes on the property.

This will be available as of 6.0.8 release.

Hope this helps.
Back to Top
yimbot View Drop Down
Newbie
Newbie


Joined: 15-Jan-2011
Posts: 10
Post Options Post Options   Quote yimbot Quote  Post ReplyReply Direct Link To This Post Posted: 20-Jan-2011 at 1:05am
Thanks again DenisK,
 
Yes, you are correct. I am looking to override the message for the RequiredValueVerifier. It is a shame if I cannot do it, but at least I will not waste any more time attempting it.
I don't really see any value in altering the "global" ErrorMessageResourceName as it will affect every field and it for that purpose, the message is fine.
 
The only way I could think to do it is to change the EDM so that it is not required, but I am not really comfortable with lowering that defence.
 
Any other ideas welcomed.
 
Cheers.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 19-Jan-2011 at 12:23pm
Hi yimbot;

I'm assuming the way you trigger the validation error "Name is required" is by assigning empty or null string to the Name property. The custom message, in this case, won't be triggered because if you look at the following line:

[IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Account_Name")]

The ErrorMessageResourceName, "Account_Name" is assigned to a StringLengthVerifier so the custom message will only be displayed if the input string exceeds the MaxValue.

The following implementation using buddy class,

public class EmployeeMetadata {
      /// <summary>
      /// Override Name to make it required.
      /// </summary>
      [RequiredValueVerifier(IsRequired = true, ErrorMessageResourceName = "Account_Name")]
      public static string Name;
    }

will, unfortunately, not work as well. It's possibly a bug and I'm going to confirm it. 

For the time being, you can use the "global" ErrorMessageResourceName located in the fallback resources. For example, to customize all RequiredValueVerifier, you can use the following ErrorMessageResourceName:

<data name="VerifierRequired" xml:space="preserve">
    <value>{0} is required</value>
  </data>

inside your custom message resources:

CustomErrorMessages.resx

Name = VerifierRequired
Value = Some customized message for {0} property

Please see http://drc.ideablade.com/xwiki/bin/view/Documentation/Verify_Localization to see the complete ErrorMessageResouceName in the fallback resources.

Hope this helps. Let me know if something is not clear for you.
Back to Top
yimbot View Drop Down
Newbie
Newbie


Joined: 15-Jan-2011
Posts: 10
Post Options Post Options   Quote yimbot Quote  Post ReplyReply Direct Link To This Post Posted: 19-Jan-2011 at 12:41am
Thanks Denisk,
 

#region Name property

/// <summary>Gets or sets the Name. </summary>

[Bindable(true, BindingDirection.TwoWay)]

[Editable(true)]

[Display(Name="Name", AutoGenerateField=true)]

[IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Account_Name")]

[DataMember]

public string Name {

get { return PropertyMetadata.Name.GetValue(this); }

set { PropertyMetadata.Name.SetValue(this, value); }

}

#endregion Name property

Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 18-Jan-2011 at 7:37pm
Hi yimbot;

Could you post me the generated code attributes decorating your Name property? For example,

#region LastName property

    /// <summary>Gets or sets the LastName. </summary>
    [Bindable(true, BindingDirection.TwoWay)]
    [Editable(true)]
    [Display(Name="LastName", AutoGenerateField=true)]
    [IbVal.StringLengthVerifier(MaxValue=30, IsRequired=true, ErrorMessageResourceName="Employee_LastName")]
    [DataMember]
    public string LastName {
      get { return PropertyMetadata.LastName.GetValue(this); }
      set { PropertyMetadata.LastName.SetValue(this, value); }
    }

 #endregion LastName property
Back to Top
yimbot View Drop Down
Newbie
Newbie


Joined: 15-Jan-2011
Posts: 10
Post Options Post Options   Quote yimbot Quote  Post ReplyReply Direct Link To This Post Posted: 17-Jan-2011 at 3:27pm
Bump ;)
Back to Top
yimbot View Drop Down
Newbie
Newbie


Joined: 15-Jan-2011
Posts: 10
Post Options Post Options   Quote yimbot Quote  Post ReplyReply Direct Link To This Post Posted: 15-Jan-2011 at 5:28am
Hi,
 
I am only new to DevForce and relatively new to Silverlight, so please excuse my ignorance...
 
I am encountering an issue whereby my customised validation messages are not displaying in the UI.
 
A breif rundown of the steps I have taken so far:
 
  • New Resources File (ValidationErrorResources) created in the server side project with custom messages
  • Resources file added as link to client (silverlight) project (interstingly, the heirarchy of Designer.cs under resx does not show)
  • Custom properties class set up as per the following link using a 'Buddy Class'
  • http://drc.ideablade.com/xwiki/bin/view/Documentation/Verify_MetadataType
  • Added as Link the Class file to Silverlight Project
  • In the constructor for my ViewModel, I have instanciated a new MyApplicationEntities Mgr
  • I have a Validate() method in the ViewModel which is called before executing the Save.
  • The validate method is:

private bool Validate()

{

Mgr.VerifierEngine.ErrorsResourceManager = ValidationErrorResources.ResourceManager;

var verifierResults = Mgr.VerifierEngine.Execute(this.Account);

return (!this.HasErrors && !verifierResults.HasErrors);

}

 

Code compiles fines and executes fine, but my custom messages never diplay, I only get 'Name is Required' or similar which comes from the fallback resources.

I do not really require real-time validation or complex rules, but a customised message would be nice.
 
Not sure where I am going wrong here, so a point in the right direction would be appreciated!


Edited by yimbot - 15-Jan-2011 at 5:35am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down