Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 88619 invoked from network); 26 Mar 2006 09:48:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Mar 2006 09:48:52 -0000 Received: (qmail 51270 invoked by uid 500); 26 Mar 2006 09:48:50 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 51228 invoked by uid 500); 26 Mar 2006 09:48:50 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 51217 invoked by uid 99); 26 Mar 2006 09:48:49 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO [127.0.0.1]) (209.237.227.194) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Mar 2006 01:48:49 -0800 Message-ID: <44266347.4060901@apache.org> Date: Sun, 26 Mar 2006 11:47:51 +0200 From: Carsten Ziegeler User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Cocoon-Dev Subject: CForms and Portlets - making form ids dynamic X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N While cforms is excellent for developing form based applications, it has some (minor) problems if Cocoon is used in a portal environment, being it the Cocoon portal or Cocoon used as a JSR 168 portlet in a different portal container. One of the problems is the uniqueness of ids in the resulting html: each form and input field gets an id based on it's definition in the model. While this works perfectly in a standalone environment this might lead to problems with portals: the portlet may be displayed more than once or the generated ids might interfere with ids generated by other portlets. Therefore a portal usually provides kind of a namespace for each portlet. Fortunately, CForms based applications can make use of such namespaces if you set the id of the form to this namespace. This will then lead to unique ids as the id of the form is prefixed to each input field (the mechanism is in fact more general). The only drawback is that you have to specify this id in the model. And this means that the model is dynamic as each portlet instance must have an own model as each instance must have a different id for the form. This works but of course the form model is never cached. To make cforms more portal friendly I suggest to extend the form creating a little bit by: - adding a createInstance(String formId) method to the FormDefinition - adding createForm(source, String formId) methods to the FormManager - adding a Form(formDefinition, formId) method to form.js WDYT? Or is there a better solution? Carsten -- Carsten Ziegeler - Open Source Group, S&N AG http://www.s-und-n.de http://www.osoco.org/weblogs/rael/