see,look,rise,raise

see:I see a book on the table.

look:I look at your face.

(wrong:I look your face.)

rise:A snake rises up from a backet.(active)

(wrong:A snake raises up from a backet.)

raise:I raise a stone.(passive)

we can do our program as a plugin

This program can be easy to install on another's website.

and we can import and export everyone's entire or part of articles with XML technique.XML is must be used!

And,all kinds of documentation in our developing website should use XML as well,like http://argouml.tigris.org.In this way,the content can be communicated between any program which can support XML.

I insist an idea:the idea is first,and the technique is second!

Do you agree with me?

Please give your idea about what function should be included in our website(program).

The ideas we can refer:www.43things.com

Before yesterday,my friend TangYong told me there are some web site like ours.He gave me some link:

       http://www.blogcn.com/user14/davidczg/blog/22723065.html

        http://www.43things.com/

        http://www.aimi.cn/

        http://www.sharethings.com.cn/

I found these website are like ours very much:guiding with a self-selected goal,and sharing processing with diary.Instead of we are focusing on the learning,their scope cover all things(all goals) that we will to do.and,they use Tag,XML,etc. technique.

I am very happy there are another people are interesting this style,and,we can learn them,exchange with them.

  I think,we will own good future if we do this with my heart and brain,eyes,hands.

need "j2ee.jar" added to classpath when hibernate

Today,I am trying Hibernate and use Hibernatesynch for eclipse2.1 plugin got some classes.

When I run this program on Tomcat5.0,the page always reports:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: javax/transaction/Synchronization

net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:314)

net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:327)

net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:335)

com.asprise.business._BaseRootDAO.createSession(_BaseRootDAO.java:116)

com.asprise.business._BaseRootDAO.createSession(_BaseRootDAO.java:107)

com.asprise.business._BaseRootDAO.getSession(_BaseRootDAO.java:99)

com.asprise.business._BaseRootDAO.find(_BaseRootDAO.java:162)

com.asprise.business.UserBean.findUsers(UserBean.java:23)

com.asprise.struts.action.OwnerAction.performViewUsers(OwnerAction.java:61)

com.asprise.struts.action.OwnerAction.execute(OwnerAction.java:51)

org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:448)

org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:263)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1176)

org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:454)

javax.servlet.http.HttpServlet.service(HttpServlet.java:697)

javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.

--------------------------------------------------------------------------------

Apache Tomcat/5.0.25

I found there are two ways to resolve this problem:

1.add j2ee.jar to program's "/web-inf/lib" folder or javax.transaction.Synchronization.class to it's "/web-inf/classes" folder;

2.add the file to tomcat's "/common/lib" or "/common/classes" as above.

I don't know why this happened,I have configed the classpath environment "d:\j2ee1.3\lib\j2ee.jar",and configed the "J2EE_HOME" is "d:\j2ee1.3".

Is there anyone can answer me this question,by any chance please?

definition of "classfier"(转贴)

 MOF以及MOF四层结构的理解(2)

2005-06-30 10:43:41 The(158587432)

请阁下给出keven->人?>?的答案

2005-06-30 10:43:51 The(158587432)

我就卡在这个关头了!

2005-06-30 10:44:06 keven(184014384)

我还是希望你可以自己悟到。

2005-06-30 10:44:12 The(158587432)

难悟啊!

2005-06-30 10:51:07 中国幽剑软件(465572013)

谢谢了,终于找到头绪了

2005-06-30 10:51:11 The(158587432)

我钻进死胡同了,感觉出不来了,脑袋也晕掉了

2005-06-30 10:51:35 keven(184014384)

你们两个感觉完全相反哦。

2005-06-30 10:52:19 The(158587432)

不是吧,他先前也认为我说keven->人?>物种是对的

2005-06-30 10:52:23 中国幽剑软件(465572013)

因为我喜欢简单,再复杂的东西我都喜欢找一种简单的例子来说明它,呵呵........

2005-06-30 10:52:39 中国幽剑软件(465572013)

好像我没有说吧?

2005-06-30 10:53:38 keven(184014384)

那我说了。

2005-06-30 10:54:02 The(158587432)

这样说的话,"元"就表示"如何"构建,"物种"这个概念是表明了如何构建"人"这个"物种",而"人"又表明了如何构建"keven"。是这样的啊?

然后,你说“对头‘

2005-06-30 10:54:45 中国幽剑软件(465572013)

我说的对头是指keven说的要实际应用,呵呵.......

2005-06-30 10:55:27 The(158587432)

[:L]

2005-06-30 10:55:48 The(158587432)

下午再来,现在要去吃饭,并且休息一下,我已经脑袋很痛了!!!!

2005-06-30 10:56:10 keven(184014384)

其实很简单:

keven

人(类)

类(UML)

类元(MOF)

2005-06-30 10:57:01 中国幽剑软件(465572013)

不用头痛,“对象”这个词我理解了两年才真正弄明白它的内涵呢

2005-06-30 11:04:17 keven(184014384)

呵呵,答案出来了,人也跑了。

2005-06-30 11:05:22 中国幽剑软件(465572013)

现在我不说我明白了,等我有机会把它正确的扔到我的图里的时候,才说明我明白了.....

2005-06-30 11:05:38 keven(184014384)

呵呵,有志气。

2005-06-30 11:07:02 中国幽剑软件(465572013)

我说了,我今天开始学习UML(理论以前看过)和Plato,我今天就开始用它做项目,错误和更好的方法少了还得keven指教了.........

2005-06-30 11:07:44 keven(184014384)

好的。

2005-06-30 11:09:21 中国幽剑软件(465572013)

暂时潜水,玩玩VC,没有实现的经验设计出来的东西可能不好用的.........呵呵..........

2005-06-30 14:28:53 The(158587432)

下午来报道!

 

2005-06-30 14:30:06 webmaster(344593239)

现在想明白了吧?

2005-06-30 14:30:28 The(158587432)

没想明白

2005-06-30 14:31:20 webmaster(344593239)

嗬嗬,可惜早上keven说答案的时候,你已经走了

2005-06-30 14:33:25 The(158587432)

就先前中午睡觉,脑袋痛,迷糊的很,云里雾里感觉到人后面应该是类,也算沾边了不少。但是刚刚看到,keven说类后面是类元,那翻译过去就是classifier,关于classifier,uml参考手册上是这么说的:a model element that describes the behavioral and structural features.

2005-06-30 14:34:23 The(158587432)

类元包括类,actor,component,等等,这不是混淆了吗?那构造型到底扩展的是第几层》?

2005-06-30 14:34:45 The(158587432)

头痛啊~~~

2005-06-30 14:37:27 keven(184014384)

首先搞明白:为什么类是人(类)的元?

2005-06-30 14:37:41 The(158587432)

uml参考手册里面说association is the semantic relationship that two or more classifiers that involves connection among their instances.

这不就是classifier是元模型层

2005-06-30 14:38:35 The(158587432)

类是人的元,我在感觉上已经赞同了,精确的表述出来,我还要想想

2005-06-30 14:39:09 The(158587432)

uml参考手册竟然不能复制,要手敲英文!

2005-06-30 14:40:55 The(158587432)

我的理解:类应该是具有属性集和方法集的整体,而人这个类具体讲明了属性集里有哪些属性,方法集里有哪些方法,实例化了属性集和方法集

2005-06-30 14:41:02 The(158587432)

对不?

2005-06-30 14:42:45 keven(184014384)

呵呵,对啦。

2005-06-30 14:43:02 keven(184014384)

终于有些明白了。

2005-06-30 14:43:23 The(158587432)

类元解释不过去啊,就我刚说的那些问题

2005-06-30 14:44:25 keven(184014384)

我这里的类元不是UML里的类元,而是MOF里的类元。

2005-06-30 14:44:54 The(158587432)

哦?~难怪

 

2005-06-30 14:45:25 keven(184014384)

MOF里的类和UML里的类名字一样,概念却完全不一样:MOF里的类是UML里的类的元数据,即定义了UML里的类;

而MOF里的类由谁定义呢?

2005-06-30 14:46:03 The(158587432)

好象错开了一个层次

2005-06-30 14:46:15 The(158587432)

这些个老外,写文挡也不致意一致!

2005-06-30 14:46:34 keven(184014384)

告诉我,MOF里的类的元数据是谁?

2005-06-30 14:47:03 The(158587432)

那在uml里,classifier和metacalss是不是一回事情

2005-06-30 14:47:23 The(158587432)

MOF里的类的元数据?我先查查术语啊

2005-06-30 14:48:04 keven(184014384)

现学现卖?

2005-06-30 14:48:34 The(158587432)

是啊,中午头痛的很,睡觉去了,睡觉中,还迷糊地在想这些个问题呢

2005-06-30 14:49:08 keven(184014384)

呵呵

2005-06-30 14:49:23 The(158587432)

类元啊

2005-06-30 14:50:00 The(158587432)

那在uml里,classifier和metaclass是不是一回事情

2005-06-30 14:50:10 keven(184014384)

又错了。

M1定义M0,

M2定义M1,

M3定义M2

那么谁定义M3?

2005-06-30 14:50:19 The(158587432)

M4

2005-06-30 14:50:45 keven(184014384)

那岂不无限了,M10000...

2005-06-30 14:50:48 The(158587432)

等等,本来就只四层,说到M4,似乎又错了,那就没得去定义

2005-06-30 14:51:08 The(158587432)

我也刚刚发现这个问题

2005-06-30 14:52:22 keven(184014384)

metaclass可以认为是MOF层的类。

而Classifier是UML层的类的父类。

不一个层次。

2005-06-30 14:52:37 keven(184014384)

M3定义自身。呵呵。

2005-06-30 14:53:24 The(158587432)

想一分钟~

2005-06-30 14:56:23 The(158587432)

不是 ,uml手册里面写的:metaclass:a class whose intances are classes

2005-06-30 14:56:50 keven(184014384)

呵呵。

所谓元:就是实例和类的关系。instance

2005-06-30 14:56:58 The(158587432)

这不明确表示metaclass是类的父类?

 

2005-06-30 14:57:22 keven(184014384)

实例和泛化是两个概念。

2005-06-30 14:57:41 The(158587432)

精髓啊!!!!

2005-06-30 14:58:09 The(158587432)

好象有点悟了~~~

还差术语通关!

2005-06-30 14:58:09 keven(184014384)

明白了?

2005-06-30 14:58:11 The(158587432)

谢谢

2005-06-30 14:59:15 /catAcaT/cat(367021)

我是来拜2位牛人了,受我253一计,hoho

2005-06-30 15:00:44 The(158587432)

实例化即为赋值,泛化即为扩展~

对不?

2005-06-30 15:01:13 keven(184014384)

赋值???

2005-06-30 15:01:43 The(158587432)

我是这样想的啊

2005-06-30 15:02:17 keven(184014384)

实例就是类和对象的关系。

2005-06-30 15:03:21 The(158587432)

我的意思是赋值是实例化的过程,就像实例化一个类,先是构造建立一个空的未初始化对象,然后对其进行每项赋值

2005-06-30 15:03:34 The(158587432)

我认为就这样

2005-06-30 15:03:56 keven(184014384)

呵呵。

2005-06-30 15:05:46 The(158587432)

就像先前说的类和人,人就对类的属性集和方法集在它们未初始化后进行赋值。先建造容器,再填充

2005-06-30 15:06:21 keven(184014384)

呵呵,大家都明白了。

2005-06-30 15:06:46 The(158587432)

元赋予了容器的语义,而下一步操作就是根据这个语义和实际应用需求进行填充

2005-06-30 15:07:19 The(158587432)

这里的容器就是一个概念,只有装满了东西,才能够成为真正的实例

2005-06-30 15:07:28 The(158587432)

你是说我明白了?

2005-06-30 15:07:33 The(158587432)

[:D]

2005-06-30 15:07:41 keven(184014384)

[strong]

2005-06-30 15:07:54 The(158587432)

谢谢您的指点!

2005-06-30 15:08:32 The(158587432)

我想我刚说的赋予和扩展是分辨这两个关系的好切入点

2005-06-30 15:08:39 keven(184014384)

呵呵,没事。实践三个代表,人人有责。

2005-06-30 15:11:05 The(158587432)

能再问两三个关于很实际的术语方面的问题吗?不知道是否耽误您的时间。

敬上!

2005-06-30 15:11:18 keven(184014384)

说。

2005-06-30 15:11:48 The(158587432)

那我就一鼓作气把问题搞懂了。谢谢

2005-06-30 15:12:39 The(158587432)

stereotype扩张的是元模型层对吗?

2005-06-30 15:13:33 The(158587432)

我说的是uml中的概念,都不涉及MOF

2005-06-30 15:13:36 keven(184014384)

对,可以认为和UML类同级的兄弟。

2005-06-30 15:14:10 The(158587432)

那profile就是一个充满构造型的包包?

2005-06-30 15:15:04 The(158587432)

在uml的概念范围中,classifier和metaclass应该是同一个概念?

 

2005-06-30 15:15:08 keven(184014384)

还有标记,约束。

2005-06-30 15:15:30 The(158587432)

呵呵,记住了

2005-06-30 15:16:00 keven(184014384)

在uml的概念范围中,classifier和metaclass不是同一个概念。刚才已经解释过了。

2005-06-30 15:20:35 keven(184014384)

一个定义结构:元。

一个定义数据:泛化。

2005-06-30 15:21:39 The(158587432)

大三了,毕业不考研,希望到你们公司工作。我会努力的!

2005-06-30 15:24:46 The(158587432)

不是,我觉得你们楚凡,感觉起来是一帮子实打实的人,而且名字上又有个“楚”字,我是湖南人呢。

跟这样的一群人打交道,感觉很好

 

 

 

我是www.trufun.net站长!

 

 本贴发表时间:2005-7-2 11:02:08

 

Struts开发技巧

/*看到这篇文章不错,害怕后来被删除了,于是把它保存在这里。*/

  Struts开发技巧

Struts配置文件

事件对应的类主要有Action、ActionForm

struts开发中一些的规范

Struts开发技巧

谢?

在经历了《中国电信大客户贴心服务》项目的开发以及目前正在开发中的《中国电信经营分析》项目,已累计了一些对于Struts1.1和Tiles开发的一些技术和技巧,特写出来,方便以后的开发,同时也相信能给读者在开发Struts方面提供一些帮助。

在经历了《中国电信大客户贴心服务》项目的开发以及目前正在开发中的《中国电信经营分析》项目,已累计了一些对于Struts1.1和Tiles开发的一些技术和技巧,特写出来,方便以后的开发,同时也相信能给读者在开发Struts方面提供一些帮助。

模块配置

1.     Struts配置文件定义

   对于系统中的某个模块,需要在开发前定义该模块的配置,该struts的配置文件命名为:

struts-config-xxx.xml

xxx为模块的小写英文名或缩写,如:struts-config-sysman.xml

注意:中间为"-",而不是"_"连接符

统一保存在"WEB-INF\xml"文件夹下,并需要在web.xml中添加相应的配置文件

地址,具体如下例:

       ...

  <init-param>

      <param-name>config</param-name>

      <param-value>/WEB-INF/struts-config.xml, /WEB-INF/xml/struts-config-pages.xml,/WEB-INF/xml/struts-config-sysman.xml</param-value>

       </init-param>

...

注意:需要用","连接符隔开各个配置文件名

另外,所有的静态jsp需要通过配置文件定义其".do"形式的访问,保存在

struts-config-pages.xml文件中,内容如下例:

  ...

  <!--主页转向-->

  <action path="/main" type="org.apache.struts.actions.ForwardAction" parameter="/main.jsp"/>

  ...

2.         Tiles配置文件定义

系统的框架配置文件为tiles-defs_zh_CN.xml(通过.properties属性文件支持国际化应用,默认是tiles-defs.xml),模块的框架结构需要定义在里面,如下例:

...

<!-- 定义默认首页 -->

    <definition name="default.frame" path="/layouts/defaultLayout.jsp">

        <put name="title"  value="欢迎进入电信经营分析系统" />

        <put name="header" value="/top.jsp" />

        <put name="body"   value="default.body" />

        <put name="footer" value="/buttom.jsp" />

    </definition>

<!-- 定义默认首页的body -->  

    <definition name="default.body" path="/layouts/main.jsp" >

  <put name="logon"   value="/logon.jsp" />

  <put name="date" value="/layouts/date.jsp" />

       <put name="linkSite"   value="/layouts/link.html" />

    </definition>

...

框架命名规范按"系统(子系统).功能模块.页面模块",如上面的"default.frame"

在struts-config-pages.xml文件中的设置的页面action可以这样写:

<action path="/main" type="org.apache.struts.actions.ForwardAction" parameter=" default.frame "/>

这样就不必单独写一个tiles:insert的页面,如下:

<tiles:insert definition="vip.warn.day" flush="true" />

3.         模块中的注释

不但需要在程序中添加必要的注释,在定义配置文件的时候也必须需要添加相应注释,主要是在struts-config-xxx.xml和tiles- defs_zh_CN.xml这些文件中添加注释,要把action或配置模块的功能解释清楚,放在配置项的前面,参见上面的配置文件

4.         对于配置文件的编辑

不能使用Jbuilder里面的xml编辑功能,因为JB会自动地改变xml里面的编码和内容,因此,对xml配置文件的编辑,要使用编辑软件,如UE等

事件定义

事件对应的类主要有Action、ActionForm,还有jsp中提交的".do"定义,以及页面动作的提交,以login登录为例:

1.  类的命名定义(首字母需大写)

形式为"动作名+Action/Form"

如:LoginAction.class、LoginForm.class

2.  页面地址定义(首字母需小写)

如果有两个单词以上,第二个单词首字母大写,依此类推

形式为"动作名"

如:login.do或loginSys.do

jsp文件命名也按此规范

3.  页面动作定义

因为jsp页面中的Form对应ActionForm,其本身有action这个属性,所以页面动作如果定义也为action,会引起不必要的麻烦,所以,把页面动作统一定义为"act",

如需要编辑某条记录,地址如下:

"/editRecord.do?act= Edit"

如需要删除,地址如下:

"/editRecord.do?act=Delete"

4.  对于菜单和操作事件触发的控制机制

由于系统中的菜单和操作都是由".do"形式向服务端发请求的,因此需要一套机制来控制哪些是对菜单的事件请求,哪些是对操作的事件请求;

我们在系统中引入了Filter过滤器,对所有请求进行控制,以及判断用户是否登录和是否有对资源(菜单等)访问权限等;

约定:

jsp页面上对于系统中菜单的请求都是"GET"方法,对于操作的Action都是"POST"方法;

有了这样的约定,在Filter中先判断request的请求方法,如果是"GET"方法,则认为是对菜单的请求,所以去"菜单表"根据请求地址读取相应的记录,并读取用户的权限表,判断用户的菜单权限;

如果是"POST"的方法,则认为是对操作的请求,并提取request中的"act"动作,进行对用户的权限点的判定。

 

参数信息获取

1.         公共参数信息通过Plugin方式在Web服务启动时将变量放入application中,使得在任何需要该变量的jsp中都可以调用;

方式如下:

public void setServletContext(ActionServlet actionServlet) {

try {

        ServletContext sc = actionServlet.getServletContext();

        //SysInitPwd

   sc.setAttribute(Constants.SYS_INIT_PWD,SelectLists.getSysConfig("PWDINIT"));

...

在action等程序中的调用方式:

getServlet().getServletContext().getAttribute("...");

 

2.         对于页面上需要展示的数据尽量存放在request这个范围里,可以减轻服务器端内存负载,方式如下:

//调用员工处理类

StaffDeal sd=new StaffDeal();

//根据员工状态查询员工

ArrayList al=sd.qryStaff(strState);

//放入request

    request.setAttribute("staffInfo",al);

3.         私有的或需要根据用户的属性来获取参数信息的,可以在tiles的定义中使用"controlClass=xxx"这个方式获取,配置如下例:

<definition name="vip.welcome" path="/vip/welcome.jsp" controllerClass="viptx.logic.vip.welcomeAction" />

需implements Controller中的perform方法,代码如下例:

public void perform(ComponentContext componentContext,

                      HttpServletRequest request,

                      HttpServletResponse response,

                      ServletContext servletContext) throws IOException,ServletException  {

    HttpSession session = request.getSession();

    // Get current session.

    User user = (User) session.getAttribute(Constants.USER_KEY);

    if (user == null) {

      return null;

    }

    String uid = user.getUserid();

    String sql = "select userid,content from ti_salutatory where userid='"+uid+"'";

    try {

      ...

    }

    catch (Exception ex) {

      throw new ServletException(ex.getMessage());

    }

}

4.         对于后台出错信息在前台页面显示的技巧

首先在properties配置"message.common={0}"

然后在Action类中使用ActionErrors或ActionMessages时,方法如下:

...

ActionMessages ams = new ActionMessages(); //例外处理

Try{

...

}

catch (Exception ex) {

    ex.printStackTrace();

    ams.add(ActionMessages.GLOBAL_MESSAGE,

                 new ActionMessage("message.common", ex.getMessage()));

}

                finally {

if (!ams.isEmpty()) {

        saveMessages(request, ams);

     }

}

...

        在jsp页面中使用方法如下:

        <html:messages id="msg" message="true">

               <font color="red"><bean:write name="msg"/></font>

        </html:messages>

        如果有后台的messages产生,前台页面就可以出现报错信息

5.         系统配置文件

系统参数如数据库连接等在sysConfi.xml文件中配置,存放在"WEB-INF/xml"文件夹下,请参见该文件。

开发规范和公用方法

关于java的开发规范参见《Java 编程规范.doc》,这里仅给出用struts开发中一些的规范:

1.         java文件存放按业务逻辑划分,并用模块作为包名的形式,如:telecombi.logic.sysman.security

包名都为小写形式

所有的Action和ActionForm都存放在同一包下,便于管理,不要跨包调用

2.         所有ActionForm中的属性均为"首单词小写+第二个单词首字母大写+..."的形式,如:staffId、staffName,不允许使用"_"为单词连接符

3.         需要验证的页面,均需要客户端和服务端两次验证(即对jsp中的Form进行javascript验证和Action中的excute方法中进行验证),不能只采用其中一种方法,防止客户绕过js直接提交;

在验证登录提交的form时,必须使用staticJavascript="false",否则就会把javascript写到页面里,如:

<html:javascript formName="logonForm"

        dynamicJavascript="true"

         staticJavascript="false"/>

<script language="Javascript1.1" src="staticJavascript.jsp"></script>

验证的formName必须和validation.xml中的Form的名字对应起来,否则验证无效

4.         ActionForm是代表html中的Form的,其中的变量需要和Form中的属性对应起来,如:要在jsp中使用<form:text property="userName"/>,则使用的ActionForm中就必须有userName这个变量

5.         对于Action中的逻辑,如果处理方法在一个以上,需要另外新建一个处理类,负责对Action中的逻辑集中处理,命名为xxxDeal,如:LoginDeal;

Action通过调用该处理类的方法,实现业务逻辑处理

6.         对数据库的操作使用DBManager这个类,对其中的一些方法,具体介绍如下:

n         查询结果对象化的Select操作,使用Select(String sql,String className)方法

StringBuffer sql = new StringBuffer(

        "select staff_id staffId from ts_m_staff ")

        .append("where staff_id='").append(uid).append("'");

    try {

/**

*       User是一个用户对象类,其中有staffId这个属性,以及对应的get/set方法,通过

*        DBManager的Select方法获得一个User的ArrayList集合

*/

ArrayList rs = DBManager.Select(sql.toString(), User.class.getName());

/**

*   如果确定返回的只有一个对象,则可以使用

*

*/

User user=(User)rs.get(0);

    }

    catch (Exception ex) {

      throw new ServletException(ex.getMessage());

}

取出来的数据可以存放在session或page等里,供jsp页面调用,方法为session.setAttribute("user",user1)

...

n         Insert或Update等操作

使用DBManager里面的executeSql(String sql)方法,如果是批量处理,使用executeBatchSql(String[] sqls)方法,返回成功标志为Constants.OPERATE_SUCCESS

失败标志为Constants.OPERATE_FAILED

暂无其它信息返回

n         ResultSet对象向Hashtable集合对象的转化,使用select(String sql)方法:

除了可以使用DBManager的Select把查询结果转为对象以外,还可以使用以前的直接使用ResultSet对象的方式,不过这里返回的数据集对象为Hashtable;

Hashtable存放的数据结构为:

columnName1 ? ArrayList1(该字段的结果集)

columnName2 ? ArrayList2(该字段的结果集)

...

        系统中使用该方法的比较多的是用在生成下拉框数据,从select方法返回的Hashtable取到字段值,并生成LabelValueBean,具体方法如下:

        /**公用函数 Hashtable 转换成 ArrayList (LabelValueBean)*/

   private static ArrayList hashToLVB(Hashtable ht, String id, String name,boolean hasBlank) {

      if (ht!=null){

         ArrayList al = new ArrayList();

         ArrayList alId = (ArrayList) ht.get(id.toUpperCase());

         ArrayList alName = (ArrayList) ht.get(name.toUpperCase());

         int iLen = alId.size();

         if (hasBlank)

            al.add(new LabelValueBean("未知", "-1"));

         for (int i = 0; i < iLen; i++) {

            al.add(new LabelValueBean( (String) alName.get(i),

                                      (String) alId.get(i)));

         }

         return al;

      }

      else{

         return null;

      }

   }

n         AutoSetForm(String sql, Object frm)方法介绍:

a)         该方法可以返回一个查询数据库后已对其中的属性赋值的对象,使用方法如下:

User user=DBManager. AutoSetForm(sql,new User());

sql为查询语句

b)        该方法还可以对页面操作后的Form进行赋值,比如在页面上提交一个对某条记录进行编辑的操作,当Action得到该条记录的Id号并查询数据库成功后,需要把各个详细信息set到ActionForm的属性变量中去,这个时候就可以使用该方法,方法如下:

form= DBManager. AutoSetForm(sql,form);

form为Action的excute方法中传入的ActionForm

 

7.         调用存储过程

使用DBManager中的execProc(String procName,ArrayList procPrts)方法

procName为存储过程名,procPrts是该存储过程的入口参数集,返回的是ProcOuts的对象,其中有Result和ExceptionInfo两个属性,表示返回的处理标记和异常信息(如果有的话)

8.         数据操作返回信息的处理

在对数据操作完成后,需要返回操作是否成功等信息,具体步骤如下:

n         使用属性文件中的"messages.comm"这个key,可以对该key添加具体返回信息

n         程序中使用"ActionMessages"这个对象,java程序如下:

ActionMessages ams = new ActionMessages();

...

//执行结果

         ProcOuts pResult=null;

//是否调用成功

         if (pResult.getResult() == -1) {

               ams.add(ActionMessages.GLOBAL_MESSAGE,

                       new ActionMessage("message.common",

                                         pResult.getExceptionInfo()));

         }

if (!ams.isEmpty()) {

            saveMessages(request, ams);

         }

Jsp中调用方法如下:

<html:messages id="msg" message="true">

  <font color="red"><bean:write name="msg"/></font>

</html:messages>

 

- 作者: 张丘 2004年12月21日, 星期二 15:26  回复(0) |  引用(0) 加入博

don't have medicine resolutely

two years daughter don't like before,she don't have medicine resolutely if she is ill.Having medicine voluntarily is imposible now,unless she is very happy then and she is very dry(having chinese medicine).

And,imposing her to have medicine is also no effection.

"It's no way that let me have medicine!"I think this is my daughter want to say.

What should we do?