Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 97106 invoked by uid 500); 1 Jul 2003 05:36:51 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 97082 invoked from network); 1 Jul 2003 05:36:50 -0000 Received: from dobit2.ugent.be (HELO dobit2.rug.ac.be) (157.193.42.8) by daedalus.apache.org with SMTP; 1 Jul 2003 05:36:50 -0000 Received: from allserv.UGent.be (allserv.ugent.be [157.193.40.42]) by dobit2.rug.ac.be (8.12.8/8.12.8) with ESMTP id h615b1Y1027020 for ; Tue, 1 Jul 2003 07:37:01 +0200 (MEST) Received: from otsrv1.iic.rug.ac.be (otsrv1.iic.ugent.be [157.193.121.51]) by allserv.UGent.be (8.12.8/8.12.8) with ESMTP id h615b0Sf012143 for ; Tue, 1 Jul 2003 07:37:00 +0200 (MEST) Received: from outerthought.org (host117 [192.168.123.117]) by otsrv1.iic.rug.ac.be (8.11.6/8.11.6) with ESMTP id h615b0x24980 for ; Tue, 1 Jul 2003 07:37:00 +0200 Message-ID: <3F011DFB.6090706@outerthought.org> Date: Tue, 01 Jul 2003 07:36:59 +0200 From: Marc Portier User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en, nl-be MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: [woody] binding the forms to data Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi all, just want to share some thoughts on a possble nice addition for the woody forms, feel free to comment (see http://wiki.cocoondev.org/Wiki.jsp?page=Woody 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? b.saveFormToModel(frm,model)? The actual binding definition file could be filled with: and possibly a bit more complex constructs to ease on the typing with context narrowing: 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( jxpc.getPointer(this.xpath)); continueLoadingFromChildren(c, subContext); } similar there could be binding for repeaters and the new aggregate fields 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= -- Marc Portier http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center Read my weblog at http://radio.weblogs.com/0116284/ mpo@outerthought.org mpo@apache.org