You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by asif_zzz <as...@meteximtechnologies.com> on 2008/12/29 09:48:24 UTC
How to create dynamic CForms Template,Definition and binding
Hi,
Im new to Cocoon ,and im using Cocoon 2.1.10,Spring ORM,Hibernate.
Till now i've been using static files(CForms template,definition,binding) to
generate the pages.
Now I need to create the fields based upon a data file(XML file).
I've parsed the XML file and i've the field names in a List.
How to do the above scernario??
Anyone please help to solve this problem.
Regards,
Aashik
--
View this message in context: http://www.nabble.com/How-to-create-dynamic-CForms-Template%2CDefinition-and-binding-tp21200337p21200337.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to create dynamic CForms Template,Definition and binding
Posted by asif_zzz <as...@meteximtechnologies.com>.
Hi mark,
Thanks :-).
i've done it, the way u said.
Its working fine.
Regards,
Aashik
--
View this message in context: http://www.nabble.com/How-to-create-dynamic-CForms-Template%2CDefinition-and-binding-tp21200337p21248582.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to create dynamic CForms Template,Definition and binding
Posted by Anish M <an...@yahoo.com>.
Hi,
I am facing the same problems with validations (using dynamic CForms).
Is there a solution for this or is it impossible to do this in cocoon?
Regards,
Anish
asif_zzz wrote:
>
> Hi Mark,
>
> Im facing some integration problems when dynamically creating the CForms
> Template,Definition and binding.
> My Global validation error block is not working when doing this. When i
> remove the dynamic artifacts,Global validation error block works fine.
>
> Both these features works independently.
>
> Any suggestion ,it would help me to solve this problem.
>
> Here i post the my codes which are related to it
>
> Sitemap.xmap
> -------------
>
> <map:match pattern="MainForm-dyna-tmpl">
> <map:generate src="forms/MainForm_tmpl.xml"/>
> <map:transform type="xinclude"/>
> <map:transform src="stylesheets/MainForm_tmpl.xsl"/>
> <map:serialize type="xml"/>
> </map:match>
>
> <map:match pattern="MainForm-dyna-defn">
> <map:generate src="forms/MainForm_defn.xml"/>
> <map:transform type="xinclude"/>
> <map:transform src="stylesheets/MainForm_defn.xsl"/>
> <map:serialize type="xml"/>
> </map:match>
>
> <map:match pattern="formDyna/**">
> <map:generate src="cocoon:/MainForm-dyna-tmpl" type="jx">
> <map:parameter name="lenient-xpath" value="true" />
> </map:generate>
> <map:transform type="xinclude"/>
> ....
> </map:match>
>
> Flow.js:
> -------------
>
> var form = new Form("cocoon:/MainForm-dyna-defn");
> form.showForm("formDyna/MainForm");
>
> MainForm_tmpl.xml:
> ---------------------
>
> <page>
> <ft:form-template id="mainForm"
> action="#{$cocoon/continuation/id}.continue" method="POST"
> enctype="multipart/form-data" ajax="true">
> <fi:validation-errors>
>
> <header><p><i18n:text>validationErrorMessageHeader</i18n:text></p></header>
>
> <footer><p><i18n:text>validationErrorMessageFooter</i18n:text></p></footer>
> </fi:validation-errors>
>
> ....
> <table>
> <fields type="sample" cols="5"/>
> </table>
> </ft:form-template>
> <xi:include href="../data/Fields.xml"/>
> </page>
>
> MainForm_defn.xml:
> ---------------------
>
> <fd:form
> xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
> xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
> xmlns:xi="http://www.w3.org/2001/XInclude">
>
> <fd:widgets>
> ....
> </fd:widgets>
> <xi:include href="../data/Fields.xml"/>
> </fd:form>
>
> Fields.xml:
> ----------------
> <infos xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
> <type1>
> <info name="c1"><i18n:text>text1</i18n:text></info>
> <info name="c2"><i18n:text>text2</i18n:text></info>
> ...
> </type1>
> </infos>
>
> MainForm_tmpl.xsl:
> ----------------------
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
> xmlns:ft="http://apache.org/cocoon/forms/1.0#template">
>
> <xsl:include
> href="resource://org/apache/cocoon/forms/resources/forms-page-styling.xsl"/>
> <xsl:include
> href="resource://org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl"/>
>
> <xsl:param name="resources-uri">resources</xsl:param>
>
> <xsl:template match="fields">
> <xsl:variable name="cellsPerRow" select="@cols"/>
> <xsl:variable name="type" select="@type"/>
> <xsl:for-each select="/page/infos/*[local-name()=$type]/info[position()
> mod $cellsPerRow = 1]">
> <tr>
> <xsl:apply-templates select=".|following-sibling::info[position()
> < $cellsPerRow]">
> </xsl:apply-templates>
> </tr>
> </xsl:for-each>
> </xsl:template>
>
> <xsl:template match="info">
> <td>
> <ft:widget-label>
> <xsl:attribute name="id"><xsl:value-of select="."/></xsl:attribute>
> </ft:widget-label>
> <ft:widget>
> <xsl:attribute name="id"><xsl:value-of
> select="@name"/></xsl:attribute>
> </ft:widget>
> </td>
> </xsl:template>
> </xsl:stylesheet>
>
> MainForm_defn.xsl:
> ----------------------
>
> My MainForm_defn stylesheet has the definition artifacts in <xsl:template
> match="info"> tagset,
> rest of the codes are same as MainForm_tmpl.xsl
>
> <xsl:template match="info">
> <fd:field>
> <xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
> <fd:label><i18n:text><xsl:value-of
> select="@name"/></i18n:text></fd:label>
> <fd:datatype base="string"/>
> </fd:field>
> </xsl:template>
>
>
> Thanks in Advance.
> Regards,
> Aashik
>
--
View this message in context: http://www.nabble.com/How-to-create-dynamic-CForms-Template%2CDefinition-and-binding-tp21200337p23575141.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to create dynamic CForms Template,Definition and binding
Posted by asif_zzz <as...@meteximtechnologies.com>.
Hi Mark,
Im facing some integration problems when dynamically creating the CForms
Template,Definition and binding.
My Global validation error block is not working when doing this. When i
remove the dynamic artifacts,Global validation error block works fine.
Both these features works independently.
Any suggestion ,it would help me to solve this problem.
Here i post the my codes which are related to it
Sitemap.xmap
-------------
<map:match pattern="MainForm-dyna-tmpl">
<map:generate src="forms/MainForm_tmpl.xml"/>
<map:transform type="xinclude"/>
<map:transform src="stylesheets/MainForm_tmpl.xsl"/>
<map:serialize type="xml"/>
</map:match>
<map:match pattern="MainForm-dyna-defn">
<map:generate src="forms/MainForm_defn.xml"/>
<map:transform type="xinclude"/>
<map:transform src="stylesheets/MainForm_defn.xsl"/>
<map:serialize type="xml"/>
</map:match>
<map:match pattern="formDyna/**">
<map:generate src="cocoon:/MainForm-dyna-tmpl" type="jx">
<map:parameter name="lenient-xpath" value="true" />
</map:generate>
<map:transform type="xinclude"/>
....
</map:match>
Flow.js:
-------------
var form = new Form("cocoon:/MainForm-dyna-defn");
form.showForm("formDyna/MainForm");
MainForm_tmpl.xml:
---------------------
<page>
<ft:form-template id="mainForm" action="#{$cocoon/continuation/id}.continue"
method="POST" enctype="multipart/form-data" ajax="true">
<fi:validation-errors>
<header><p><i18n:text>validationErrorMessageHeader</i18n:text></p></header>
<footer><p><i18n:text>validationErrorMessageFooter</i18n:text></p></footer>
</fi:validation-errors>
....
<table>
<fields type="sample" cols="5"/>
</table>
</ft:form-template>
<xi:include href="../data/Fields.xml"/>
</page>
MainForm_defn.xml:
---------------------
<fd:form
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
xmlns:xi="http://www.w3.org/2001/XInclude">
<fd:widgets>
....
</fd:widgets>
<xi:include href="../data/Fields.xml"/>
</fd:form>
Fields.xml:
----------------
<infos xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
<type1>
<info name="c1"><i18n:text>text1</i18n:text></info>
<info name="c2"><i18n:text>text2</i18n:text></info>
...
</type1>
</infos>
MainForm_tmpl.xsl:
----------------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:ft="http://apache.org/cocoon/forms/1.0#template">
<xsl:include
href="resource://org/apache/cocoon/forms/resources/forms-page-styling.xsl"/>
<xsl:include
href="resource://org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl"/>
<xsl:param name="resources-uri">resources</xsl:param>
<xsl:template match="fields">
<xsl:variable name="cellsPerRow" select="@cols"/>
<xsl:variable name="type" select="@type"/>
<xsl:for-each select="/page/infos/*[local-name()=$type]/info[position()
mod $cellsPerRow = 1]">
<tr>
<xsl:apply-templates select=".|following-sibling::info[position()
< $cellsPerRow]">
</xsl:apply-templates>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match="info">
<td>
<ft:widget-label>
<xsl:attribute name="id"><xsl:value-of select="."/></xsl:attribute>
</ft:widget-label>
<ft:widget>
<xsl:attribute name="id"><xsl:value-of
select="@name"/></xsl:attribute>
</ft:widget>
</td>
</xsl:template>
</xsl:stylesheet>
MainForm_defn.xsl:
----------------------
My MainForm_defn stylesheet has the definition artifacts in <xsl:template
match="info"> tagset,
rest of the codes are same as MainForm_tmpl.xsl
<xsl:template match="info">
<fd:field>
<xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
<fd:label><i18n:text><xsl:value-of select="@name"/></i18n:text></fd:label>
<fd:datatype base="string"/>
</fd:field>
</xsl:template>
Thanks in Advance.
Regards,
Aashik
--
View this message in context: http://www.nabble.com/How-to-create-dynamic-CForms-Template%2CDefinition-and-binding-tp21200337p21721707.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to create dynamic CForms Template,Definition and binding
Posted by asif_zzz <as...@meteximtechnologies.com>.
Hi Mark,
I'll try and get back to you.
Then That XML file(data file) is a static file.
Thanks and Regards,
Aashik
--
View this message in context: http://www.nabble.com/How-to-create-dynamic-CForms-Template%2CDefinition-and-binding-tp21200337p21230395.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to create dynamic CForms Template,Definition and binding
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Dec 29, 2008, at 12:48 AM, asif_zzz wrote:
>
> Hi,
> Im new to Cocoon ,and im using Cocoon 2.1.10,Spring ORM,Hibernate.
> Till now i've been using static files(CForms
> template,definition,binding) to
> generate the pages.
>
> Now I need to create the fields based upon a data file(XML file).
> I've parsed the XML file and i've the field names in a List.
> How to do the above scernario??
>
> Anyone please help to solve this problem.
The Cocoon Way™ :-) to solve this would be to take a step back and use
XLST and Cocoon's own pipeline machinery to generate the CForms
artifacts for you. So, you don't have to parse the XML document
yourself... instead, what you do is:
1) Create XSLT stylesheets to transform your XML source document into
the definition, binding and template documents
2) Create Cocoon pipeline(s) to process the XML source document
through the stylesheets you created in step (1)
3) Change the other bits that use the CForms artifacts to get them by
invoking your pipelines from step (2) (using the "cocoon://" URI
scheme).
People do this all the time. There's not all that much to it. Note
that there is no actual "file" created for the CForms artifacts using
this approach... it's just streams.
Just out of curiosity, where are you getting the XML source document
that you want to create the CForms artifacts from? Is this a static
file, or are you generating it dynamically as well?
HTH,
—ml—