随笔-39  评论-33  文章-0  trackbacks-0

newxy的简单之美

胡立新

(注:newxy新坐标是java web快速开发包,功能强大、易学,可使开发效率提高十倍、数十倍,newxyWEB开发比delphi桌面开发更快,能力更强)

 

本想用“简约”一词,但“简约”文了点,还是“简单”好。

“简单”如何与“美”挂起钩来?简单才能自由,自由才能产生美。

很多技术或框架之类上来就叫你做很烦人的配置,而有的号称零配置实际不得不写几十几百行配置代码。框架太多,但没有哪个框架让程序员不写代码实现数据的增、、改、查等最常用的功能。 newxy将绝大部分常见的、繁杂的、又不得不做的工作用最简单的、通用的方法来解决,减轻程序员的负担和痛苦。在用newxy开发过程中,一种美感油然而升。

一、newxy“配置简单”之美

newxy只需几行配置信息,而大多数情况不需写一行配置信息,正真零配置newxy为了美,为了自由,不扼杀程序员的天性。程序员有的爱写后台代码,有的爱在jsp页面上写一些逻辑。对具有不同偏好的程序员,newxy会提供不同的“简单”解决问题的办法。

二、newxy“后台代码”之美

在后台与数据库打交道,实现数据的增、、改、查如此简单:

1、增:

BaseDAO baseDao=new BaseDAO();

dynaDto dto=new DynaDto();

dto.set_table(“industry”);   //设置表名

dto.set(id”,id);

dto.set(“industry”,industry); //设置行业内容

baseDao.update(dto);

2、删:

BaseDAO baseDao=new BaseDAO();

DynaDto dto=new DynaDto();

dto.set_table(“industry”);   //设置表名

dto.set(id”,id);

baseDao.remove(dto);

3、查:

BaseDAO baseDao=new BaseDAO();

String sql=”select * from industry where……”;

DynaFormBean formBean=(DynaFormBean)baseDao.findBySql(sql);

4、改:

修改第10条记录的industry字段值:

BaseDAO baseDao=new BaseDAO();

DynaDto dto=new DynaDto(formBean.getDto(“10”));

dto.set_table(“industry”); //设置表名

dto.set(“industry”,newValue);    //设置行业内容

baseDao.update(dto);

实体类是动态的、通用的,无需写与数据库表匹配的配置文件。如此简单地解决问题,出自内心的不只是纯然主观的快感,还有我们解决现实问题直接明快的方式在内心深处的体验。

三、newxy“前台标签”之美

在前台实现数据的增、、改、查同样简单,不需写一行java代码。

1、 增:

<nlogic:action1 id="act1" formName="form1"/>

<nhtml:form action="" formName="form1">

 <html:hidden property="_table" value="industry"/>

 行业内容:<html:text property="industry"></html:text>

</nhtml:form>

<nhtml:button actionId="act1" method="update" value="保存"/>

    输入行业内容,点击“保存”铵钮,插入数据库。

2、 删:

<nlogic:action1 id="act1" formName="form1"/>

<nhtml:form action="" formName="form1">

 <html:hidden property="_table" value="industry"/>

 编号:<html:text property="id"></html:text>

</nhtml:form>

<nhtml:button actionId="act1" method="remove" value="删除"/>

输入编号,点击“删除”铵钮,删除记录。

3、 (任意姐合多项查询)

<nlogic:action1 id="act1" formName="form1"/>

<nhtml:form action="" formName="form1">

 <html:hidden property="_table" value="industry"/>

  <html:hidden property="_item1" value="industry"/>

 <html:select property="_item1">

   <html:option value=""></html:option>

   <html:option value="=">等于</html:option>

   <html:option value="like">包含</html:option>

 </html:select>

 行业内容:<html:text property="_item1"></html:text>

</nhtml:form>

<nhtml:button actionId="act1" method="find" value="查询"/>

选择等于查询或模糊查询,输入查询内容,点击查询铵钮,查询结果保存在以“form1”为名的DynaFormBean类实例中,这个类实例保存在会话中。

4、 改:

<nlogic:action1 id="act1" formName="form1"/>

<nhtml:form action="" formName="form1">

 <html:hidden property="_table" value="industry"/>

 编号:<html:text property="id"></html:text>

 行业内容:<html:text property="industry"></html:text>

</nhtml:form>

<nhtml:button actionId="act1" method="update" value="更新"/>

输入编号及行业内容,点击“更新”,如果id号不存在,作insert操作,否则作update操作。

在其它任一框架下数据的增、删、改都要写大量重复而又略有不同的代码,写代码与调试绝不可少。在查询数据时要想将用户输入的条件组合成sql语句,那是极其繁杂的,可能是程序员“苦”的较高形式。但在这里不写一行java代码,任意组合多项查询。多么美妙。

程序员从痛苦的写代码、调试代码工作中走出来,发现了自己存在,再次感受到newxy的简单之美。

这里例出的仅是极小部分方法。

5、 数据分页

    <nlogic:navigate formName="industry" length="5"/>

    <table cellspacing="0" class="table1">

      <tr>

        <td>序号</td><td align="center"> </td><td align="center" style="BORDER-RIGHT: #ffffff 0px solid;"> </td>

      </tr>

      <nlogic:iterate id="rec" name="industry" property="_coll">

        <nhtml:TR>

          <td align="center">${index+1}</td>

          <td width="50" nowrap="nowrap"><bean:write name="rec" property="code"/></td>

          <td width="400" nowrap="nowrap" style="BORDER-RIGHT: #ffffff 0px solid;"><bean:write name="rec" property="industry"/></td>

        </nhtml:TR>

      </nlogic:iterate>

    </table>

 

    数据分页同样不写一行java代码。

6、 文件上传

<nlogic:action1 id="act1" formName="fileForm"/>

<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">

  <html:hidden property="_table" value="filetable"/>

 文件不大于10兆:<nhtml:file property="content" size="40" maxSize="10240" fileNameField="field1" fileExtendNameField="field2" fileSizeField="field3" fileTypeField="field4"/><br />

</nhtml:form>

<nhtml:button actionId="act1" method="update"/>

上传大小限制在10兆,文件类容保存在content字段中,文件名保存在field1字段中,文件的扩张名保存在field2字段中,文件大小保存在field3字段中,文件类型保存在field4字段中。

理论上一次可以上传无限数量的文件,不用写一行java代码。

简单才是美,只有简单你才有时间、才有闲情逸致欣赏美。

四、“Delphi风格”之美

Delphi开发桌面运用,它那快速精巧的方法,让好多程序员如痴如醉。Newxy也可用几个标签实现具有delphi风格的开发。见下图:

 

左上部是记录集,下部是当前记录详细信息,右上部是当前记录保存的一张图片。用户点击某条记录,下部的详细信息和右上部的图片随着变化。

Delphi实现上述功能可以不写一行代码,newxy实现上述功能也不需要写一行代码。

posted on 2007-04-17 21:52 newxy新坐标 阅读(2098) 评论(6)  编辑  收藏

评论:
# re: newxy的简单之美 2007-04-17 22:52 | 山风小子
胡立新——中国一位可敬的开源先驱!  回复  更多评论
  
# re: newxy的简单之美 2007-04-18 11:30 | 有猫相伴的日子
支持一下.....  回复  更多评论
  
# re: newxy的简单之美 2007-04-18 19:57 | 王元涛
敬佩!  回复  更多评论
  
# re: newxy的简单之美 2007-11-26 11:14 | zwl
支持!佩服!  回复  更多评论
  
# re: newxy的简单之美[未登录] 2007-12-08 21:18 | a
没什么大不了的,就是仿照Ruby on Rails的Active Record,用反射实现,
每次都要检索表名是否存在,表的各个字段是否存在,其实效率非常低,
最起码比哈勃那特低,绝对的,还有,java再怎么样也实现不了Active Record
这是公认的道理

现在都什么时代了,还在搞服务器端解释的自定义标签,过时了!!
现在都搞客户端全渲染JS组件了,太弱了

不服吗,不服就一条一条的驳倒我,呵呵  回复  更多评论
  
# re: newxy的简单之美 2010-03-08 10:46 | dcr
@a
无聊!这样就说明你牛了?  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: