You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Garvin Riensche <g....@gmx.net> on 2003/12/03 19:22:44 UTC

modular database actions

hi there,

i tried to create a simple example with modular database actions. the only
thing i want cocoon to do is to store a number from a form field into my
database. but it seems like cocoon doesn't propagate the input number from
the form to the action as i always get this error:

Could not add record

org.apache.cocoon.ProcessingException: Could not add record:
java.sql.SQLException: General error, message from server: "Column 'number'
cannot be null"

i am using cocoon 2.1m2 with mysql on windows xp.

the sitemap:

<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
	<map:actions>
		<map:action name="add-number"
src="org.apache.cocoon.acting.modular.DatabaseAddAction">
			<descriptor>number.xml</descriptor>
			<throw-exception>true</throw-exception>
		</map:action>
	</map:actions>
</map:components>

<map:pipelines>
	<map:pipeline>
	<map:match pattern="start">
		<map:read src="input.html" mimy-type="text/html"/>
	</map:match>

	<map:match pattern="store-number">
		<map:act type="add-number">
			<map:parameter name="table-set" value="number"/>
			<map:read src="success.html" mimy-type="text/html"/>
		</map:act>
		<map:read src="error.html" mimy-type="text/html"/>
	</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>

number.xml:

<?xml version="1.0"?>
<root>
	<connection>MySQL</connection>
	<table name="numbers" alias="numbers">
		<keys>
			<key name="uid" type="int" autoincrement="true">
				<mode name="auto" type="autoincr"/>
			</key>
		</keys>

	<values>
		<value name="number" type="int"/>
	</values>
	</table>

	<table-set name="number">
		<table name="numbers"/>
	</table-set>
</root>

input.html:

<html>
<head>
</head>
<body>
	<form action="store-number" method="post">
		<h1>Number: </h1>
		<input name="number" type="int"/>
		<input type="submit" value="ok"/>
	</form>
</body>
</html>

My database table consists of 2 rows: "uid" as primary key and "number".

It would be great if someone could help.


regards,
Garvin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: modular database actions

Posted by Garvin Riensche <g....@gmx.net>.
Sorry!!! I forgot to change the email adress...

> > To explicitly ask for "number" you would do
> > 
> >      <value name="number" type="int">
> >         <mode type="all" name="request-param">
> >             <parameter>number</parameter>
> >         </mode>
> >      </value>
> 
> Vielen Dank!  Jetzt funktioniert es.

regards,
Garvin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: modular database actions

Posted by Garvin Riensche <g....@gmx.net>.
Hallo Christian,

> To explicitly ask for "number" you would do
> 
>      <value name="number" type="int">
>         <mode type="all" name="request-param">
>             <parameter>number</parameter>
>         </mode>
>      </value>

Vielen Dank!  Jetzt funktioniert es.

Viele Gru?e,
Garvin 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: modular database actions

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Garvin Riensche wrote:
> hi there,
> 
> i tried to create a simple example with modular database actions. the only
> thing i want cocoon to do is to store a number from a form field into my
> database. but it seems like cocoon doesn't propagate the input number from
> the form to the action as i always get this error:
> 
> Could not add record
> 
> org.apache.cocoon.ProcessingException: Could not add record:
> java.sql.SQLException: General error, message from server: "Column 'number'
> cannot be null"

> 	<table name="numbers" alias="numbers">
> 		<keys>
> 			<key name="uid" type="int" autoincrement="true">
> 				<mode name="auto" type="autoincr"/>
> 			</key>
> 		</keys>
> 
> 	<values>
> 		<value name="number" type="int"/>
> 	</values>
> 	</table>
> 
> 	<table-set name="number">
> 		<table name="numbers"/>
> 	</table-set>
> </root>
> 
> input.html:
> 
> <html>
> <head>
> </head>
> <body>
> 	<form action="store-number" method="post">
> 		<h1>Number: </h1>
> 		<input name="number" type="int"/>
> 		<input type="submit" value="ok"/>
> 	</form>
> </body>
> </html>

By default the parameter name is expected to be table.column, hence
numbers.number. So you could either change the name of the input
element, explicitly ask for the attribute "number", or configure the
action to not prepend the table name.

To explicitly ask for "number" you would do

     <value name="number" type="int">
        <mode type="all" name="request-param">
            <parameter>number</parameter>
        </mode>
     </value>

Mind you that I might have mixed up @type and @name, so please
cross check with the docs.

	Chris.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org