cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Portier <>
Subject [woody] binding the forms to data
Date Tue, 01 Jul 2003 05:36:59 GMT
Hi all,

just want to share some thoughts on a possble nice addition for 
the woody forms, feel free to comment
(see for the 
miinimal current docs)

the woody forms as of today allow you to define the form-model 
(woody-definition file, with some validation in there) and have a 
way to template the defined widgets into an HTML-form frame 
(woody-template file)

however, filling the form with data comming from your backend 
needs to be done programmtically (various 
frm.getWidget(..).setValue (..) calls)

this got me thinking (and thinkering) towards a declarative way 
for expresiing what I would call 'form-binding'

Using a similar factory/builder pattern as the current woody 
forms there could be some binding-definition file that gets build 
  into some runtime Binding object that actually performs the 
trick for you:

Form frm ...;
BindingManager bm = serviceManager.lookup("..");
Binding b = bm.createBinding(source);

Object model = BackendService.interact();

b.loadFormFromModel(frm, model);

// and something similar for the way back?

The actual binding definition file could be filled with:
<bnd:field id="widget-name"
            path="xpath expression into model" />

and possibly a bit more complex constructs to ease on the typing 
with context narrowing:

<bnd:context path="xpath to context">
   <bnd:field  path="relative-path" id="widget-name" />
   <bnd:field  path="relative-path" id="widget-name" />

Thinking about a context like 'address' and fields as
'addressline', 'city', 'zip'

This would call for the Binding object to be in fact a nested 
tree of binding objects reflecting the widget-tree inside the 
form.  Each of these Binding objects could then narrow the scope 
of the current context and pass over to the children to continue 
on the binding. (assuming jxpath usage for inspecting the model)

e.g. for this context-thing:
public void loadFormFromModel(
        ContainerWidget c, JXPathContext jxpc){

     JXPathContext subContext;
     subContext = jxpc.getRelativeContext(

     continueLoadingFromChildren(c, subContext);

similar there could be binding for repeaters and the new 
aggregate fields

<bnd:repeater path=".." id="..">
   <bnd:field .../>

<bnd:aggregate path=".." id="..">
   <bnd:field .../>

Using JXPath there should be a fairly easy way to have this 
binding work for a backend producing either javabeans or XML files.

what do people think?

Marc Portier                  
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                        

View raw message