jdk-1_5_0-windows-i586.exe;
Eclipse3.2.exe;
eclipse3.2andmyeclipse5.0(MyEclipseEnterpriseWorkbenchInstaller_5.0.1GA_E3.2.exe);
jakarta-tomcat-5.0.28;
备注:先安装jdk-1_5_0-windows-i586.exe,然后安装Eclipse3.2.exe(如果是绿化版,则不需要安装)。
在安装MyEclipseEnterpriseWorkbenchInstaller_5.0.1GA_E3.2.exe时,工作路径指向Eclipse的安装主目录。
1)先创建一个CVS库的链接。
2)Check Out(或者Check Out AS)
3) 然后转到“MyEclipse J2EE Development”.
4)JDK和 tomcat 服务配置。
该步骤会生成两类文件*.java 和*.xml文件,需要修改XML文件:
修改:
<hibernate-mapping>
<class name="VO.EamCompanies" table="EAM_COMPANIES" schema="EAIS_UPDATE">
<id name="companyId" type="java.lang.Long">
为:
<hibernate-mapping>
<class name="com.enstrong.mis.resource.companies.vo.EamCompanies" table="EAM_COMPANIES">
<id name="companyId" type="java.lang.Long">
修改:
<set name="eamCompcontacts" inverse="true">
<key>
<column name="COMPANY_ID" precision="22" scale="0" />
</key>
<one-to-many class="VO.EamCompcontact" />
</set>
</class>
</hibernate-mapping>
为:
<set name="eamCompcontacts" inverse="true">
<key>
<column name="COMPANY_ID" precision="22" scale="0" />
</key>
<one-to-many class="com.enstrong.mis.resource.companies.vo.EamCompcontact" />
</set>
</class>
</hibernate-mapping>
然后把修改后的*.xml文件和*.java文件 拷贝的MyEclipse Web Project 的 src的VO包中;O/R映射就结束;
注意:在创建Service时,要进行Struts和Hibernate的配置:
Spring Service配置:applicationContext-service.xml :
<!-- 公司信息service -->
<bean id="EamCompaniesServiceImp" parent="txProxyTemplate">
<property name="target">
<bean class="com.enstrong.mis.resource.companies.service.EamCompaniesServiceImp">
<property name="companiesDao" ref="companiesDao"></property>
</bean>
</property>
</bean>
<!-- 公司联系人信息service -->
<bean id="EamCompcontactServiceImp" parent="txProxyTemplate">
<property name="target">
<bean class="com.enstrong.mis.resource.companies.service.EamCompcontactServiceImp">
<property name="compcontactDao" ref="compcontactDao"></property>
<property name="companiesDao" ref="companiesDao"></property>
</bean>
</property>
</bean>class="com.enstrong.mis.resource.companies.dao.EamCompcontactImp">
<property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
Hibernate配置:applicationContext-hibernate.xml :
<!-- 公司信息 -->
<bean id="companiesDao" class="com.enstrong.mis.resource.companies.dao.EamCompaniesDaoImp">
<property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<!-- 公司联系人信息 -->
<bean id="compcontactDao" class="com.enstrong.mis.resource.companies.dao.EamCompcontactImp">
<property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
另外,在Service创建dao对象时要注意get 和 set 方法;
public class EamCompaniesForm extends ActionForm implements java.io.Serializable
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="companyBean" type="com.enstrong.mis.resource.companies.actionform.EamCompaniesForm"></form-bean>
</form-beans>
<action-mappings>
<action name="companyBean" path="/eamCompaniesAction" validate="false" parameter="method" scope="request" type="com.enstrong.mis.resource.companies.action.EamCompaniesAction">
<forward name="forwardMain" path="/pages/resource/companies/main_companies.jsp" />
<forward name="forwardGrid_companies" path="/pages/resource/companies/grid_companies.jsp" />
<forward name="forwardTab_companies" path="/pages/resource/companies/tab_companies.jsp" />
<forward name="forwardTab_compcontact" path="/pages/resource/companies/tab_companies_contact.jsp" />
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>
假如上面创建的配置文件的名称是“struts-config-resource.xml”,需要在工程的web.xml中增加 Action servlet 配置
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>
/WEB-INF/struts-config.xml,/WEB-INF/struts-config-sysinit.xml,/WEB-INF/struts-config-ranliao.xml,/WEB-INF/struts-config-sampling.xml,/WEB-INF/struts-config-equipment.xml,/WEB-INF/struts-config-runmanager.xml,
/WEB-INF/struts-config-sampling.xml,/WEB-INF/struts-config-material.xml,/WEB-INF/struts-config-pm-ht.xml,/WEB-INF/struts-config-produce.xml,/WEB-INF/struts-config-hr.xml,
/WEB-INF/struts-config-planmanager.xml, /WEB-INF/struts-config-overhaul.xml,/WEB-INF/struts-config-workflow.xml,/WEB-INF/struts-config-resource.xml
</param-value>主页面DoSearch方法:
function doSearch(page) {
cur_page = (page==undefined)?1:page;
companyName = dojo.byId("companiesName").value;
companyCode = dojo.byId("companiesCode").value;
dojo.io.bind({
url: "<%=request.getContextPath()%>/eamCompaniesAction.do",
encoding: 'UTF-8',
method: 'post',
content: {
method: 'getCompainesListByPage',
cur_page: cur_page,
companyName: companyName,
companyCode: companyCode
},
load: function(type, data, evt) {
resetAll();
//dojo.debug('success!!!!!' );
dojo.widget.byId("main").setContent(data);
//alert(data);
fixdg();
},
error: function(type, error) {
dlgShow('搜索失败!!!!');
},
mimetype: "text/plain"
});
}