db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caron, Roger A." <roger.ca...@pw.utc.com>
Subject RE: Torque and jsp
Date Tue, 15 Mar 2005 14:57:28 GMT
I use the commons-configuration-1.0-dev-3.jar which has a new method in
org.apache.commons.configuration.ConfigurationFactory called
setConfigurationURL().  This is used to get a Configuration object which you
then use in Torque.init(configuration) in place of Torque.init(pathName).
My code then looks like this:

        ConfigurationFactory factory = new ConfigurationFactory();
        URL configURL =
this.getClass().getResource("/Torque.properties.xml"); // an xml file in my
web-inf directory
        try {
            Configuration configuration = factory.getConfiguration();
    	} catch (Exception ex) {

Then the contents of Torque.properties.xml are:

<?xml version="1.0" encoding="ISO-8859-1" ?>

  <properties fileName="Torque.properties"/>

You may have some versioning issues by getting that newer
commons-configuration jar so you may also need newer versions of other jars,
like beanutils-1.6.1, collections-2.1, lang-2.0, etc.  I have all these
newer jars but don't remember if I needed them specifically because of the
updated configuration jar.


-----Original Message-----
From: raphael.x.mankin@gsk.com [mailto:raphael.x.mankin@gsk.com]
Sent: Tuesday, March 15, 2005 9:42 AM
To: Apache Torque Users List
Cc: Apache Torque Users List
Subject: Re: Torque and jsp

Torque.init() requires an absolute pathname. It's a bummer.

I put the true pathname in another properties file so that I do not have to
hard-code it in the program. This does mean, however, that I have to know
the absolute path where, in my case, Tomcat is installed. Here is my
initialisation code

        apiResources = ResourceBundle.getBundle("betapi");
        if (!Torque.isInit()) {
            String configFile = apiResources.getString
            try {
            } catch (TorqueException e) {
                  context.log(e,"Cannot initalise Torque: " + e.toString()

and betapi.properties contains:

In cases where I build on one machine but run on another I have a little
shell script that that runs on installation. It tracks down the appropriate
line in betapi.properties and adjusts it so suit where the code is actually

|         |           "salwa idrissi"  |
|         |           <idrissi82@yahoo.|
|         |           fr>              |
|         |                            |
|         |                            |
|         |           15-Mar-2005 14:19|
|         |           Please respond to|
|         |           "Apache Torque   |
|         |           Users List"      |
|         |           <torque-user@db.a|
|         |           pache.org>       |
|         |                            |
  |       To:      "Apache Torque Users List" <torque-user@db.apache.org>
  |       cc:
  |       Subject: Re: Torque and jsp

the problem is not confusing presentation and model but when i compile in
jdev i have the exception "Could not open file Torque.properties"because i
must put it in a specific directory in jdev that i don't know.

this is the code:


<table width="165" border="0" cellpadding="2" cellspacing="0" class
Iterator i;
List listecr=(List)session.getAttribute("liste");
 i = listecr.iterator();
 while ( i.hasNext() )
  Ecriture monecriture = (Ecriture) i.next();
           <td width="8" align="center">
                      <%= monecriture.getCodeetape()%>



      public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
    HttpSession session=request.getSession();

    AddEcriture test=new AddEcriture();

    return mapping.findForward("success");


package si.av;

import java.util.*;
import org.apache.torque.Torque;
import org.apache.torque.util.Criteria;
import si.av.om.*;

public class AddEcriture

 List listecrs;
 public List getListecrs()
 {return listecrs;}

  public void afficher()

     Criteria critaffichage=new Criteria();


  catch(Exception e){e.printStackTrace();}


 Découvrez nos promotions exclusives "destination de la Tunisie, du Maroc,
des Baléares et la Rép. Dominicaine sur Yahoo! Voyages.

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

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

View raw message