Dennis
Not sure exactly what your question is... if I phrase it as
"how can I easily get data for my CForm selection list
from a database without using a bean" then the answer is:
1. setup a field in your form template/definition
<fd:field id="special">
<fd:label>Theme</fd:label>
<fd:datatype base="string"/>
<fd:selection-list src="cocoon:/form-sql/theme.xml" dynamic="true"/>
</fd:field>
2. in your sitemap have a match for the above call:
<!-- === data for form from database list === -->
<map:match pattern="form-sql/theme.xml">
<map:generate src="docs/basic-sql.xml"/> <!-- step 3 below -->
<!-- === SQL Connector ==== -->
<map:transform type="sql">
<map:parameter name="use-connection" value="connection_name"/>
<map:parameter name="show-nr-of-rows" value="true"/>
<map:parameter name="clob-encoding" value="UTF-8"/>
</map:transform>
<map:transform src="stylesheets/widget-theme.xsl"/> <!-- step 4 below -->
<map:serialize type="xml"/>
</map:match>
3. a XML page containing the SQL for the generator step:
<?xml version="1.0" encoding="UTF-8"?>
<fd:selection-list
xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
>
<sq2:execute-query xmlns:sq2="http://apache.org/cocoon/SQL/2.0">
<!-- SQL statement or stored procedure -->
<sq2:query name="themes">
SELECT ID,Name FROM MyTableName
</sq2:query>
</sq2:execute-query>
</fd:selection-list>
4. a stylesheet to transform the XML from the database into a list;
below is an example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
>
<!-- root -->
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<!-- list -->
<xsl:template match="fd:selection-list">
<fd:selection-list>
<xsl:apply-templates select="sq2:rowset"/>
</fd:selection-list>
</xsl:template>
<!-- rowset -->
<xsl:template match="sq2:rowset">
<xsl:apply-templates select="sq2:row"/>
</xsl:template>
<!-- row -->
<xsl:template match="sq2:row">
<fd:item value="{sq2:id}"><fd:label><xsl:value-of select="sq2:name"/></fd:label></fd:item>
</xsl:template>
</xsl:stylesheet>
HTH,
Derek
>>> dennis_riedel@web.de 2005/06/02 02:15:07 PM >>>
Hello.
Is there no other possibility for dynamic selection lists than
-flow-jxpath implementation
-enum implementation
??
I want to load the data for my selection list from database and like the
JSF idea with backing beans load my bean into my form.
So the selection list should be able to read the collection of items,
display them and I must save the selection in my bean to save the data
to database.
Thx for any idea.
Dennis
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
|