cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashel Shehata" <rashe...@gmail.com>
Subject Re: dynamic cForm generation
Date Thu, 19 Apr 2007 00:19:35 GMT
Hi,
Thank you all for all the help...
I am trying the suggestion found in
https://issues.apache.org/jira/browse/COCOON-1418
so many thanks for the hint

Regards


On 4/18/07, Jason Johnston <cocoon@lojjic.net> wrote:
>
> Philippe Gauthier - INSERM SIRH wrote:
> >   Hi Rashel,
> >
> > U shouldn't use a dynamic form definition, because it means for each
> > call, cocoon will have to compile a new form and can't use any caching.
> > I did the same mistake using xslt transformation to generate the
> > definition (using pipelineToStream to save it to disk temporary) and it
> > killed the JVM eventually .
> > And that's why the form instantiation function takes only system file.
> >
> > Instead u have to understand the binding concepts of forms an redesign a
> > or some generic forms definition and templates with more complex
> widgets.
> > Then u'll be have able to fill thoses forms with dynamic data.
> > I hope I gave U the right pointers, sorry for my english.
>
> I agree that it's preferable to have a static form definition with
> dynamic widgets that modify the structure of the form at runtime.  But
> there are cases where that's not possible, so true dynamic form creation
> is a useful tool to have.
>
> What you say about caching the form definition is also true but is only
> an issue if the pipeline that generates it is not cacheable.  If all of
> that pipeline's components are cacheable then the form definition is
> cached IIUC.
>
> Rashel, what you are looking for I believe is this:
>
>   var form = new Form("cocoon:/my-dynamic-form-def-pipeline");
>
> That uses the result of a Cocoon pipeline to build the form definition.
> Unfortunately, currently the Form constructor does not allow passing
> flow attributes as a second argument; there is an open issue in Jira for
> adding that feature: https://issues.apache.org/jira/browse/COCOON-1418
>
> In the absence of that feature you can pass along the data in another
> way, for instance setting it as an attribute on the request.  Or you
> could try applying the patch attached to that Jira issue.
>
> Finally, if you're using JX to generate the definition XML, I'd strongly
> suggest using jx:cache-key and jx:cache-validity to control the caching
> of the result if possible, that way you'll avoid the performance/memory
> issue Philippe warned of.  This feature might only be available in the
> 'newjx' version of JXTemplateGenerator; details at
> http://wiki.apache.org/cocoon/JXTemplateGenerator
>
> --Jason
>
> >
> > regards,
> >
> > Philippe
> >
> > Rashel Shehata a écrit :
> >> Hi Bart,
> >> Ok so  to create the form definition xml the jx generator uses the
> >> following xml file:
> >> I pass it an array object (questionRegistry.getAllQuestions()) that
> >> contains a list of all the questions to be created in the form
> >>
> >> <?xml version="1.0"?>
> >> <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
> >>          xmlns:i18n=" http://apache.org/cocoon/i18n/2.1"
> >>     xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
> >>
> >>
> >> <fd:widgets>
> >>
> >>    <jx:forEach var="question" items="${questions}">
> >>
> >>    <jx:choose>
> >>  <jx:when test="${question.responseType == 'multivalue-field'}">
> >>   <fd:multivaluefield id='${question.ID}'
> >> required='${question.required}' state='${question.state}'>
> >>     <fd:label>     ${question.label} </fd:label>
> >>     <fd:help>${ question.help}</fd:help>
> >>        <fd:hint>${question.hint}</fd:hint>
> >>      <fd:datatype base="long"></fd:datatype>
> >>      <fd:selection-list>
> >>      <jx:forEach var="response" items="${ question.responses}">
> >>      <fd:item value='${response.ID}'>
> >>         <fd:label>${response.label}</fd:label>
> >>         </fd:item>
> >>
> >>    </jx:forEach>
> >>    </fd:selection-list>
> >>   </fd:multivaluefield>
> >>
> >>   </jx:when>
> >>
> >>   <jx:when test="${question.responseType == 'checkbox'}">
> >>   <fd:booleanfield id='${question.ID}' required='${
> >> question.required}' state='${question.state}'>
> >>     <fd:label>     ${question.label} </fd:label>
> >>     <fd:help>${question.help}</fd:help>
> >>        <fd:hint>${question.hint }</fd:hint>
> >>    </fd:booleanfield>
> >>
> >>   </jx:when>
> >>
> >>  <jx:otherwise>
> >>    <fd:field id='${question.ID}' required='${question.required}'
> >> state='${question.state}'>
> >>        <fd:label>     ${question.label} ${question.responseType }
> >> </fd:label>
> >>     <fd:help>${question.help}</fd:help>
> >>        <fd:hint>${question.hint}</fd:hint>
> >>
> >> ...
> >>
> >>   </fd:field>
> >>  </jx:otherwise>
> >>    </jx:choose>
> >>    </jx:forEach>
> >>  </fd:widgets>
> >>  </fd:form>
> >>
> >>
> >>
> >>
> >> the jx generator then outputs the serialized xml to the browser, where
> >> the xml is in correct cForm syntax... it's similar for the
> >> form template also...
> >>
> >> I now want to do use both serialized xml and feed it back into a
> >> pipeline entry so i can view the generated form as a HTML form...
> >>
> >>
> >>
> >> I hope this made my problem clearer..
> >>
> >>
> >>
> >> Thanks heaps
> >>
> >> On 4/18/07, *bart remmerie* <remmerie@gmail.com
> >> <mailto:remmerie@gmail.com>> wrote:
> >>
> >>     Dear Rashel,
> >>
> >>     Could you give an example/snippet of one of these .xml files ?
> >>
> >>     Bart
> >>
> >>     2007/4/18, Rashel Shehata <rashel.s@gmail.com
> >>     <mailto:rashel.s@gmail.com>>:
> >>
> >>         Hey,
> >>
> >>         I'm trying to generate cocoon forms dynamically. atm I create
> >>         the cForm model xml dynamically using jx generator; this is
> >>         what i have:
> >>
> >>         in my flowscript:
> >>           cocoon.sendPage("form_model-pipeline.xsp" ,
> >>              {questions: questionRegistry.getAllQuestions()});
> >>
> >>         and in my pipeline:
> >>         <map:match pattern="*-pipeline.xsp">
> >>                <map:generate type="jx" src="forms/{1}.xml"/>
> >>                <map:serialize type="xml"/>
> >>              </map:match>
> >>
> >>         the jx generator creates a cForm xml model in correct syntax
> >>         and is outputted as XML to the browser...
> >>
> >>         what im trying to do now is feed this newly generated xml
> >>         model to the pipeline so that a Form will be generated and
> >>         viewed, however i'm not really sure how to do this, or which
> >>         part of cocoon docos i sould be reading...
> >>         How do I dynamically generate input content to be used as a
> >>         source in the sitemap??
> >>
> >>
> >>         Any help would be appreciated...
> >>
> >>
> >>
> >>
> >>
> >>
> >>     --
> >>     Bart Remmerie
> >>
> >>
> >
> >
> > --
> > Philippe Gauthier
> > INSERM
> > DRH - SIRH
> > Tel: 01.44.23.62.57
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Mime
View raw message