So perhaps a dynamic component should check for an existing API file during
instantiation and perform its validation rules? That way these validations
would not be duplicated.
jw
Am 06.08.2012 um 07:14 schrieb Chuck Hill:
> Hi Johann,
>
> If the error is WOLips is ignored (or validation turned off), then this code
> is needed to give a useful error message. WIthout it, it would be hard to
> track down the cause.
>
> Chuck
>
>
> On 2012-08-04, at 8:34 AM, Johann Werner wrote:
>
>> Hi list,
>>
>> in many dynamic element classes there are some checks in the constructor if
>> certain bindings exist or not. Example from ERAttachmentLink:
>>
>> public ERAttachmentLink(String name, NSDictionary<String, WOAssociation>
>> associations, WOElement template) {
>> super(name, associations, template);
>> _associations = associations.mutableClone();
>> _attachment = _associations.removeObjectForKey("attachment");
>> _download = _associations.removeObjectForKey("download");
>> if (_attachment == null) {
>> throw new WODynamicElementCreationException("<ERAttachmentLink> The
>> 'attachment' binding is required.");
>> }
>> _configurationName =
>> _associations.removeObjectForKey("configurationName");
>> }
>>
>> Most of the components do have an API file (for those missing we will have
>> to fix and add them) that WOLips uses to do binding validation within the
>> component editor. In the API file you can set a binding as mandatory or even
>> more complex rules by manually editing the file in a text editor. An API
>> file should be present for a component as you will get instant feedback in
>> the component editor while changing bindings.
>>
>> Now looking at the checks in code this is sort of duplicated code. In the
>> example above if I don't add the attachment binding to the ERAttachmendLink
>> on a page of mine the component editor will already show an error whereas
>> the exception that the binding is missing will only be thrown when a user
>> will hit the enclosing page. So do we really need that extra logic in the
>> constructors? I would tend to no (at least for those validations that can be
>> covered by an API file), remove them and prefer keeping the API files
>> correct. What is your opinion?
>>
>> jw
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>>
>> This email sent to [email protected]
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall
> knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/gvc/practical_webobjects
>
>
>
>
>
>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]