You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Frédéric Ledent <fr...@market-ip.com> on 2004/03/19 17:32:39 UTC

RE : Tapestry Torque

Hi,

Here is an example how to configure Torque in Tapestry :

public class InitTorque extends HttpServlet {
  public void init(ServletConfig config) throws ServletException {	
	super.init(config);
	try {
	  InputStream configStream = 
	
getServletContext().getResourceAsStream(config.getInitParameter("configT
orque"));
	  PropertiesConfiguration c = new PropertiesConfiguration();
	  c.load( configStream );
	  Torque.init(c);  
	}
	  catch ( IOException e ) {
	  throw new ServletException( e.toString() );
	}
	  catch ( TorqueException e ) {
	  throw new ServletException( e.toString() );
	}
  }
}

and in your web.xml you should add :

    <servlet-name>InitTorque</servlet-name>
    <servlet-class>com.mycompany.InitTorque</servlet-class>
	    <init-param>
	      <param-name>configTorque</param-name>
	      <param-value>/WEB-INF/Torque.properties</param-value>
	    </init-param> 
	    <load-on-startup>2</load-on-startup>    
  	</servlet>	


If you are used to work with Torque, you should don’t have any problem
in Tapestry.

Simple Example : 

public void formLoginSubmit(IRequestCycle cycle) {
	Criteria criteria = new Criteria();
	criteria.add(UserPeer.LOGIN,login);
	criteria.add(UserPeer.PASSWD,password);
	User user = UserPeer.doSelect(criteria);
	If (user != null) {
		...
		cycle.activate("HomePage");
	}
}


Fred

-----Message d'origine-----
De : secam secam [mailto:secam2004@yahoo.fr] 
Envoyé : vendredi 19 mars 2004 16:53
À : Tapestry users
Objet : Tapestry Torque

hi,
 
I'm new in tapestry
  
Have you got some simple example that illustrate the connection to a 
database using torque in tapestry?
 
Thanks,
Regard's
Secam


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.591 / Virus Database: 374 - Release Date: 17/02/2004
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org