db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sgarlata Matt" <sgarlata_m...@bah.com>
Subject Re: Developing with Torque and Struts
Date Fri, 25 Jul 2003 13:28:49 GMT
Hi Cameron,

Here is the structure we use in my project.  It is just an example
structure, there are others that could work equally well.  My example
assumes you are using Tomcat for development, in which case the "PROJECT"
directory would be <<tomcat dir>>/webapps/PROJECT

The structure for JSP is very flexible, depending on whether you use
application modules in struts.  In the exampe below I do use application
modules, but if you did not then you would probably just place all your JSP
directly in PROJECT/

PROJECT/document (this is a struts module)
PROJECT/admin (this is a struts module)
PROJECT/css (css go here)
PROJECT/images (images go here)
PROJECT/WEB-INF (web.xml, struts-config.xml, validation-rules.xml, torque
build properties, etc. go here)
PROJECT/WEB-INF/lib (torque.jar, struts.jar, and other jar files)
PROJECT/WEB-INF/cp (classes that are needed to successfully compile your
code, but your web server does not need included in the lib directory.  for
example, we have jndi-1.2.1.jar here and servlet.jar here)
PROJECT/WEB-INF/src (all java files go here.  if you have a class called
com.mycompany.myproject.ExampleClass then it would go in
PROJECT/WEB-INF/src/com/mycompany/myproject/ExampleClass.java)
PROJECT/WEB-INF/classes (all compiled classes go here.  So the previous
example would end up compiling to
PROJECT/WEB-INF/classes/com/mycompany/myproject/ExampleClass.class)

This is nearly impossible to get working using javac.  You should download
and use ant.  Here is a starter build.xml file you can use.  It should be
placed in PROJECT/WEB-INF:

<project name="example" default="compile">

 <!-- set global properties for this build -->
 <property name="src" location=".\src"/>
 <property name="build" location=".\classes"/>
 <property name="lib" value=".\lib"/>
 <property name="javadoc" value=".\..\javadoc"/>
 <!-- libraries already included in the servlet engine but that need to be
included for javadoc to work propertly -->
 <property name="cp" value=".\cp"/>

 <target
  name="all"
  description="perform all tasks"
  depends="compile,javadoc"/>

 <target name="compile" description="compile the source ">
  <!-- Compile the java code from ${src} into ${build} -->
  <javac
   srcdir="${src}"
   destdir="${build}"
   debug="on">
   <classpath>
    <fileset dir="${lib}">
     <include name="**/*.jar"/>
     <include name="**/*.zip"/>
    </fileset>
    <fileset dir="${cp}">
     <include name="**/*.jar"/>
     <include name="**/*.zip"/>
    </fileset>
    <pathelement location="${}"/>
   </classpath>
  </javac>
  <!-- copy any .properties files from ${src} to ${build} -->
  <copy todir="${build}">
   <fileset dir="${src}" includes="**/*.properties"/>
  </copy>
 </target>

 <target name="deprecation" description="compile with depreceation
information">
  <!-- Compile the java code from ${src} into ${build} -->
  <javac
   srcdir="${src}"
   destdir="${build}"
   deprecation="on">
   <classpath>
    <fileset dir="${lib}">
     <include name="**/*.jar"/>
     <include name="**/*.zip"/>
    </fileset>
    <fileset dir="${cp}">
     <include name="**/*.jar"/>
     <include name="**/*.zip"/>
    </fileset>
    <pathelement location="${}"/>
   </classpath>
  </javac>
  <!-- copy any .properties files from ${src} to ${build} -->
  <copy todir="${build}">
   <fileset dir="${src}" includes="**/*.properties"/>
  </copy>
 </target>

 <!-- defined for the recompile target.  probably not useful on its own -->
 <target
  name="delclasses"
  description="deletes old class files">
  <delete>
   <fileset dir="${build}">
    <include name="**/*.class"/>
   </fileset>
  </delete>
 </target>

 <target
  name="recompile"
  description="remove old class files and recompile"
  depends="delclasses,compile"/>

 <target name="javadoc" description="generate documentation">
  <!-- Compile the java code from ${src} into ${build} -->
  <javadoc
   sourcepath="${src}"
   destdir="${javadoc}"
   windowtitle="EBS Plans &amp; Programs API">
   <classpath>
    <fileset dir="${lib}">
     <include name="**/*.jar"/>
     <include name="**/*.zip"/>
    </fileset>
    <fileset dir="${cp}">
     <include name="**/*.jar"/>
     <include name="**/*.zip"/>
    </fileset>
    <pathelement location="${}"/>
   </classpath>
   <packageset dir="${src}" defaultexcludes="yes"/>
   <!-- not sure what this is -->
   <group title="Core Packages in the KRM framework"
packages="com.bah.krm.*"/>
   <group title="Packages specific to this application"
packages="com.bah.*"/>
   <!-- Java 1.3 SE API -->
   <link href="http://java.sun.com/j2se/1.3/docs/api/"/>
   <!-- Struts 1.1 API -->
   <link href="http://jakarta.apache.org/struts/api/"/>
   <!-- Torque 3.0 API -->
   <link href="http://db.apache.org/torque/apidocs/"/>
   <!-- Servlet 2.3 API -->
   <link href="http://java.sun.com/products/servlet/2.3/javadoc/"/>
   <!-- log4j -->
   <link href="http://jakarta.apache.org/log4j/docs/api/"/>
   <!-- jakarta regexp 1.2 -->
   <link href="http://jakarta.apache.org/regexp/apidocs/"/>
   <!-- junit -->
   <link href="http://www.junit.org/junit/javadoc/3.8.1/"/>
   <!-- Jakarta Commons Validator -->
   <link href="http://jakarta.apache.org/commons/validator/apidocs/"/>
   <!-- Jakarta Commons Logging -->
   <link href="http://jakarta.apache.org/commons/logging/api/"/>
   <!-- Village 1.5.3 -->
   <!-- not working right now
   <link
href="http://share.whichever.com/village/village-1.5.3/docs/apidocs/"/>
   -->
   <!-- Java 1.3 EE -->
   <link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
  </javadoc>
 </target>

</project>

I hope that helps!  Let me know if you have more questions.

Matt
----- Original Message ----- 
From: "Cameron Hickey" <cam@panoramatos.com>
To: <torque-user@db.apache.org>
Sent: Friday, July 25, 2003 7:52 AM
Subject: Developing with Torque and Struts


> Although I am new to the whole world of JSP development, have been spent
> a significant learning about developing web apps with struts.  I had
> originally been using Hibernate for my Object Persistence, but after
> purchasing a Struts Quickstart guide, I have decided to move over to
> torque because it seems a little more straightforward and simple to use.
>
>
> My questions are rudimentary:
>
> How should I set up my development structure so that I can get
> everything to compile correctly?
>
> This is the basic structure I am trying to work from:
>
> PROJECT/lib
> PROJECT/web
> PROJECT/src
> PROJECT/src/torque
> PROJECT/src/torque/om
> PROJECT/src/torque/om/map
> PROJECT/src/struts
> PROJECT/src/struts/action
> PROJECT/src/struts/form
>
>
> I cannot figure out how to get the 2 sides of my component (struts and
> torque) to build properly using ant.
>
> In all my searching, I have only found a logical structure for the
> resulting WAR, but not for the development environment.
>
> Can anyone provide a working example that accounts for logical placement
> of the different build configuration files, and where the resultant
> compiled classes should land.
>
> Do you normally compile the torque classes separately from the other
> action and form classes?
>
> Thanks for any advice
>
> Cameron Hickey
>
>
>
>


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


Mime
View raw message