Joose

You are starting to venture in deeper waters here!

Part 1: Forms fields

This is not so hard, but quite fiddly....

Your form model will look like:

    <fd:field id="special">
      <fd:label>Movie Theme</fd:label>
      <fd:datatype base="string"/>
       <!-- from internal pipeline... database call to get list data
-->
      <fd:selection-list  src="cocoon:/form-sql/theme.xml"
dynamic="true"/> 
    </fd:field> 

And the form template (layout) will have

      <ft:widget id="special">
         <fi:styling list-type="radio" list-orientation="vertical"
class="form-about"/>
      </ft:widget>

(as Helma has said, you can also have "horizontal" orientation for
shorter lists)

In your sitemap you will need:

     <!-- === data for form from database list === -->
     <map:match pattern="form-info/theme.xml">
       <map:generate src="docs/basic-sql.xml"/>
       <!-- === SQL Connector ==== -->       
       <map:transform type="sql">
         <map:parameter name="use-connection" value="theme_user"/>
         <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"/>
       <map:serialize type="xml"/>
     </map:match>  

The basic-sql.xml file looks like:

<?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";> 
    <sq2:query name="themes">
      SELECT ThemeID, ThemeDesc FROM MovieTheme
    </sq2:query>
  </sq2:execute-query>
  
</fd:selection-list>

The widget-theme.xsl stylesheet I use is:

<?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>
<!-- select 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:themeid}"><fd:label><xsl:value-of
select="sq2:themedesc"/></fd:label></fd:item>
</xsl:template>


Part 2:  Saving to a database

The move is away from ESQL and Modular DB actions
to  3rd party database persistence layers.. this is an 
area new to me, too - a number of folk here are using
Hibernate BUT there has been very little documentation
produced (despite numerous pleas from me - see the mail
archives!!).  Start in the wiki with the various Hibernate
samples; you can also see the one I did that attempts 
to make CForms work with Flow; its broken somewhere
and so far no one has come forward to help (sorry!).
This is a big learning curve, but will probably pay off in
the longer term.

HTH

Derek


>>> [EMAIL PROTECTED] 2004/07/16 03:09:42 PM >>>
Hi Derek.. Seems like I little bit over simplified my need =)

Anyway, concerning to this, my next question is:

If I have data on SQL-server, how can I make it as a forms field as 
radiobutton list?
Is it possible if:
a) I don't know the result-set
b) I know the result set but only part of it are shown?

so-> viewing forms page, would work so, that options to radiolist would

be fetched from database.

Also.. How to save that damn data? If used from flowscript, do I just 
create some page which get's input from bizData and saves it to 
database using ESQL? I was thinking that perhaps it could be done with

modular database actions (atleast it would look very nice to do it
so).

Thanks,

Joose

16.7.2004 kello 14:40, Derek Hohls kirjoitti:

  Joose
>
> Any reason you cannot use Cocoon 2.1.5; the
> CForms are a fairly stable and more evolved
> verison of Woody  - and certainly support radio
> buttons!
>
> Derek
>
>>>> [EMAIL PROTECTED] 2004/07/16 01:37:49 PM >>>
> Hi,
>
> seems like woody is nice, but I did not find a way to do radiobuton
> list like this;
>
> <label> <radiobutton>
> <label2> <radiobutton>
> <label3> <radiobutton>
>
> Is this possible to implement?
>
> (cocoon 2.1.3)
>
> Thanks, Joose
>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 *
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
>
>
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> MailScanner thanks transtec Computers for their support.
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 *


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to