You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Honza Spurný <sp...@master.cz> on 2003/11/24 17:35:54 UTC

MessageResources in ActionForm

Hi there,

I'm able to read values from MessageResources in JSP files. But in special
case I need to read such values in java-classes. Unfortunatelly I need it in
ActionForm in validate() method...

To understand me I'm attaching my vision of how it could be very easy (it
doesn't work):

public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request){
  MessageResources mr = request.getMessageResources();
  ActionErrors errors = new ActionErrors();

  if (anyReasonToFailValidation){
    errors.add("Error found", new ActionError("key.to.this.error",
mr.getMessage("key.to.errorMessageParameter")));

  return errors;
}

I think it's clear why I need to have an object of Messageresources in
ValidatorForm.

Please, could anybody help me?

Thanks a lot.
Sporak


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: MessageResources in ActionForm

Posted by Honza Spurný <sp...@master.cz>.
Manish Singla wrote:
> Hi
>
> Use following
>
> MessageResources mr = ((MessageResources)
> request.getAttribute(Globals.MESSAGES_KEY));
                       ^^^^^^^^

what is Globals ??? I've tried it, but my java compiler does not knows it...

>
> Instaed of
>
>>  MessageResources mr = request.getMessageResources();
>
> HTH
> Manish Singla
>
>
>
> Honza Spurný wrote:
>> Hi there,
>>
>> I'm able to read values from MessageResources in JSP files. But in
>> special case I need to read such values in java-classes.
>> Unfortunatelly I need it in ActionForm in validate() method...
>>
>> To understand me I'm attaching my vision of how it could be very
>> easy (it doesn't work):
>>
>> public ActionErrors validate(ActionMapping mapping,
>> HttpServletRequest request){
>>   MessageResources mr = request.getMessageResources();
>>   ActionErrors errors = new ActionErrors();
>>
>>   if (anyReasonToFailValidation){
>>     errors.add("Error found", new ActionError("key.to.this.error",
>> mr.getMessage("key.to.errorMessageParameter")));
>>
>>   return errors;
>> }
>>
>> I think it's clear why I need to have an object of Messageresources
>> in ValidatorForm.
>>
>> Please, could anybody help me?
>>
>> Thanks a lot.
>> Sporak
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: MessageResources in ActionForm

Posted by Frers Michael <fr...@Sisis.de>.
Globals are in the struts.jar

org.apache.struts.Globals


Have a nice day

Michael

----- Original Message -----
From: "Honza Spurný" <sp...@master.cz>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>;
<Ma...@Sun.COM>
Sent: Tuesday, November 25, 2003 11:07 AM
Subject: Re: MessageResources in ActionForm


> Manish Singla wrote:
> > Hi
> >
> > Use following
> >
> > MessageResources mr = ((MessageResources)
> > request.getAttribute(Globals.MESSAGES_KEY));
>                        ^^^^^^^^
>
> what is Globals ??? I've tried it, but my java compiler does not knows
it...
>
> >
> > Instaed of
> >
> >>  MessageResources mr = request.getMessageResources();
> >
> > HTH
> > Manish Singla
> >
> >
> >
> > Honza Spurný wrote:
> >> Hi there,
> >>
> >> I'm able to read values from MessageResources in JSP files. But in
> >> special case I need to read such values in java-classes.
> >> Unfortunatelly I need it in ActionForm in validate() method...
> >>
> >> To understand me I'm attaching my vision of how it could be very
> >> easy (it doesn't work):
> >>
> >> public ActionErrors validate(ActionMapping mapping,
> >> HttpServletRequest request){
> >>   MessageResources mr = request.getMessageResources();
> >>   ActionErrors errors = new ActionErrors();
> >>
> >>   if (anyReasonToFailValidation){
> >>     errors.add("Error found", new ActionError("key.to.this.error",
> >> mr.getMessage("key.to.errorMessageParameter")));
> >>
> >>   return errors;
> >> }
> >>
> >> I think it's clear why I need to have an object of Messageresources
> >> in ValidatorForm.
> >>
> >> Please, could anybody help me?
> >>
> >> Thanks a lot.
> >> Sporak
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: MessageResources in ActionForm

Posted by Honza Spurný <sp...@master.cz>.
Manish Singla wrote:
> Hi
>
> Use following
>
> MessageResources mr = ((MessageResources)
> request.getAttribute(Globals.MESSAGES_KEY));
                       ^^^^^^^^

what is Globals ??? I've tried it, but my java compiler does not knows it...

>
> Instaed of
>
>>  MessageResources mr = request.getMessageResources();
>
> HTH
> Manish Singla
>
>
>
> Honza Spurný wrote:
>> Hi there,
>>
>> I'm able to read values from MessageResources in JSP files. But in
>> special case I need to read such values in java-classes.
>> Unfortunatelly I need it in ActionForm in validate() method...
>>
>> To understand me I'm attaching my vision of how it could be very
>> easy (it doesn't work):
>>
>> public ActionErrors validate(ActionMapping mapping,
>> HttpServletRequest request){
>>   MessageResources mr = request.getMessageResources();
>>   ActionErrors errors = new ActionErrors();
>>
>>   if (anyReasonToFailValidation){
>>     errors.add("Error found", new ActionError("key.to.this.error",
>> mr.getMessage("key.to.errorMessageParameter")));
>>
>>   return errors;
>> }
>>
>> I think it's clear why I need to have an object of Messageresources
>> in ValidatorForm.
>>
>> Please, could anybody help me?
>>
>> Thanks a lot.
>> Sporak
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: MessageResources in ActionForm

Posted by Manish Singla <Ma...@Sun.COM>.
Hi

Use following

MessageResources mr = ((MessageResources) 
request.getAttribute(Globals.MESSAGES_KEY));

Instaed of

>  MessageResources mr = request.getMessageResources();

HTH
Manish Singla



Honza Spurný wrote:
> Hi there,
> 
> I'm able to read values from MessageResources in JSP files. But in special
> case I need to read such values in java-classes. Unfortunatelly I need it in
> ActionForm in validate() method...
> 
> To understand me I'm attaching my vision of how it could be very easy (it
> doesn't work):
> 
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request){
>   MessageResources mr = request.getMessageResources();
>   ActionErrors errors = new ActionErrors();
> 
>   if (anyReasonToFailValidation){
>     errors.add("Error found", new ActionError("key.to.this.error",
> mr.getMessage("key.to.errorMessageParameter")));
> 
>   return errors;
> }
> 
> I think it's clear why I need to have an object of Messageresources in
> ValidatorForm.
> 
> Please, could anybody help me?
> 
> Thanks a lot.
> Sporak
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


-- 
Thanks
Manish Singla
x73166


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org