无聊人士

搬家==》www.soapui.cn

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  32 随笔 :: 0 文章 :: 60 评论 :: 0 Trackbacks

2006年10月12日 #

struts 2.0.6GA开始试螃蟹,照着struts2的tag文档写成<@s.datetimepicker/>,结果老是报错
211672 [http-8080-Processor25] ERROR freemarker.runtime  - 
on line 
7, column 17 in admin/index.ftl s.datetimepicker not found.
The problematic instruction:
----------
==> user-directive s.datetimepicker [on line 7, column 17 in admin/index.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: on line 
7, column 17 in admin/index.ftl s.datetimepicker not found.

试着google一下,正好有人也提交了这个bug,改成 <@s.dateTimePicker />,问题解决

The fix is as follows:

In struts2-core-
2.0.6:
org.apache.struts2.views.freemarker.tags.StrutsModels

has a method
getDateTimePicker()

Which should be re-named:
getDatetimepicker()

to match with the naming convention.


hello,struts2.jpg
posted @ 2007-04-20 10:26 mmwy 阅读(2570) | 评论 (0)编辑 收藏

来自:http://www.javaworld.com.tw/jute/post/print?bid=11&id=166588

3.Re:BIRT報表工具的問題 [Re: uxa]     Copy to clipboard
Posted by: uxa
Posted on: 
2006-09-15 15:28

經過幾次的失敗後~~小弟終於試出來了
不過感覺它似乎只是support xls file format並沒有excel的一些功能> <

1. download eclipse plugin BIRT,小弟抓的是birt-report-designer-all-in-one-2_1_0.zip
將其解開後把eclipse\plugins和eclipse\features這兩個目錄放到eclipse的目錄底下
現在將eclipse打開,您已經可以開始設計報表了。

2. BIRT預設有支援HTML和PDF的格式,以下說明如何支援xls格式
a. download xls-emitter-bin_2
.1.0.zip,解開後將plugins複製到eclipse\plugins下
b. download poi-bin-
3.0-alpha2-20060616.zip,解開後將jar檔複製到eclipse\plugins\ org.uguess.birt.report.engine.emitter.xls_2.1.0.200607031206\lib
c. xls-emitter-bin_2
.1.0.zip解開後有個path的目錄,
(
1) 將org.eclipse.birt.report.designer.ui目錄下的檔案複製到eclipse\plugins\org.eclipse.birt.report.designer.ui.preview_2.1.0.*.jar
(
2)將org.eclipse.birt.report.viewer目錄下的檔案複製到eclipse\plugins\ org.eclipse.birt.report.viewer_2.1.0.*\birt\WEB-INF\lib\viewservlets.jar
(
3)將org.eclipse.birt.report.engine目錄下的檔案複製到eclipse\plugins\org.eclipse.birt.report.engine_2.1.0.*.jar

完成後啟動eclipse可看到在view report的按鈕上多了xls和ppt兩種格式

BIRT下載位置:http://download.eclipse.org/birt/downloads/
Tribix下載位置:https://sourceforge.net/projects/tribix
ps:請注意版本的問題,BIRT2
.1.0請搭配Tribix XLS Emitter 2.1.0版本,在置換檔名的部份也請注意路徑是否正確

posted @ 2007-04-08 15:42 mmwy 阅读(1596) | 评论 (2)编辑 收藏

条码显示,在birt中最常见的有两种方法:1、使用条码字体(对pdf无效);2、用barcode的开源包,生成barcode,然后在报表里用动态地址去取图片。

今晚看birt文档(第 23 章 使用 Java 编写事件处理程序),例子中用java实现了一个LabelEventAdapter的适配器,对标签元素进行事件控制。脑子里灵光一现,似乎条码有着落了。

我的测试例子很简单,继承ImageEventAdapter类,重载onCreate方法,以进行条形码处理

 1 package cn.ynzc.common.birt.test;
 2 
 3 import java.io.File;
 4 import java.io.FileOutputStream;
 5 
 6 import jbarcodebean.Code128;
 7 import jbarcodebean.JBarcodeBean;
 8 
 9 import org.apache.commons.codec.digest.DigestUtils;
10 import org.eclipse.birt.report.engine.api.script.IReportContext;
11 import org.eclipse.birt.report.engine.api.script.eventadapter.ImageEventAdapter;
12 import org.eclipse.birt.report.engine.api.script.instance.IImageInstance;
13 
14 public class MyLabelClass extends ImageEventAdapter {
15 
16   public void onCreate(IImageInstance image, IReportContext reportContext) {
17     try {
18       //实际应用中,可以使用image.getRowData().getColumnValue("columnname")获得字段值
19       String code = "ABCDEF123-2222";
20       //似乎windows文件名中不允许使用“-”等符号,干脆将code进行md5散列处理
21       File file = new File(System.getProperty("java.io.tmpdir"), DigestUtils.md5Hex(code));
22       //避免每次都进行条码文件生成
23       if (!file.exists()) {
24         JBarcodeBean bb = new JBarcodeBean();
25         bb.setCodeType(new Code128());
26         bb.setShowText(true);
27         bb.setBarcodeHeight(45); //条码高度
28         bb.setCode(code);
29         bb.gifEncode(new FileOutputStream(file));
30       }
31       image.setFile(file.getAbsolutePath());
32     }
33     catch (Exception e) {
34       e.printStackTrace();
35     }
36   }
37 
38 }
39 

测试用的birt报表文件简单得要死,就往上面扔了个image元素,设置其Event Handler Class为刚才写好的java类,最终得到的rptdesign文件内容如下:
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!-- Written by Eclipse BIRT 2.0 -->
 3 <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.6" id="1">
 4     <property name="createdBy">Eclipse BIRT Designer Version 2.1.2.v20070205-1728 Build &lt;20070205-1728></property>
 5     <property name="units">in</property>
 6     <page-setup>
 7         <simple-master-page name="Simple MasterPage" id="2"/>
 8     </page-setup>
 9     <body>
10         <image id="4">
11             <property name="eventHandlerClass">cn.ynzc.common.birt.test.MyLabelClass</property>
12         </image>
13     </body>
14 </report>

运行测试,条形码出来了
birt.jpg

遗留问题:
这次是调用org.eclipse.birt.report.engine.api.script.instance.IImageInstance.setFile()来解决问题,从javadoc可以看到,IImageInstance有很多方法可以调用,其它方法分别有什么作用?比如我尝试了半天的setData(byte[])方法,一开始以为是用这个方法直接把图形数据set进去就ok,结果未成功。


posted @ 2007-04-07 03:37 mmwy 阅读(4160) | 评论 (4)编辑 收藏

birt的IRunAndRenderTask接口提供了addScriptableJavaObject(java.lang.String jsName, java.lang.Object obj)方法,利用这个方法,在直接调用birt api操作处理报表的时候,我们可以将任何java对象通过addScriptableJavaObject("xxx",Object)加进birt去,然后在birt脚本中直接调用xxx.method()进行操作。

我的测试是在一个webwork+spring+hibernate的webapp应用中进行的,进行报表处理的代码参照http://wiki.eclipse.org/index.php/Servlet_Example编写,在代码中,写了一句
task.addScriptableJavaObject("ctx",
WebApplicationContextUtils.getWebApplicationContext(sc));

birt中定义了一个scripts datasource,然后定义一个data set,在dataset的open方法中编写脚本

infoManager=ctx.getBean("infoManager");
infos=infoManager.loadAll();
...
posted @ 2007-04-06 15:39 mmwy 阅读(2027) | 评论 (3)编辑 收藏

在apache网站上已经有很详细的介绍
http://tomcat.apache.org/connectors-doc/reference/iis.html

有几点注意的:
1、除了照文档的例子在注册表"HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0"建相应键值外,还可以在isapi_redirect.dll所在的目录建“isapi_redirect.properties”文件。

2、extension_uri=/jakarta/isapi_redirect.dll
这个extension_uri写成什么路径,就得在iis站点中建相应名字的虚拟目录(执行权限),以保证/jakarta/isapi_redirect.dll能被正常访问到。

3、除文档上介绍的几大步(注册表、网站、虚拟路径等)以外,win2003 iis上还得做下面这个步骤

新建应用程序扩展
在IIS管理器左侧网站下面选中Web服务扩展,添加一个新的Web服务扩展,扩展名为jakarta,添加要求得文件为D:\Tomcat5.0\bin\jakart\isapi_redirect.dll,并设置扩展状态为允许。
(注:来自 http://www.cnrui.cn/blog/article.asp?id=179




posted @ 2007-03-19 15:39 mmwy 阅读(1806) | 评论 (2)编辑 收藏



选中table的detail行,切换到script标签,在onPrepare事件中输入
 
count=1;

在onCreate事件中输入
1count++;
2this.getStyle().backgroundColor=(count%2==0?"red":"blue");

或是直接打开xml source,在相应的detail位置上修改源码为
                <detail>
                  
<row id="66">
                    .
                    
<method name="onPrepare"><![CDATA[count=1;]]></method>
                    
<method name="onCreate"><![CDATA[count++;this.getStyle().backgroundColor=(count%2==0?"red":"blue");]]></method>
                    ..

xxxxx.jpg

posted @ 2006-11-24 01:04 mmwy 阅读(1845) | 评论 (0)编辑 收藏

定义报表参数:

3.jpg



解决方法一:

1.jpg


2.jpg



解决办法二:

在报表空白处点击一下,然后切换到script标签,选择beforeFactory。

4.jpg


posted @ 2006-11-23 01:48 mmwy 阅读(3260) | 评论 (0)编辑 收藏

笔记一下:

设hibernate.hbm2ddl.auto为update/create-drop/create后,在classpath中扔一个/import.sql进去,hibernate启动时就会执行import.sql的内容。

11860 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaExport  - Running hbm2ddl schema export
11860 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaExport  - import file not found: /import.sql
11875 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaExport  - exporting generated schema to database
posted @ 2006-10-31 00:32 mmwy 阅读(5736) | 评论 (2)编辑 收藏

使用的安装包:
 1 cronolog-1.6.2.tar.gz                              
 2httpd-2.0.59.tar.gz                                
 3instantclient-basic-linux32-10.2.0.2-20060331.zip  
 4instantclient-sdk-linux32-10.2.0.2-20060331.zip    
 5libmcrypt-2.5.7.tar.gz                             
 6mhash-0.9.7.1.tar.gz                               
 7mysql-3.23.58.tar.gz                               
 8php-4.4.4.tar.gz    

参考文档

  1. 为 Linux 和 Windows 安装 PHP 和 Oracle 10g Instant Client
  2. Connecting to Oracle10g from PHP using OCI-8 (Linux)
与文档有出处的地方
  1. otn上只能下到zip格式的oracle 10g instant client basic和sdk包。解压缩后,全部放到instantclient_10_2目录下。
    [root@localhost sdk]# ls -l ..
    total 
    115948
    -r--r--r--  
    1 root root  1594191 Feb  5  2006 classes12.jar
    -rwxrwxr-x  
    2 root root 18774535 Feb  5  2006 libclntsh.so
    -rwxrwxr-x  
    2 root root 18774535 Feb  5  2006 libclntsh.so.10.1
    -r-xr-xr-x  
    1 root root  5623929 Feb  5  2006 libnnz10.so
    -rwxrwxr-x  
    1 root root  1398088 Feb  5  2006 libocci.so.10.1
    -rwxrwxr-x  
    1 root root 70690282 Feb  5  2006 libociei.so
    -r-xr-xr-x  
    1 root root   119919 Feb  5  2006 libocijdbc10.so
    -r--r--r--  
    1 root root  1540457 Feb  5  2006 ojdbc14.jar
    drwxr-xr-x  
    4 root root     4096 Oct 17 04:27 sdk
    [root@localhost sdk]# ls -l
    total 
    324
    drwxr-xr-x  
    2 root root   4096 Oct 17 04:27 demo
    drwxr-xr-x  
    2 root root   4096 Oct 17 04:27 include
    -r-xr-xr-x  
    1 root root    346 Oct 17 04:27 ott
    -rw-r--r--  
    1 root root 298274 Oct 17 04:27 ottclasses.zip
  2. php4.4.4已经提供了--with-oci8-instant-client参数的支持,同时修复了相关补丁,因此,文档中为php打补丁、重建“configure”脚本的步骤可以省略。
环境变量:
  1. 在LD_LIBRARY_PATH中添加oracle 10g instant client的路径。
    export LD_LIBRARY_PATH=/www/server/instantclient_10_2/:${LD_LIBRARY_PATH}
  2. 设置TNS_ADMIN为oracle tnsname.ora文件所在目录。
    export TNS_ADMIN=/u01/app/oracle/product/10g/network/admin/
编译脚本
./configure \
--prefix
=/www/server/php-4.4.4 \
--with-apxs2
=/www/server/httpd-2.0.59/bin/apxs \
--with-mysql
=/www/server/mysql-3.23.58 \
--with-mcrypt
=/www/server/libmcrypt-2.5.7 \
--with-mhash
=/www/server/mhash-0.9.7.1 \
--with-gd --with-zlib \
--with-oci8-instant-client
=/www/server/instantclient_10_2
注:需要使用ln命令为libclntsh.so.10.1创建一个名为libclntsh.so的连接,否则在configure过程中将会出现error:Link xxxx not found的错误。(http://forums.oracle.com/forums/thread.jspa?messageID=1203218&#1203218

测试
  1. 安装成功的话,在phpinfo()信息中可以看到相应信息
    OCI8 Support                  enabled
    Revision                      $Revision: 
    1.183.2.18.2.3 $
    Oracle Version               
    10.1
    Compile-time ORACLE_HOME      /www/server/instantclient_10_2
    Libraries Used                no value
  2. 测试代码
     1 <?php 
     2 $conn = OCILogon("username", "password", "//127.0.0.1:1521/sid");
     3 $query = 'select table_name from user_tables';
     4 $stid = OCIParse($conn, $query);
     5 OCIExecute($stid, OCI_DEFAULT);
     6 
     7 while ($succ = OCIFetchInto($stid, $row)) {
     8     foreach ($row as $item) {
     9         echo $item." ";
    10         }
    11     echo "<br>\n";
    12  }
    13 OCILogoff($conn);
    14 ?>


posted @ 2006-10-15 02:46 mmwy 阅读(1314) | 评论 (1)编辑 收藏

最近在“玩”hibernate Annotation,弄了个Attachment保存进数据库的测试,附件内容保存在content属性里面。
  @Lob
  @Column(columnDefinition 
= "LongBlob")
  
public byte[] getContent() {
    
return content;
  }
一开始,配置mysql jdbc url如下
jdbc.url            =    jdbc:mysql://localhost/test\
                            ?useUnicode
=true\
                            &characterEncoding
=gbk
一测试,报错
Caused by: java.sql.BatchUpdateException: Syntax error or access violation message from server: "You have an error in your SQL syntax near ''D0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF0900060000000000000' at line 1"
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:
1540)
同样的语句,直接在mysql命令行下运行就没问题,偏偏jdbc上就有这臭毛病。换jdbc driver版本,改@Lob为 @Type(type = "org.springframework.orm.hibernate3.support.BlobByteArrayType"),改hibernate配置(比如hibernate.jdbc.use_streams_for_binary true),甚至是直接用jdbc来insert,乱七八糟折腾半天,问题照旧。最后只好用上“歪”招,把byte[]配成String,在保存的时候把byte[]保存成hex String格式,取的时候再解码回来。

歪招终归是歪招,这两天老为这东西心烦,晚上吃饭的时候无意中想起charset的问题,把代码捡回来再测试了一下,问题解决,哈哈!
jdbc.url            =    jdbc:mysql://localhost/mmwy_blog\
                            ?useUnicode
=true\
                            &characterEncoding
=utf-8
如果设成iso-8859-1、utf-8,保存一点问题都没有,换用gbk、gb2312、big5之类的字符集,问题就出来了。

posted @ 2006-10-12 15:54 mmwy 阅读(1740) | 评论 (1)编辑 收藏

最近开始尝试hibernate annotations,终于成功的将手上一个小应用转为annotations :)

1、spring orm support
与原来使用LocalSessionFactoryBean相比,变动不大(AnnotationSessionFactoryBean本来就是从LocalSessionFactoryBean类继承过来的嘛)
 1    <bean
 2         id="sessionFactory"
 3         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
 4         parent="AbstractSessionFactory">
 5         <property name="annotatedClasses">
 6             <list>
 7                 <value>xxx.xxx.xxx.domain.Account</value>
 8             </list>
 9         </property>
10     </bean>
11     <bean
12         id="AbstractSessionFactory"
13         class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
14         abstract="true">
15         <property
16             name="dataSource"
17             ref="DataSource" />
18         <property name="hibernateProperties">
19             <props>
20                 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
21                 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
22                 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
23                 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
24                 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
25             </props>
26         </property>
27         <property
28             name="lobHandler"
29             ref="DefaultLobHandler" />
30     </bean>
2、id的配置
非常简单,在id的getter上面加个“@Id”就可以了。此时采用的id策略是javax.persistence.GenerationType.AUTO,也可以再加上“@GeneratedValue(generator =GenerationType.IDENTITY|GenerationType.SEQUENCE|GenerationType.TABLE)”换成其它策略。
我的应用采用的是hibernate的uuid策略,就不得不在这儿使用hibernate的扩展了
  @Id
  @Column(length 
= 32)
  @GeneratedValue(generator 
= "system-uuid")
  @GenericGenerator(name 
= "system-uuid", strategy = "uuid")

3、级联策略
在ejb3-persistence.jar中只定义了ALL、MERGE、PERSIST、REFRESH、REMOVE,比较恶心的就是,删除对象的时候,并不会级联删除关联对象,而是用update xx set parent_id=null where parent_id=?这类语句把关系干掉了事。不得已,在这儿用了hibernate的DELETE_ORPHAN。
  @OneToMany(targetEntity = Attachment.class)
  @Cascade(value 
= {org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
      org.hibernate.annotations.CascadeType.ALL})
  @JoinColumn(name 
= "info_id")
4、CACHE
ejb3-persistence.jar里面没有找到cache的配置,继续请出hibernate来干活
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name 
= "T_INFO")
@Cache(usage 
= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
5、自定义字段类型
我的POJO中有一个private String content;的属性,按ejb3配成@Lob后,被处理成了text类型,text 64k的存储容量还是比较可怜了。
  @Lob
  @Column(columnDefinition 
= "LongText")

posted @ 2006-10-12 15:38 mmwy 阅读(4870) | 评论 (0)编辑 收藏