WODynamicElementCreationException
WODynamicElementCreationException
- Subject: WODynamicElementCreationException
- From: Johann Werner <email@hidden>
- Date: Sat, 04 Aug 2012 17:34:28 +0200
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden