Nokia网站上的资源

pureMVC
http://wiki.forum.nokia.com/index.php/Model-View-Controller_Architecture
可以用于jme开发的MVC框架

nokia2008年的CallingAllInnovators比赛的获胜者,其中总冠军是来自中国的,居然一直都没听说过,Grand Prize: X Dancery,看了一下视频,震撼到了!
http://www.callingallinnovators.com/previous_winners.aspx

eSWT貌似s60的runtime一直都支持eSWT,怎么没怎么见有人用过呢?可能还是见的太少了。
http://wiki.forum.nokia.com/index.php/ESWT
eRCP是nokia的开源项目http://www.eclipse.org/ercp
    * eSWT:   The embedded Standard Widget Toolkit which is a subset of desktop SWT API. An eSWT implementation for Series 80 has been contributed. The development for s60 platform is in progress.
    * Core Runtime:   Eclipse Core which provides OSGI and Extension Point Framework support.
    * eJFace:   A set of classes which extend eSWT to: enable eRCP applications to integrate with an eRCP workbench, and provide more complex widgets like MVC oriented viewers.
    * eWorkbench:   A UI framework which supports multiple cooperative eRCP applications, and a generic Workbench which manages launching and display of eRCP applications.
    * eUpdate:   A simplified API and interface for dynamically updating device software.

How to use eSWT with Midlets
http://wiki.eclipse.org/How_to_use_eSWT_with_Midlets
Using eSWT and MMAPI together to take a picture in Java ME
http://wiki.forum.nokia.com/index.php/Using_eSWT_and_MMAPI_together_to_take_a_picture_in_Java_ME

Java Runtime 1.4 for S60 Release notes(目前只有N97)
http://wiki.forum.nokia.com/index.php/Java_Runtime_1.4_for_S60_Release_notes(支持触摸屏)

Java Runtime 1.3 for S60 Release notes(目前只有5800)
http://wiki.forum.nokia.com/index.php/Java_Runtime_1.3_for_S60_Release_notes

Java API Specifications
http://www.forum.nokia.com/Resources_and_Information/Documentation/Java/Java_API_Specifications.xhtml

System properties
http://wiki.forum.nokia.com/index.php/TSJ000306_-_MIDP:_System_properties

Java ME UI Frameworks
http://wiki.forum.nokia.com/index.php/Java_ME_UI_Frameworks

SWT的布局管理小结

SWT的布局管理

FillLayout
组件填满整个容器,当容器大小变化时,组件同时跟随变化。如果同时添加多个组件,则每个组件将平均分配容器空间。默认情况下filllayout会水平添加多个组件。可以通过设置来达到垂直加入。
s.setLayout(new FillLayout(SWT.VERTICAL));

RowLayout
组件会按行排列,当容器大小不够排列时,组件会自动排到第二排。如果不希望容器自动排列,可以通过设置wrap:rl.wrap = false;
如果想要让一排中所有组件都同宽,可以通过设置pack:rl.pack = false;
设置纵向排列RowLayout rl = new RowLayout(SWT.VERTICAL);

GridLayout
可以设置参数决定组件加入容器时占多少行、列单元格,如何填充.
设置列数:
GridLayout gl = new GridLayout( );
        gl.numColumns=3;
        s.setLayout(gl);
控制组件的尺寸和对齐方式:
对齐方式:
GridData gd = new GridData( );
gd.horizontalAlignment = GridData.CENTER;//GridData.BEGINNING,GridData.END
l1.setLayoutData(gd);
组件填充方向:
gd = new GridData(GridData.FILL_HORIZONTAL); //FILL_VERTICAL,FILL_BOTH
t1.setLayoutData(gd);

FormLayout
用来布局表单,也是最复杂的布局管理,在FormLayout中FormData和FormAttachment的设置是必需的。
    FormData fd = new FormData( );
        fd.top = new FormAttachment(10, 10);
        fd.left = new FormAttachment(0, 10);
        fd.bottom = new FormAttachment(30,0);
        fd.right = new FormAttachment(40,0);
        l1.setLayoutData(fd);
上面这几行代码首先设置了组件的上下左右边缘的距离 – 上端位于整个容器的10%处,

如何创建一个可执行的jar并使用jws发布

(翻出来的一篇老文,备份上来)
14:09 2006-7-14

一.从eclipse输出项目jar包  — 注意main-class的设置

二.将所有依赖包签名
a.怎么创建签名:
1.创建密钥库
keytool -genkey -keystore myKeystore -alias myself
myKeystore 密钥库的名字(这里会生成一个以它为文件名的文件,该文件不能移动位置)
myself 密钥的别名

2.根据创建好的密钥库创建自己的证书
keytool -selfcert -alias myself -keystore myKeystore

3.查看密钥库中是否创建了相应的证书
keytool -list -keystore myKeystore

Keystore 类型: jks
Keystore 提供者: SUN

您的 keystore 包含 1 输入

myself, 2006-7-13, keyEntry,
认证指纹 (MD5): A7:BB:42:89:15:B4:4E:7A:2E:A4:4F:E5:89:24:06:55

b.怎样给jar文件签名
jarsigner -keystore myKeystore test.jar myself
myKeystore 指定密钥库
myself 指定要使用的密钥的别名
test.jar 要签名的jar文件
(所有要发布的jar包都要签名)

三.创建jnlp文件(jws的部署描述文件)
jnlp文件中使用的标签参考:http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html
例子:
<?xml version=”1.0″ encoding=”utf-8″?>
<jnlp spec=”1.0+” codebase=”http://localhost:8080/” href=”rssreader.jnlp”>
<information>
<title>**title**</title>
<vendor>**vendor**</vendor>
<description>**description**</description>
<description kind=”short”>**anther description**</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se      version=”1.4+”/>
<jar       href=”rssreader.jar”/>
</resources>
<resources os=”Windows”>
<jar       href=”jdic.jar”/>
<jar       href=”lib/commons-collections-3.1.jar”/>

<jar       href=”lib/commons-configuration-1.2.jar”/>
<nativelib href=”jdic-native.jar”/>
</resources>
<application-desc main-class=”com.zhangv.rss.RssReader”/>
</jnlp>

四:发布
将所有文件(jnlp,jar)放到服务器上,注意相对路径

五:使用jdic的程序发布还是有问题
难道客户端一定还要配置那些(dll,exe)到path吗?
nativelib为什么没有起作用?

递归生成目录文件列表

很早前在学校时候写的一个生成目录文件列表的东西,因为那时候自己开了一个ftp服务器。

import java.util.Date;
import java.util.Arrays;
import java.io.*;

/**
* Time: 2003-12-23 20:46:42
*/
public class FileManager {
private String ListFilename = "@list.txt";
private String root;
private String updatetime;

public FileManager(String root) {
this.root = root;
updatetime=new Date().toString();
}


private void getList(String dir) {
File tmp = new File(dir);
File[] files = tmp.listFiles(new ffilter());
File[] dirs = tmp.listFiles(new dfilter());

if (files.length != 0) {
writeListFile(files);
}
if (dirs.length != 0) {
for (int i = 0; i < dirs.length; i++)
getList(tmp.getPath() + "/" + dirs[i].getName());
}
}

private void writeListFile(File[] files) {
FileWriter f = null;
String parent = files[0].getParent();
try {
int size;
f = new FileWriter(parent +"/"+ListFilename);
f.write("【列表最后更新时间】"+" :"+updatetime);
f.write(13);
f.write(10);
f.write("【欢迎分享我的收藏】,enjoy!");
f.write(13);
f.write(10);

//排列顺序
Arrays.sort(files);
for (int i = 0; i < files.length; i++) {
f.write(files[i].getName());
size = ((int) files[i].length()) ;
f.write(" 【size:"+size/1000+"k】");
f.write(13);
f.write(10);
}
f.flush();
f.close();
} catch (FileNotFoundException e) {
System.out.println("file not found");
} catch (IOException e) {
}
}

public void run() {
delete(root);
getList(root);
}

private void delete(String dir) {
File tmp = new File(dir);
File lfile = new File(dir + "/" + ListFilename);
lfile.delete();
File[] dirs = tmp.listFiles(new dfilter());

if (dirs.length != 0) {
for (int i = 0; i < dirs.length; i++)
delete(tmp.getPath() + "/" + dirs[i].getName());
}

}

public static void main(String args[]) {
/*      String dowhat = "list";
if (args[0] != null) Root = args[0];
if (args[1] != null) dowhat = args[1];
FileManager f = new FileManager(Root);
if (args[1] == "list")
f.getList(Root);
else if (args[1] == "delete") f.delete(Root);*/

FileManager f=new FileManager(args[0]);
f.run();
}
}

class ffilter implements FileFilter {
public boolean accept(File pathname) {
String name = pathname.getName();
return (pathname.isFile()) && (name.indexOf(".mp3") != -1);
}
}

class dfilter implements FileFilter {
public boolean accept(File pathname) {
return pathname.isDirectory();
}
}

httpUnit无法获取select框的选项值(options)

今天用httpunit写一个测试时候发现无法设置select框,报错是:
com.meterware.httpunit.IllegalParameterValueException: May not set parameter ‘userInfo.processingUnit’ to ‘BOM’. Value must be one of: { }
at com.meterware.httpunit.SelectionFormControl$Options.reportNoMatches(FormControl.java:1186)
at com.meterware.httpunit.SelectionFormControl$SingleSelectOptions.claimUniqueValues(FormControl.java:1360)
at com.meterware.httpunit.SelectionFormControl$Options.claimUniqueValues(FormControl.java:1178)
at com.meterware.httpunit.SelectionFormControl.claimUniqueValue(FormControl.java:1059)

跟进发现,webform无法通过getOptions来获取选择项.google后发现有人建议把页面中的

<html xmlns=”http://www.w3.org/1999/xhtml”>
改成
<html>

果然管用. 为什么会影响到httpunit? 指定上述的命名空间的意思是说这个html文档是遵守xhtml规范.通过下面的方法打开httpunit的解析详情 – httpunit会在得到html内容后告诉你这个文档是否遵守了你所指定的规范.(这里是xhtml).

HttpUnitOptions.setParserWarningsEnabled(true);

结果会得到这样的信息:
At line 121, column 1: Element <BODY> not closed properly.
At line 121, column 1: Element <HTML> not closed properly.
At line 1249, column 1: Element <BODY> not closed properly.
At line 1249, column 1: Element <HTML> not closed properly.
At line 1477, column 1: Element <BODY> not closed properly.
At line 1477, column 1: Element <HTML> not closed properly.

也就是输出的页面已经不是严格遵守xhtml的了.(推测是sitemesh的使用问题,没有很好的组织页面之间的关系依赖.),然后HttpUnit使用他的html解析器去查找select框的options时就出问题了. 为什么httpunit的作者不把具体原因给出来呢?