struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: use of validate() method [S 1.3.8]
Date Wed, 14 Dec 2011 21:01:17 GMT
A validation failure's return is still an HTTP success--the request itself
is successful.

You'd need to change the response code if you want to use something other
than the `success` result (or whatever mechanism your Ajax call uses), or
return data you can use to determine if there was a failure.

Dave

On Wed, Dec 14, 2011 at 3:57 PM, Anjib Mulepati <anjibcs@hotmail.com> wrote:

> Thanks
>
> I have each field as unique so they are not composite that means I am in
> right direction.
>
> Now what you say about composite key I think that will be valid for
> primary key also. I also have primary key in the table 'id' which user
> doesn't have to enter. To ensure any sql exception in createCustomer()
> method I am catching SQLException and throwing new custom exception. In my
> calling action class I am mapping error message for this exception. But
> when I call this action class using AJAX its always returning as success
> case even when I sending duplicate ID (I am not sending this id from form.
> I have hardcoded). I think this is because action call doesn't send failure
> status if exception occur. Am i correct? If no what I am missing? If yes
> then what will be solutionfor these problems?
>
> Anjib
>
> On 12/14/2011 3:31 PM, Eric Reed wrote:
>
>> By saying both code and name are unique... is this a composite key that
>> must be unique or do both fields have to be unique?  If it is the composite
>> key that must be unique than I would skip the checks and catch the
>> exception when thrown.  Otherwise if each field must be unique then you
>> need to validate each one and your design/logic is fine.
>>
>>  Anjib Mulepati<anjibcs@hotmail.com>  12/14/2011 3:21 PM>>>
>>>>>
>>>> Hi All,
>>
>> I have question regarding use of validate() method in Struts 1.3.8.
>>
>> I have simple form to collect couple of information (e.g. code and name)
>> and have to add them to the Database. All database operations are
>> handled by my DAO layer.
>>
>> Both code and name are unique in Database. So I want to validate code
>> and name before calling INSERT SQL statement.
>>
>> Three methods I have in DAO layer are
>>       - Cutomer findByCode(String code);
>>       - Customer findByName (String name);
>>       - void createCustomer (Cutomer cust);
>>
>> So I am calling first two methods in validate() method and third one in
>> execute() method.
>>
>> Is this a good way to do validation before inserting the record? Or
>> there is better logic/design than this?
>>
>> I will be glad if anyone can answer my curiosity.
>>
>> Thanks,
>> Anjib
>>
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<user-unsubscribe@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<user-unsubscribe@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<user-unsubscribe@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message