dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03849
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
Hi,
As always there is not a single right and wrong answer here. There are some
things (usually different things) that might need to be validated at
different levels of the application. But things which might make a mess of
the model should be validated by the model (or the service layer as I see
Lars has just chiped in :-). I'm not sure if I really buy the idea that
communication of problems at the model shouldn't percolate up to the UI.
Are we saying that from a UI perspective, an update, delete or add should
allows be assumed to just succeed? Of course these will sometimes fail and
of course we have to feed that back up (whether by exception or return value
- whichever is least evil).
Its sure will be better if you have a validator at model layer. But I think
all the rules that you validate at model layer, also have to be validated at
controller and view layer. The data go from top to bottom layer, and my
point is, its must be validate as much as it can at each layer. I think of
each layer as a firewall, and for each layer the data is passing, it will be
more safe or reliable. User can by pass the javascript which is the view
layer, so the controller will be the main gate, and it should be responsible
for all the data that it passes to the model layer. If there is an error in
the save, update, delete method, it should be an error related to the
database or the business logic of the application, not the data itself. And
this error also should not be throw directly to the user, there should be a
custom exception handler message.
Anyway, this is my first time discussing on this mailing list, so .. just
sharing my opinion about this validation things :)
@Lars: what about having a custom abstract action class that will overwrite
the execute method . It will first call the validate abstract method, then
call the handleRequest abstract method, those abstract methods will be
implemented by extended action class. Something like this :
public String execute() throws Exception
{
if( validate() )
return handleRequest();
else return ERROR;
}
Is this possible ?
2009/12/23 Lars Helge Øverland <larshelge@xxxxxxxxx>
>
>
> On Wed, Dec 23, 2009 at 5:42 PM, Bob Jolliffe <bobjolliffe@xxxxxxxxx>wrote:
>
>> As always there is not a single right and wrong answer here. There are
>> some things (usually different things) that might need to be validated at
>> different levels of the application. But things which might make a mess of
>> the model should be validated by the model (or the service layer as I see
>> Lars has just chiped in :-). I'm not sure if I really buy the idea that
>> communication of problems at the model shouldn't percolate up to the UI.
>> Are we saying that from a UI perspective, an update, delete or add should
>> allows be assumed to just succeed? Of course these will sometimes fail and
>> of course we have to feed that back up (whether by exception or return value
>> - whichever is least evil).
>>
>>
> Just to clarify... Right now we do validation of things like uniqueness and
> non-null-ability in separate actions. If we push this down to the service
> layer I do believe that this should happen in a separate method. It could be
> the client/presentation layers responsibility to call that validation method
> before calling the "business method". If the business method still fails we
> are dealing with insufficient validation or programming errors. In that case
> we could naturally handle that with a checked or unchecked exception which
> could be caught in the presentation layer. But I do think mixing validation
> and business logic code in the same method is not to separate concerns...
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs<https://launchpad.net/%7Edhis2-devs>
> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs<https://launchpad.net/%7Edhis2-devs>
> More help : https://help.launchpad.net/ListHelp
>
>
--
Nguyen Pham Hoang Quoc Viet
Follow ups
References
-
[Bug 430657] [NEW] Date text field needs validation rule in form area or data entry screen
From: Brajesh, 2009-09-16
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Saptarshi Purkayastha, 2009-12-22
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Hieu Dang Duy, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Lars Helge Øverland, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Bob Jolliffe, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Jason Pickering, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Viet Nguyen, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Saptarshi Purkayastha, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Bob Jolliffe, 2009-12-23
-
Re: [Bug 430657] Re: Date text field needs validation rule in data entry screen
From: Lars Helge Øverland, 2009-12-23