cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <Ralph.Go...@digitalinsight.com>
Subject RE: Action problem
Date Sun, 18 Jan 2004 01:27:53 GMT
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 

<form action="testpage" method="post"? 

2. sitemap 

			<map:match pattern="testpage"> 
				<map:act type="get-detail2"> 
					<map:generate type="file"
src="content/main.xml" /> 
					<map:transform
scr="style/main.xsl"> 
						<map:parameter
name="first_name" value="{first_name}" /> 
					</map:transform> 
				</map:act> 
				 
			<map:redirect-to uri="login.html" /> 
			</map:match> 



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


Mime
View raw message