Re: [Validation] and local string insertion

2004-11-22 Thread Radu Badita
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]



Re: [Validation] and local string insertion

2004-11-22 Thread Corey Scott
Fantastic thanks, I knew I was going in the wrong direction.

Regards,
-Corey


On Mon, 22 Nov 2004 16:51:56 +0200, Radu Badita [EMAIL PROTECTED] wrote:
 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]



[Validation] and local string insertion

2004-11-21 Thread Corey Scott
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]



RE: [Validation] and local string insertion

2004-11-21 Thread David G. Friedman
Corey,

We get it that you're resending it!  Now, on to helping mode...

What version of Struts are you using?

-Original Message-
From: Corey Scott [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 12:37 PM
To: [EMAIL PROTECTED]
Subject: [Validation] and local string insertion


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]



Re: [Validation] and local string insertion

2004-11-21 Thread Corey Scott
Sorry, I have been having huge troubles with my email lately.

I am using Struts 1.2.4, is this wrong?

Thanks again,
Corey


On Sun, 21 Nov 2004 23:18:44 -0500, David G. Friedman
[EMAIL PROTECTED] wrote:
 Corey,
 
 We get it that you're resending it!  Now, on to helping mode...
 
 What version of Struts are you using?
 
 
 
 -Original Message-
 From: Corey Scott [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, November 17, 2004 12:37 PM
 To: [EMAIL PROTECTED]
 Subject: [Validation] and local string insertion
 
 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]



Fwd: [Validation] and local string insertion

2004-11-17 Thread Corey Scott
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]