Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 62780 invoked from network); 18 Jan 2004 01:28:39 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 18 Jan 2004 01:28:39 -0000 Received: (qmail 7801 invoked by uid 500); 18 Jan 2004 01:28:15 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 7786 invoked by uid 500); 18 Jan 2004 01:28:14 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 7772 invoked from network); 18 Jan 2004 01:28:14 -0000 Received: from unknown (HELO warden.diginsite.com) (208.29.163.248) by daedalus.apache.org with SMTP; 18 Jan 2004 01:28:14 -0000 Received: from wlvims01.diginsite.com by warden.diginsite.com via smtpd (for daedalus.apache.org [208.185.179.12]) with SMTP; Sat, 17 Jan 2004 17:28:23 -0800 Received: from WLVIMS01 ([127.0.0.1]) by WLVIMS01.digitalinsight.com (Post.Office MTA v3.5.3 release 223 ID# 0-0U10L2S100V35) with SMTP id com; Sat, 17 Jan 2004 17:28:21 -0800 Received: by calexc01.diginsite.com with Internet Mail Service (5.5.2657.72) id ; Sat, 17 Jan 2004 17:27:55 -0800 Message-ID: <31DF72A980E5D511B48C000102BD868503EA817F@calexc01.diginsite.com> From: Ralph Goers To: 'beyaNet Consultancy ' , "'users@cocoon.apache.org '" Subject: RE: Action problem Date: Sat, 17 Jan 2004 17:27:53 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I don't see a serializer in your pipeline... Ralph -----Original Message----- From: beyaNet Consultancy To: users@cocoon.apache.org Sent: 1/17/2004 1:34 PM Subject: Action problem hi, I have written an action which is meant to, for the meantime, return a single column value. The problem is that you continually keep getting redirected to the login page, which is meant to happen if a map is not returned successfully. What am I missing? This action is called from a login page as so: 1.login.html
3. Action package test; import org.apache.avalon.excalibur.datasource.DataSourceComponent; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentSelector; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.activity.Disposable; import org.apache.cocoon.Constants; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.acting.AbstractAction; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.sql.SQLException; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; public class GetUserDetail2 extends AbstractAction implements ThreadSafe, Composable, Disposable { protected ComponentSelector dbselector; protected ComponentManager manager; public void compose(ComponentManager manager) throws ComponentException { this.dbselector = (ComponentSelector) manager.lookup(DataSourceComponent.ROLE + "Selector"); } protected final DataSourceComponent getDataSource(String pool) throws ComponentException { return (DataSourceComponent) this.dbselector.select(pool); } public Map act ( Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters param) throws Exception { Request request = ObjectModelHelper.getRequest(objectModel); Map map = new HashMap(); DataSourceComponent dataSource = getDataSource("postgresql"); Connection conn = null; try { conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); String cmd = "Select user_id, first_name, last_name, address1, address2, address3, postcode, country, email, home_telephone, mobile_telephone, date_joined from usertbl where username = 'x' and userpassword = 'y'"; ResultSet rs = stmt.executeQuery(cmd); if (rs.next()) { map.put("first_name", rs.getString(1)); } rs.close(); stmt.close(); }catch (Exception e){ getLogger().error("Query failed: ", e); }finally { try { if (conn != null) conn.close(); }catch (SQLException sqe) { getLogger().warn("Error closing the datasource", sqe); } } return (map); } public void dispose() { this.manager.release(dbselector); } } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org