设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> Java >> Web DbForms (续二)
精品推荐
Java点击TOP10
·java笔试题
·《Thinking in Java》读书笔记
·JSP的mysql_jdbc驱动程序
·异常java.sql.SQLException: Io exception:The Network Adapter could not establish connection
·Java Coder 常用软件下载地址
·org.apache.commons.dbcp.SQLNestedException解决办法
·Java图形界面开发:SWT全接触
·如何使用Java POI生成Excel表文件 !
·功能强大的在线网页编辑器
·一些非常不错的Struts 例子下载
编程开发点击TOP10
·ASP.NET 程序中常用的三十三种代码
·利用ASP.NET构建网上考试系统
·C#版的网站新闻发布系统
·(转)23种设计模式汇集
·设计ASP.NET新闻管理系统
·深山红叶袖珍PE工具箱V16正式版
·我的.NET书架 (入门篇)
·java笔试题
·C++经典电子书下载
·.NET:是什么?将走向哪里?
精选专题

Web DbForms (续二)

作者: 来源:网络文章 时间:2005-12-16 22:37:13

Web DbForms (续二)(1) XML:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Web DbForms (续二)

 

Advanced Features

高级特征

 

Fine-grained Security

精密的安全机制

 

DbForms' security model builds on top of the Java Servlet security model, with its concept of users (principals) and roles.

DbForms的安全模型建立在Java Servlet安全模型之上使用了用户和角色的概念。

 

DbForms provides fine-grained declarative definition of rights for data Access and manipulation. DbForms can attach security constraints to each table defined in the XML configuration, telling DbForms which kind of database operations may be executed by which user groups.

DbForms对数据访问和操作权限提供了严密而明确的定义。DbForms可以对XML配置中定义的每个表格安装安全约束,告诉DbForms哪些用户组可以操作哪些数据库。

 

Listing 4. Defining privileges

 

<dbforms-config>

 

  <table name="customer" >

    <field name="id" fieldType="int" isKey="true" />

    <field name="firstname" fieldType="char" />

    <field name="lastname" fieldType="char" />

    <field name="address" fieldType="char" />

 

    <granted-privileges

      select = "A,B"

      insert = "A"

      update = "A,B"

      delete = "A" />

  </table>

 

</dbforms-config>

 

 

The attributes of the <granted-privileges> element tell DbForms: "Members of group A may select, insert, update and delete customers, and members of B may read and update customers." All other groups (for example, a group C) may not Access this table at all.

<granted-privileges>元素的属性对DbForms来说是A组成员可以查询增加更新和删除客户B组成员可以读取和更新客户。其他组成员(例如C组)根本不能访问此表。

 

File Uploads

文件上传

 

Managing BLOB Fields is a very easy task when using DbForms; first you have to tell DbForms about BLOB-Fields in the XML configuration file:

用DbForms来管理BLOB字段是很简单的事情;首先,你要在XML配置文件中告诉DbForms有关BLOD字段信息:

 

 

Listing 5. Defining fields of type "BLOB"

 

 

<dbforms-config>

 

  <table name="pets">

    <field name="pet_id" fieldType="int" isKey="true" autoInc="true" />

    <field name="name" fieldType ="char" />

    <field name="portrait_pic" fieldType ="blob" />

    <field name="story" fieldType ="blob" />

 </table>

 

</dbforms-config>

 

 

The configuration code-snippet shown in Listing 5 tells DbForms that the fields portrait_pic and story are BLOBs. As you can see, DbForms allows more than one field in a row to be a BLOB.

Listing5所示的配置代码段告诉了DbForms照片和简历是用BLOB字段保存的。正如你所见的,DbForms允许一行中有多个字段是BLOB类型的。

 

After defining our BLOB-powered table, we would want to build a JSP for managing the BLOB fields. For this purpose, a new custom tag is introdUCed:

定义好BLOB表后,我们还要建立一个JSP文件来管理这些BLOB字段。为此,这里引入一个新的自定义标签:

 

Listing 6. Implementing a file tag

 

<db:file fieldName="portrait_pic">

 

 

 

The attribute fieldName refers to the name of the field the file needs to be uploaded to. (There exist additional attributes available for this element that are not shown here.)

fieldName的属性值由文件要上传到的字段名决定。(这个元素还有其他属性,这里没有列出来)

 

This custom tag gets rendered as a HTML <input type="file"> tag, as shown in Figure 6.

此标签显示为一个HTML标签<input type="file">,如图6所示。

 

CSDN_Dev_Image_2003-4-301431400.jpg" align=baseline border=0>

 

Figure 6. The result visible to the user.

 

 

This HTML element enables multipart-enabled browsers to submit files to the server.

HTML元素允许支持multipart的浏览器将文件提交到服务器上。

 

If we were using BLOBs for storing images in a database, we could write the following JSP code to retrieve and render sUCh a field:

如果我们在数据库中使用BLOB来保存图片,我们可以用下面的JSP代码来取出并显示这个字段:

 

Listing 7. Rendering images using a blobURL

 

<img src="<db:blobURL fieldName="portrait_pic"/>" width="100" height="80" border="0">

 

 

 

Special DbForms Feature: DISKBBLOBs

DbForms特性DISKBBLOBs

 

There are situations where BLOBs are not an option: if the application uses a RDBMS or JDBC driver without BLOB support, if BLOB support is too slow or even buggy, or if the files should be Accessible by other applications without using a database layer.

一些情况下,不选择BLOBs:如果应用程序使用不支持BLOB的RDBMS或者JDBC驱动,如果BLOB速度太慢甚至有臭虫,或者其他程序不使用数据库层也可以访问这些文件。

 

DbForms also manages uploads to a file system instead of a database. This is completely transparent to the JSP view developer! For uploading and retrieving file-system-stored objects, the same tags and attributes are used as for uploading and retrieving regular BLOBs.

DbForms管理上传到文件系统而不是数据库。这对JSP视图开发者来说是完全透明的。为了上传和取回作为文件系统保存的对象,上传和取回常规BLOBs使用相同的标签和属性。

 

The only difference lies in the definition of the Model, where a server directory for storing the files must additionally be specified.

唯一的不同点是在模型的定义方面,即必须另外指定保存文件的服务器目录。

 

 

 

Listing 8. Defining fields of type "DISKBLOB"

 

<field name="story" fieldType ="diskblob" directory="x:\stories" />

 

 

共2页 9 7 [1] [28 :>

Web DbForms (续二) 相关文章:
Web DbForms (续二) 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com