Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

AbstractMessageSource.UseCodeAsDefaultMessage Property

Gets or Sets a value indicating whether to use the message code as default message instead of throwing a NoSuchMessageException. Useful for development and debugging. Default is "false".

[Visual Basic]
Public Property UseCodeAsDefaultMessage() As Boolean
   Public Get
   End Get
   Public Set
   End Set
End Property
[C#]
public bool UseCodeAsDefaultMessage { public get; public set; }

Property Value

true if use the message code as default message instead of throwing a NoSuchMessageException; otherwise, false.

Remarks

Note: In case of a IMessageSourceResolvable with multiple codes (like a FieldError) and a MessageSource that has a parent MessageSource, do not activate "UseCodeAsDefaultMessage" in the parent: Else, you'll get the first code returned as message by the parent, without attempts to check further codes.

To be able to work with "UseCodeAsDefaultMessage" turned on in the parent, AbstractMessageSource contains special checks to delegate to the internal

GetMessageInternal
method if available. In general, it is recommended to just use "UseCodeAsDefaultMessage" during development and not rely on it in production in the first place, though.

Alternatively, consider overriding the

GetDefaultMessage
method to return a custom fallback message for an unresolvable code.

See Also

AbstractMessageSource Class | Spring.Context.Support Namespace