You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2004/07/16 15:44:06 UTC
Forms and Database storage [was Re: woody and "big"
radiobutton list]
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
>>> joose@iki.fi 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
>
>>>> joose@iki.fi 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/ * joose@iki.fi * +358 44 561 0270 *
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> --
> 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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Forms and Database storage [was Re: woody and "big" radiobutton
list]
Posted by Ugo Cei <u....@cbim.it>.
Joose Vettenranta wrote:
> I did not find anything related to hibernate in cocoon 2.1.3, perhaps
> hibernate is still in expiremental feature?
First: there's a licensing problem so, unless the ASF decides that
distributing (L)GPL code is OK, you won't find code that depends on
Hibernate in the Cocoon repository for the foreseeable future.
Second: even if it wasn't for the licensing problems, it's not that you
can expect Cocoon to integrate every database access technology under
the sun. Hibernate is just a Java library, so there's nothing stopping
you from using it from whatever Cocoon component you like.
However, it seems that someone has already done something for you. You
can find a Cocoon application that uses Hibernate here:
http://wiki.apache.org/cocoon/SpringPetstore
And if you happen to dislike Hibernate and would prefer OJB instead,
there's a OJB block in the latest Cocoon release (2.1.5).
I think you have plenty of examples to look at.
> I have to check this Hibernate more closely, it would be very nice to
> have some documentation or even a page "What is hibernate and what is it
> for" would be nice :)
Ever tried Google? http://hibernate.org
Ugo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Forms and Database storage [was Re: woody and "big" radiobutton list]
Posted by Joose Vettenranta <jo...@iki.fi>.
Hi,
> Part 1: Forms fields
Thanks derek for detailed sample. The thing I missed was that I can
give cocoon: -style urls to selection-list.
> 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
I thought that modular db is better than using esql.. But I did not
know any other way to do these things.
> 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
I did not find anything related to hibernate in cocoon 2.1.3, perhaps
hibernate is still in expiremental feature?
I have to check this Hibernate more closely, it would be very nice to
have some documentation or even a page "What is hibernate and what is
it for" would be nice :)
Thank you very many, Joose
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org