You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Nikolai <jn...@is2inc.com> on 2003/06/03 01:35:50 UTC
Re: [BULK] RE: Default ActionError message...
I thought about using this method but we would like to have a more
specific error message for some resultCode. For example, a resultCode
of 24 is an "Invalid expiration date" which is something the user may
be able to fix by resubmitting the form with an updated date. I think
that only showing the error code would confuse the user.
Thanks
On Monday, June 2, 2003, at 04:26 PM, Jivan, Rajiv wrote:
> You can define a generic error message in ActionResources
> error.verisign=Verisign has returned an error. Error code is {0}
>
> and in your Action have the following
> errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.verisign,
> resultCode));
>
> -----Original Message-----
> From: John Nikolai [mailto:jnikolai@is2inc.com]
> Sent: Mon 6/2/2003 7:10 PM
> To: struts-user@jakarta.apache.org
> Cc:
> Subject: Default ActionError message...
>
>
>
>
> Hi fellow Struts users!
>
> We are using Verisign to validate a users credit card. There are
> several error codes which can be returned but we don't wish to map
> every single one of these error code in the properties file. I would
> like to do something like the following where resultCode is what is
> returned from Verisign servers (at this point in the code, we know
> Verisign has returned an error so the resultCode will contain the
> error
> number) :
>
> String resultCode = result.getParameter(result.RESULT);
> errors.add(ActionErrors.GLOBAL_ERROR, new
> ActionError(resultCode));
> saveErrors(request, errors);
>
> This works fine if the resultCode is mapped in the properties file but
> breaks if the it is not there. What I would like to do is use a
> default
> error message if the resultCode is not contained in the properties
> file. This will allow us to add error codes to the properties file as
> needed...
>
> Short of creating a local properties object, reading in the properties
> and searching to see if it exists is there a better solution?
>
> Thank you for your help,
> - John
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
> NOTICE:
> This message is for the designated recipient only and may contain
> privileged or confidential information. If you have received it in
> error, please notify the sender immediately and delete the original.
> Any other use of this e-mail by you is prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [SOLUTION] RE: Default ActionError message...
Posted by John Nikolai <jn...@is2inc.com>.
FYI for anyone interested:
-----------------
MessageResources resources = getResources(request);
String message = resources.getMessage("error.verisign." + resultCode);
if (message == null) {
// Use the default error text
message = resources.getMessage("error.verisign.default");
}
------------------
On Monday, June 2, 2003, at 04:35 PM, John Nikolai wrote:
>
> I thought about using this method but we would like to have a more
> specific error message for some resultCode. For example, a resultCode
> of 24 is an "Invalid expiration date" which is something the user may
> be able to fix by resubmitting the form with an updated date. I think
> that only showing the error code would confuse the user.
>
> Thanks
>
> On Monday, June 2, 2003, at 04:26 PM, Jivan, Rajiv wrote:
>
>> You can define a generic error message in ActionResources
>> error.verisign=Verisign has returned an error. Error code is {0}
>>
>> and in your Action have the following
>> errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.verisign,
>> resultCode));
>>
>> -----Original Message-----
>> From: John Nikolai [mailto:jnikolai@is2inc.com]
>> Sent: Mon 6/2/2003 7:10 PM
>> To: struts-user@jakarta.apache.org
>> Cc:
>> Subject: Default ActionError message...
>>
>>
>>
>>
>> Hi fellow Struts users!
>>
>> We are using Verisign to validate a users credit card. There are
>> several error codes which can be returned but we don't wish to map
>> every single one of these error code in the properties file. I would
>> like to do something like the following where resultCode is what is
>> returned from Verisign servers (at this point in the code, we know
>> Verisign has returned an error so the resultCode will contain the
>> error
>> number) :
>>
>> String resultCode = result.getParameter(result.RESULT);
>> errors.add(ActionErrors.GLOBAL_ERROR, new
>> ActionError(resultCode));
>> saveErrors(request, errors);
>>
>> This works fine if the resultCode is mapped in the properties file
>> but
>> breaks if the it is not there. What I would like to do is use a
>> default
>> error message if the resultCode is not contained in the properties
>> file. This will allow us to add error codes to the properties file as
>> needed...
>>
>> Short of creating a local properties object, reading in the
>> properties
>> and searching to see if it exists is there a better solution?
>>
>> Thank you for your help,
>> - John
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>
>>
>> NOTICE:
>> This message is for the designated recipient only and may contain
>> privileged or confidential information. If you have received it in
>> error, please notify the sender immediately and delete the original.
>> Any other use of this e-mail by you is prohibited.
>
>
> ---------------------------------------------------------------------
> 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