You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by John Austin <jo...@integerservices.no-ip.com> on 2002/05/29 02:04:58 UTC
Database Action assistance request.
I have been poking around trying to find out whether
DatabaseSelectAction can help me.
There is very little written about this action and I wonder whether it
has ever been used (or even tested).
My problem is as follows:
I have a column in a table in a database that I am able to access from
XSP and Java with no problems. In the interest of elegance I would like
to make the item available to an XSLT Transformation as a parameter.
All I want to do is supply the key column 'name', get the corresponding
row and then use the value of the field 'company' later in my pipeline
as: {company}.
Sitemap.xmap contains:
<map:actions>
<map:action name="select-user" logger="databaseselectaction"
src="org.apache.cocoon.acting.DatabaseSelectAction"/>
</map:actions>
And the matching pipeline entry is:
<map:match pattern="process">
<!-- first validate whether user has logged in -->
<map:act type="session-validator">
<map:parameter name="descriptor"
value="context://alpha/descriptors/params.xml"/>
<map:parameter name="validate" value="username"/>
<!-- generate protected content -->
<map:act type="form-validator">
<map:parameter name="descriptor"
value="context://alpha/descriptors/getfiles_form.xml"/>
<map:parameter name="validate" value="filename"/>
<!-- form-validation success -->
<map:act type="select-user">
<map:parameter name="descriptor"
value="context://alpha/descriptors/getuser.xml"/>
<map:generate type="serverpages" src="docs/process.xsp"/>
<map:transform src="stylesheets/dynamic-page2html.xsl">
</map:transform>
<map:serialize/>
</map:act>
</map:act>
<!-- form-validation failure -->
<map:redirect-to uri="pickdoc"/>
</map:act>
<!-- session-validation failed ==> redirect to login-page -->
<map:redirect-to session="true" uri="login"/>
</map:match>
The value "username" is captured by a form earlier in the session and
exists as a session attribute.
<root>
<parameter name="username" type="string" nullable="no"/>
<!--parameter name="company" type="string"/-->
<connection>phoenix</connection>
<table name="users">
<keys>
<key param="username" dbcol="name" type="string" mode="form"/>
</keys>
<values>
<value param="company" dbcol="company" type="string"/>
</values>
</table>
</root>
I include the username in the URL as I don't know how else to supply it
to the Action.
I have read the databaseSelectAction code and understand how the SELECT
statement is generated.
I have recompiled cocoon.jar with additional getLogger().debug(
"yadayadayada." ) statements but these never generate output. Anyone
care to tell me why ?
I have had some success with cocoon but I am finding it difficult to
get through to some advanced features because of the sparse
documentation.
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Database Action assistance request.
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 28.May.2002 -- 08:04 PM, John Austin wrote:
> I have been poking around trying to find out whether
> DatabaseSelectAction can help me.
>
> There is very little written about this action and I wonder whether it
> has ever been used (or even tested).
>
> My problem is as follows:
>
> I have a column in a table in a database that I am able to access from
> XSP and Java with no problems. In the interest of elegance I would like
> to make the item available to an XSLT Transformation as a parameter.
>
> All I want to do is supply the key column 'name', get the corresponding
> row and then use the value of the field 'company' later in my pipeline
> as: {company}.
Doesn't work. DatabaseSelectAction return an empty map. Values are
available only as request attributes.
> I include the username in the URL as I don't know how else to supply it
> to the Action.
It reads them from request parameters. Whether they are set via GET or
POST does not matter.
> I have recompiled cocoon.jar with additional getLogger().debug(
> "yadayadayada." ) statements but these never generate output. Anyone
> care to tell me why ?
Have you associated a log target with the action? Otherwise the
messages are lost.
Although they are only in scratchpad for 2.0.x I highly advise to use
the database actions from the org.apache.cocoon.acting.modular
package. BTW those do return a map filled with all the results on a
select.
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>