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.

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* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Dear Rashel,

    Could you give an example/snippet of one of these .xml files ?

    Bart

    2007/4/18, Rashel Shehata <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>>:

        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

Reply via email to