[Sorry for the late reply, I've been on vacation]
At present, presentation types are an internal mechanism used to support CSS
styling of LZX.
Inspecting an object in the debugger in the current trunk will display
attribute types when they are known, and will display presentation types in an
inspectable way for complex types (the "CSS" or external representation of the
type will be displayed, and if you inspect it, you can see the underlying
internal representation).
For instance, if I inspect:
> <view id="sd" x="200" clip="true" xscale="3" yscale="3" y="400" width="100"
> height="100" with="boxmodel" padding="${[7,7,7,7]}" bordercolor="red"
> borderwidth="${[5, 5, 5, 5]}" shadowblurradius="10" shadowangle="45"
> shadowdistance="20" shadowcolor="#000000">
I see:
> lzx> Debug.inspect(#sd)
> «<anonymous extends='view' with='boxmodel'>#1#0| #sd» {
> [...]
> borderbottomwidth:number 5
> bordercolor:color red
> borderleftwidth:number 5
> borderrightwidth:number 5
> bordertopwidth:number 5
> borderwidth:boxsidedimensions 5
> [...]
which shows the types and values for the various border attributes. Simple
types, like `number` are not inspectable (their internal and external
representations are identical). But if I inspect the value of `bordercolor`,
which has a complex type `color`, I see:
> lzx> Debug.inspect(red)
> «color value#7| red» {
> value: 16711680
> }
> «color value#7| red»
Showing that the internal representation of the `color` `red` is an integer
`16711680`. Similarly, I can inspect the value of `borderwidth`, which is of
type `boxsidedimensions` (defined in lps/components/mixins/boxmodel.lzx, where
you can see the pattern for defining presentation types of your own):
> lzx> Debug.inspect(5)
> «boxsidedimensions value#8| 5» {
> value: [5, 5, 5, 5]
> }
> «boxsidedimensions value#8| 5»
> lzx>
which shows that the underlying representation is an array [top, left, right,
bottom] of widths.
Presentation Types are an evolving feature, so I apologize for the lack of
documentation, but welcome your feedback.
---
We will eventually expose a public API for accepting and presenting attribute
values according to their declared presentation type, but that API design is
not yet settled. It is currently used internally to support CSS styling of
attributes. Most likely the API will be like the CSS API of HTML, although we
may also expose the acceptAttribute and presentAttribute primitives.
---
My current thinking on
http://thread.gmane.org/gmane.comp.java.openlaszlo.devel/26537/focus=6569 is
also to use a more CSS-like mechanism. E.g.,
> <view ... with="boxmodel" padding="${[7,7,7,7]}" bordercolor="red"
> borderwidth="${[5, 5, 5, 5]}" ...
might more concisely (and legibly) be expressed:
> <view ... with="boxmodel" style="padding: 7; border-color: red; border-width:
> 5" ...
(with no commitment as to whether you can constrain pieces of the style
expression, at this point).
On 2011-03-22, at 14:38, Laszlo Developer wrote:
> I'd still appreciate an answer if it's possible to introspect a class
> attribute type at runtime. Is that possible?
>
> LaszloNode.lzs has an attributes property, but there doesn't seem to
> be any type information attaches to the attribute.
>
> On Mon, Mar 21, 2011 at 12:15 PM, Laszlo Developer
> <[email protected]> wrote:
>> Ok, there's lz.TypeService object at runtime.
>>
>> And I found this file in the LFC:
>> http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc/core/PresentationTypes.lzs
>> There are a number of types defined in here:
>> - string
>> - cdata
>> - boolean
>> - number
>> - color
>> - expression
>> - size
>> - css
>>
>> At the end of the file there two comments:
>> // TODO?: add token: TokenPresentationType,
>> // script: ScriptPresentationType
>>
>> Will those types be implemented as well? And are these all the types
>> which are supported out of the box by the LFC?
>>
>>
>> On Mon, Mar 21, 2011 at 11:59 AM, Laszlo Developer
>> <[email protected]> wrote:
>>> I've a few questions around the Presentation Types introduced into
>>> OpenLaszlo:
>>>
>>> 1) It doesn't seem that the wiki page is up-to-date, can you confirm that?
>>> http://wiki.openlaszlo.org/Attribute_Type_Coercion
>>>
>>> 2) Is there any information in the documentation on the changes?
>>>
>>> 3) Has the outcome of this discussion been summarized and published
>>> somewhere?
>>> http://thread.gmane.org/gmane.comp.java.openlaszlo.devel/26537/focus=6569
>>>
>>>
>>> 4) When inspecting attributes at runtime, what is the best way to
>>> detect the type of an attribute?
>>>
>>> Thanks,
>>> L.
>>>
>>
>