On Sun, Apr 26, 2009 at 6:48 AM, Rickard Öberg <[email protected]>wrote:

> Guus Bloemsma wrote:
>
>> I'm missing an equivalent to a per-property status() method on properties
>> though.  Or am I missing something?
>> Is this view on GUI's documented anywhere?
>>
>
> A property has isImmutable() and isComputed() that helps, and then a
> property also has metainfo(type) that can be used for any additional
> metadata you need in the UI. The value is always valid, i.e. it always
> conforms to the constraints you set on it:


Those methods and the metainfo are static. The result of status() I'm
talking about would change continuously in response to changes in other
properties or entities. Validity would be defined in the context of other
properties and entities as well. Like this pseudocode for an hypothetical
Address entity:

Status Addres.zipcode.status() {         // status of zipcode property
   if(!country.get().usesZipcodes())     // some countries don't use
zipcodes
      return irrelevant;                 // in that case zipcode is
meaningless

   // otherwise use country-specific validation
   if(country.get().validate(zipcode.get())
      return new Invalid(country.get()); // invalid because of country

   return super.status();                // default
}

So what I'm looking for is to take an existing entity and easily extend it
with such a status() method per property.

As you can see there is nothing GUI specific in this code. That's why I
think it's not a problem to include this code in the entity. You could even
use the status to do some runtime checks like reading invalid or irrelevant
properties.

cheers, Guus



>
>
> @NotEmpty @Matches("[a-zA-Z]*")
> Property<String> name();
>
> /Rickard
>
>
> _______________________________________________
> qi4j-dev mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/qi4j-dev
>
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to