I think the problem might be that you don't get the right
MessageResources. Here is what Struts API says about
public MessageResources getInternal() : "Return the MessageResources
instance containing our internal message strings."
You should use:
MessageResources resources = request.getSession().getServletContext()
.getAttribute(Globals.MESSAGES_KEY));
to retrieve your bundle.
I hope this helps you.
On Thu, 18 Nov 2004 13:07:18 +0800, Corey Scott <[EMAIL PROTECTED]> wrote:
> Sorry ... resend, I cant find the previous one in the mail archive and
> I am not sure why the first one disappeared
>
> -Corey
>
> ---------- Forwarded message ----------
> From: Corey Scott <[EMAIL PROTECTED]>
> Date: Thu, 18 Nov 2004 01:36:54 +0800
> Subject: [Validation] and local string insertion
> To: [EMAIL PROTECTED]
>
> Hi,
>
> I have been trying to achieve the same in my validate method to the
> following extract from me validation.xml
> <form name="UpdateTaskForm">
> <field property="txtTaskSummary"
> depends="required">
> <msg
> name="required"
> key="stdError.missing"/>
>
> <arg0 key="UpdateTaskForm.txtTaskSummary"/>
> </field>
> </form>
>
> Extract from my message bundle:
> stdError.required.field=Please enter/choose a {0}
> UpdateTaskForm.txtTaskSummary=Task Summary
>
> My validate method:
> public ActionErrors validate(
> ActionMapping mapping,
> HttpServletRequest request)
> {
> ActionErrors errors = new ActionErrors();
>
> if ((this.txtTaskSummary == null)
> || (this.txtTaskSummary.length() == 0))
> {
> MessageResources resources = this.getServlet().getInternal();
>
> errors.add(
> "txtTaskSummary",
> new ActionMessage(
> "stdError.required.field",
> resources.getMessage( request.getLocale(),
> "UpdateTaskForm.txtTaskSummary")));
> }
>
> return errors;
> }
>
> Hopefully it is clear that I am trying get an output similar to:
> Please enter/choose a Task Summary
>
> But all I can get is:
> Please enter/choose a {0} // without the whole get resources stuff
> or
> Please enter/choose a null //code above
>
> I am getting the impression I am very much off track, any help would be great.
>
> Thanks,
> Corey
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]