You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by Ture Hoefner <th...@bea.com> on 2005/11/08 23:13:12 UTC
using non-default MessageBundle with Jpf.ValidatableProperty
Hello,
I'm trying to get i18n messages for declarative validation of my form
bean. I can't use the default MessageBundle in this case and I can't
get anything to work when I try to use another bundle. Is it possible?
I don't understand the javadoc for
Jpf.ValidatableProperty.displayNameKey: "A key in the default message
bundle or in the bundle specified by {@link MessageBundle#bundleName}
that will be used..."
Here is my latest attempt, any hints would be appreciated. Thanks!
@Jpf.Controller
(
messageBundles =
{
@Jpf.MessageBundle(
bundlePath=ContentConstants.CONTENT_JSP_RESOURCE_BUNDLE ),
// this message bundle annotation provides the message bundle
that we use in
// server-side declarative input validation
@Jpf.MessageBundle( bundleName="decValidation",
bundlePath="com.bea.jsptools.util.Validation")
},
validatableBeans =
{
@Jpf.ValidatableBean
(
type=RepositoryConfigForm.class,
validatableProperties =
{
// name is required
@Jpf.ValidatableProperty
(
propertyName=BaseContent.NAME_PROPERTY_NAME,
displayNameKey="${bundle.decValidation.name.displayName}",
validateRequired=@Jpf.ValidateRequired(messageKey="${bundle.decValidatio
n.error.required}")
),
// connection class is required
@Jpf.ValidatableProperty
(
propertyName=BaseContent.CONNECTION_CLASS_PROPERTY_NAME,
displayNameKey="${bundle.decValidation.connectionClass.displayName}",
validateRequired=@Jpf.ValidateRequired(messageKey="${bundle.decValidatio
n.error.required}")
)
}
)
}
)
Re: using non-default MessageBundle with Jpf.ValidatableProperty
Posted by Rich Feit <ri...@gmail.com>.
Hi Ture,
You should be able to get what you need by using the 'displayName' and
'message' attributes instead of 'displayNameKey' and 'messageKey'. The
former two can accept literal strings or expressions; the latter two
simply refer directly to messages in a message bundle. ** Note that
you'd need to use something other than '.' in your message key names --
the expression language will try to bind into properties through each '.' **
One alternative would be to use the 'bundleName' attribute in
conjunction with 'messageKey'/'displayName', e.g.,
validateRequired=@Jpf.ValidateRequired(messageKey="error.required", bundleName="decValidation")
Either way should work -- let me know.
Rich
Ture Hoefner wrote:
>Hello,
>
>
>
>I'm trying to get i18n messages for declarative validation of my form
>bean. I can't use the default MessageBundle in this case and I can't
>get anything to work when I try to use another bundle. Is it possible?
>
>
>
>I don't understand the javadoc for
>Jpf.ValidatableProperty.displayNameKey: "A key in the default message
>bundle or in the bundle specified by {@link MessageBundle#bundleName}
>that will be used..."
>
>
>
>Here is my latest attempt, any hints would be appreciated. Thanks!
>
>
>
>@Jpf.Controller
>
>(
>
> messageBundles =
>
> {
>
> @Jpf.MessageBundle(
>bundlePath=ContentConstants.CONTENT_JSP_RESOURCE_BUNDLE ),
>
>
>
> // this message bundle annotation provides the message bundle
>that we use in
>
> // server-side declarative input validation
>
> @Jpf.MessageBundle( bundleName="decValidation",
>bundlePath="com.bea.jsptools.util.Validation")
>
> },
>
> validatableBeans =
>
> {
>
> @Jpf.ValidatableBean
>
> (
>
> type=RepositoryConfigForm.class,
>
> validatableProperties =
>
> {
>
> // name is required
>
> @Jpf.ValidatableProperty
>
> (
>
> propertyName=BaseContent.NAME_PROPERTY_NAME,
>
>
>displayNameKey="${bundle.decValidation.name.displayName}",
>
>
>validateRequired=@Jpf.ValidateRequired(messageKey="${bundle.decValidatio
>n.error.required}")
>
> ),
>
>
>
> // connection class is required
>
> @Jpf.ValidatableProperty
>
> (
>
>
>propertyName=BaseContent.CONNECTION_CLASS_PROPERTY_NAME,
>
>
>displayNameKey="${bundle.decValidation.connectionClass.displayName}",
>
>
>validateRequired=@Jpf.ValidateRequired(messageKey="${bundle.decValidatio
>n.error.required}")
>
> )
>
> }
>
> )
>
> }
>
>)
>
>
>
>
>
>
>
>