Re: Binding values for Required & Optional
Mike Schrag <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
The API files are not used for anything at runtime. All the API
files provide is metadata about the public API of your component for
use by IDE's (like WOBuilder and WOLip's WOD editor component). So,
for instance, in WOD editor in WOLips, when you have;
PersonRepetition : WORepetition {
<user presses key for completion>
I lookup the API file for WORepetition (which is actually a little
bit loaded, because the core components are in one big file, but it's
the same basic format), and if there is one, I look at the list of
"binding" entries to know what to offer the user as candidates for
completion. Similarly, the <binding> tags can define additional
flags such as "settable", "gettable", and "required" (which are the
old-school way of doing validation, I believe), and "defaults".
"defaults" specifies the semantic type of the binding. For instance,
valid values for that are "YES/NO", "Direct Action Classes", "Page
Names", "Direct Actions", etc. An example:
<binding name = "directActionName" defaults = "Page Name"/>
WOLips uses the defaults value for completion on the binding value:
ViewPersonAction : WOHyperlink {
directActionName = <user presses key for completion>
(I actually don't remember if I support Direct Action Name :), but if
I did:) this would then look at your direct action class and provide
a list of actions as completion candidates.
Some additional things you can do in <validation>:
<ungettable name = "bindingname"/> = check to make sure you can read
the value of bindingname
<unsettable name = "bindingname"/> = check to make sure you can set
the value of bindingname
Here's a more complicated validation example from the core components:
<validation message="'item' may not be a constant when
'displayString' or 'value' is bound">
<and>
<or>
<bound name="displayString"/>
<bound name="value"/>
</or>
<unsettable name="item"/>
</and>
</validation>
So this says that if 'item' is unsettable (i.e. a constant) and
either 'displayString' is bound or 'value' is bound, then validation
failed (with the message 'item' may not be a constant when
'displayString' or 'value' is bound).
Other misc validation types:
<count test=">1">
<bound name="numberformat"/>
<bound name="dateformat"/>
<bound name="formatter"/>
</count>
Says that if there is >1 of numberformat, dateformat, or formatter
bound then validation fails. Note the xml-escaped greater-than
symbol. For the record, Apple does not escape their < and >'s in the
original version of this file, making it invalid XML. If you are a
good person, you should escape yours. If you're using WOLips and you
don't, it just won't read your API file in (which is technically
correct because your xml file is not well-formed).
I believe multiple top level entries in a validation are an implicit
<and>, by the way.
ms
On Jul 11, 2006, at 9:15 AM, Zak Burke wrote:
> Cheong Hee (QSS) wrote on 7/11/06 6:45 AM:
>> In previous version (guess Version 4.5), the variable could pass into
>> component using this binding values defined in .api:
>> Required = (itemOneRequired, itemTwoRequired);
>> Optional = (itemOneOptional, itemTwoOptional);
>>
>> In 5.0 version above, the api has changed to xml format. Could
>> someone
>> share how do we pass in the Required and Optional binding values now?
>
> Huh. I'd always wondered what the .api file was for (was I the only
> one?).
>
> The .api file is mentioned briefly in Marker's book (p 40) as being
> used
> in sub-components, but there's no more detail. I have some vague
> feeling
> that I read of binding a fetch in the .api file too, but I can't
> pin it
> down.
>
> Tips? Tutorials?
>
> TIA,
>
> zak.
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev