You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by ti...@keow.org on 2004/01/22 16:07:44 UTC

Re: [Woody] We need a booleanfield at all? (was: [Woody] Boolean widget as a combobox)

On Thu, Jan 22, 2004 at 04:28:29AM -0600, Antonio Gallardo wrote:
> We have 2 positions:
> 
> 1-booleanfield need to exist. It is a special handling case. If we need to
> render it in other ways: comboboxes, radio buttons, etc. We need to do it
> in a wi:styling.
>
> 2-We don't need a boolean field at all, since it is just a special case of
> wd:field. Let's rewrote the woody definition specification without
> booleanfield.

If we need the speed provided by having a special handling class,
then we could adapt the FieldDefinitionBuilder to choose to create
a FieldDefinition or a BooleanFieldDefinition based on the features
that are requested in the definition.  This way we could have the
speed without having to provide wd:booleanfield as an exception to
the otherwise clean wd:field-with-wd:datatype model.

What if we introduce a new "null" attribute to the definition or
to the datatype (which place makes more sense?):
  attr missing - null or missing parameter means null
  null="null"  - null or missing parameter means null
  null="false" - null or missing parameter means "false"
  null="true"  - for balance, would this have a use?
This may be useful for other datatypes as well:
  null="some-value" - null or missing parameter means "some-value"
<duck-and-run>
  null="some-expression" - null or missing parameter causes
    expression to be evaluated, possibly calculating a value
    based on the values of other widgets.  The duck-and-run
    is because this kind of logic may belong elsewhere...
</duck-and-run>

Optionally, for HTML checkbox rendering we could have the template
generator/processor check to make sure that the "null" attribute
is not missing or set to equal "null" for boolean valued fields.
This would help prevent people from tripping over the mis-design
of the HTML spec's handling of checkboxes.

--Tim Larson

Re: [Woody] We need a booleanfield at all?

Posted by Tim Larson <ti...@keow.org>.
On Thu, Jan 22, 2004 at 07:20:28PM +0100, Sylvain Wallez wrote:
> tim@keow.org wrote:
> >On Thu, Jan 22, 2004 at 04:28:29AM -0600, Antonio Gallardo wrote:
>
> Honestly, I don't think speed is the real issue here...
 
Agreed.  I was just trying to show that speed issues could be
decoupled from definition syntax issues.

> IMO, this concern belongs more to the convertor than the datatype, as 
> the convertor sits between the request parameters and the datatype and 
> is in charge of converting these parameters from/to the datatype.
> 
> Furthermore, the value of the "null" attribute has to be converted into 
> the target datatype, and this is again a convertor job!
> 
> And more: the boolean datatype can have two convertors. The default one 
> will consider null as false, which will automagically handle HTML 
> checkboxes. A second one, will consider null... as null and can be used 
> for tri-state booleans.
> 
> WDYT?

Ok, I agree that the decision of how to translate null parameters is the
responsibility of the convertors.  Are we happy with just a 3-state
boolean if we just start respecting the "required" attribute to turn it
into a 2-state boolean?  I think this setup would work well with the
two converters you suggest, but still wonder about giving all the
converters a null="some-value-or-maybe-an-expresson" parameter...

> >Optionally, for HTML checkbox rendering we could have the template
> >generator/processor check to make sure that the "null" attribute
> >is not missing or set to equal "null" for boolean valued fields.
> >This would help prevent people from tripping over the mis-design
> >of the HTML spec's handling of checkboxes.
> 
> Mmmh... I'm not sure this is so simple, as the template engine doesn't 
> know what the final rendering will be. What about my proposal above?

<sudden-thought>
  Conversion could be seen as logically a property of
  the view rather than of the model.  For example, why
  should the model determine the date format that the
  user is allowed to enter?  This is a presentation
  concern that the model should not even be aware of.
  Our current design is a side-effect of treating the
  view as a one-way template instead of as a full
  layer like the binding.

  Notice how our specific pattern approximates a much
  more general pattern:
    Beans<-->Binding   <-->Model<-->Template  <-->HTML
    Data <-->Conversion<-->Data <-->Conversion<-->Data
  
  We have the same concerns when binding as when
  templating, we just happen to use different names:
    value/attr/property <-> input field
    insert-node/bean    <-> inline markup
    binding direction   <-> normal vs output styling
    custom binding      <-> custom stylesheet
    convertor           <-> (currently missing)

  Perhaps these parallels could be exploited to permit
  the binding and view to be supported by the same code.
  We would then initially have three standard bindings:
    Java beans, XML, and HTML
  More could be created as needed, such as Mozilla XUL,
  and of course this would not prevent the continued
  use of templating and stylesheeting tools; just use a
  custom template in one binding direction and the new
  HTML binding to cover the other direction, no extra
  coding required.
</sudden-thought>

WDYT?
--Tim Larson

Re: [Woody] We need a booleanfield at all?

Posted by Sylvain Wallez <sy...@apache.org>.
tim@keow.org wrote:

>On Thu, Jan 22, 2004 at 04:28:29AM -0600, Antonio Gallardo wrote:
>  
>
>>We have 2 positions:
>>
>>1-booleanfield need to exist. It is a special handling case. If we need to
>>render it in other ways: comboboxes, radio buttons, etc. We need to do it
>>in a wi:styling.
>>
>>2-We don't need a boolean field at all, since it is just a special case of
>>wd:field. Let's rewrote the woody definition specification without
>>booleanfield.
>>    
>>
>
>If we need the speed provided by having a special handling class,
>then we could adapt the FieldDefinitionBuilder to choose to create
>a FieldDefinition or a BooleanFieldDefinition based on the features
>that are requested in the definition.  This way we could have the
>speed without having to provide wd:booleanfield as an exception to
>the otherwise clean wd:field-with-wd:datatype model.
>  
>

Honestly, I don't think speed is the real issue here...

>What if we introduce a new "null" attribute to the definition or
>to the datatype (which place makes more sense?):
>  attr missing - null or missing parameter means null
>  null="null"  - null or missing parameter means null
>  null="false" - null or missing parameter means "false"
>  null="true"  - for balance, would this have a use?
>This may be useful for other datatypes as well:
>  null="some-value" - null or missing parameter means "some-value"
><duck-and-run>
>  null="some-expression" - null or missing parameter causes
>    expression to be evaluated, possibly calculating a value
>    based on the values of other widgets.  The duck-and-run
>    is because this kind of logic may belong elsewhere...
></duck-and-run>
>  
>

IMO, this concern belongs more to the convertor than the datatype, as 
the convertor sits between the request parameters and the datatype and 
is in charge of converting these parameters from/to the datatype.

Furthermore, the value of the "null" attribute has to be converted into 
the target datatype, and this is again a convertor job!

And more: the boolean datatype can have two convertors. The default one 
will consider null as false, which will automagically handle HTML 
checkboxes. A second one, will consider null... as null and can be used 
for tri-state booleans.

WDYT?

>Optionally, for HTML checkbox rendering we could have the template
>generator/processor check to make sure that the "null" attribute
>is not missing or set to equal "null" for boolean valued fields.
>This would help prevent people from tripping over the mis-design
>of the HTML spec's handling of checkboxes.
>  
>

Mmmh... I'm not sure this is so simple, as the template engine doesn't 
know what the final rendering will be. What about my proposal above?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com