Proposal to allow the declarative specification of dynamic widgets in Woody:
(Use case that is driving dynamic widgets: web-based form and report design gui)
Bruno, if you have a chance could you comment on this before you are gone for the week?
Make the form definition dynamic:
Rely on aggregation, etc. to ensure all widget definitions are in the same source.
Create a container <wd:widgets/> for reusable widget definitions.
Create <wd:include/> to reference the reusable widget containers.
Create a new discriminated "union" widget with methods:
setCase(id) to change the distriminant and corresponding widgets.
getCase() to return the current discriminant id.
Sample form definition:
<wd:form xmlns:wd="http://apache.org/cocoon/woody/definition/1.0">
<wd:widgets id="fullname">
<wd:field id="firstname" required="true">
<wd:datatype base="string"/>
<wd:label>First Name</wd:label>
</wd:field>
<wd:field id="middlename" required="true">
<wd:datatype base="string"/>
<wd:label>Middle Name</wd:label>
</wd:field>
<wd:field id="lastname" required="true">
<wd:datatype base="string"/>
<wd:label>Last Name</wd:label>
</wd:field>
</wd:widgets>
<wd:union id="name" default="noname">
<wd:case id="noname"/>
<wd:case id="nickname">
<wd:field id="nickname" required="true">
<wd:datatype base="string"/>
<wd:label>Nickname</wd:label>
</wd:field>
</wd:case>
<wd:case id="fullname">
<wd:include id="fullname"/>
</wd:case>
</wd:union>
</wd:form>
Make the form template dynamic:
Rely on aggregation, etc. to ensure all templates are in the same source.
This will allow support for recursively nested unions.
Create a container <wt:templates/> for reusable templates.
Create <wt:include/> to reference the reusable template containers.
Create <wt:union/> to select templates based on the widget instance discriminants.
The context in <wt:union/> is the contained widgets so recursively included
templates will reference the proper widgets. We would need to introduce
xpath-like syntax (e.g. "/widget", "../widget", and "widget/widget") to allow
other widgets to be referenced from templates contained in a union.
Sample form template:
<page xmlns:wt="http://apache.org/cocoon/woody/template/1.0">
<title>The Title</title>
<content>
<wt:form-template action="#{$continuation/id}.continue" method="POST">
<wt:templates id="fullname">
<wt:widget-label id="firstname"/>: <wt:widget id="firstname"/>
<wt:widget-label id="middlename"/>: <wt:widget id="middlename"/>
<wt:widget-label id="lastname"/>: <wt:widget id="lastname"/>
</wt:templates>
<wt:union id="name">
<wt:case id="noname"/>
<wt:case id="nickname">
<wt:widget-label id="nickname"/>: <wt:widget id="nickname"/>
</wt:case>
<wt:case id="fullname">
<wt:include id="fullname"/>
</wt:case>
</wt:union>
<input type="submit"/>
</wt:form-template>
</content>
</page>
Make the binding dynamic:
I have not worked on this yet, but it will probably follow the same pattern
as the definitions and templates sections.
Make the flowscript support the dynamic widgets:
I will look at this next, along with the binding.
Well, that is the preliminary view. Before the design gets finished and coded,
what do others think of this? Am I on the right track? What could be done better?
--Tim Larson
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com