EasyJWeb-1.1版正式发布 Ajax支持得到增强

我们非常高兴的宣布,EasyJWeb-1.1今日正式对外发布,这个版本主要对EasyJWeb的Ajax支持作较大的改进。主要包括下面的内容:
  1、在EasyJWeb Tools中增加了一套Rich Component组件,可以与其它客户端Ajax框架比如ExtJS等集成开发RIA应用。
  2、修改了远程脚本调用引擎,使得性能比上一版本前提升了近2倍,详见http://www.easyjf.com/blog/html/20080103/1015816.html;
  3、多国语言功能增加了对 xml格式属性文件的支持,http://jira.easyjf.com/browse/EASYJWEB-33。
  4、增加从服务器输入JSon数据对象的快捷支持。
  5、提供了更多的EastJWeb实例应用,详见http://easyjweb.demo.easyjf.com/。
  6、修正了这两个月来大家提出的Bug及调整了一些功能,详细见jira.easyjf.com。
  7、完善了入门文档,详见wiki.easyjf.com。

  源码下载:ftp://ftp1.easyjf.com/easyjweb/easyjweb-1.1/easyjweb-1.1.zip
  在线示例:http://easyjweb.demo.easyjf.com
  在线文档:http://wiki.easyjf.com/display/wiki/EasyJWeb

  这里对Rich Component及Ajax改进作简单介绍。

一、EasyJWeb Rich Component

   EasyJWeb 1.1版提供了一套富客户端组件,也就是Rich Componet,可以用来与ExtJS等配合快速开发出基于Ajax的RIA应用。不再需要写烦琐的javascript,直接用java就能写出漂亮的基于ExtJS等客户端框架的Ajax应用,详见示例http://wlr2.easyjf.com/。
  比如只需要下面的Action代码:

Java代码
  1. public class SimpleAction extends RichComponentAction {   
  2. public Page doGrid() {   
  3. ViewPort view = new ViewPort();   
  4. GridPanel grid = new GridPanel("grid""数据表格",500,100);   
  5. grid.setColumns(new String[]{"id","姓名","出生日期","email"});                view.add(grid);   
  6. this.addComponent(view);   
  7. return  componentPage;   
  8. }   
  9. }  
public class SimpleAction extends RichComponentAction {
public Page doGrid() {
ViewPort view = new ViewPort();
GridPanel grid = new GridPanel("grid", "数据表格",500,100);
grid.setColumns(new String[]{"id","姓名","出生日期","email"});				view.add(grid);
this.addComponent(view);
return  componentPage;
}
}


  访问simple.ejf?cmd=grid将会得到一个非常漂亮的表格:

080218-8881.JPG

Java代码
  1. public Page doTree() {   
  2. ViewPort view = new ViewPort();   
  3. TreePanel tree=new TreePanel("tree","简单的树",200);   
  4. TreeNode root=new TreeNode("root","根");   
  5. root.add(new TreeNode("c1","孩子1"));   
  6. root.add(new TreeNode("c2","孩子2"));   
  7. root.getChildNodes().get(1).add(new TreeNode("c3","孙子"));   
  8. tree.setRoot(root);   
  9. view.add(tree);   
  10. this.addComponent(view);   
  11. return componentPage;   
  12. }  
public Page doTree() {
ViewPort view = new ViewPort();
TreePanel tree=new TreePanel("tree","简单的树",200);
TreeNode root=new TreeNode("root","根");
root.add(new TreeNode("c1","孩子1"));
root.add(new TreeNode("c2","孩子2"));
root.getChildNodes().get(1).add(new TreeNode("c3","孙子"));
tree.setRoot(root);
view.add(tree);
this.addComponent(view);
return componentPage;
}


  访问simple.ejf?cmd=tree将会得到一个还不错的树:

080218-8882.JPG

  如何实现一个添删改查、分页呢?看下面的代码:

Java代码
  1. public Page doCrud() {   
  2. ViewPort view = new ViewPort("fit");   
  3. CrudPanel crud = new SimpleCrud();   
  4. view.add(crud);   
  5. this.addComponents(view);   
  6. return componentPage;   
  7. }   
  8. public class SimpleCrud extends CrudPanel {   
  9. public SimpleCrud() {   
  10. super("test""简单测试""link.ejf");   
  11. this.setColumns(new String[][] { { "title""名称" },{ "url""网址" },   
  12. "rss""RSS" } });   
  13. this.getPagingToolbar().setDisplayInfo(true);   
  14. this.getGrid().load();   
  15. }   
  16. @Override  
  17. public Function getCreateWin() {   
  18. return new Function("return this.initWin(438,300,'连接管理');");   
  19. }   
  20. @Override  
  21. public Form getForm() {   
  22. Form f = new Form();   
  23. f.add(new TextField("title""主题"));   
  24. f.setLazy(false);   
  25. return f;   
  26. }   
  27. }  
public Page doCrud() {
ViewPort view = new ViewPort("fit");
CrudPanel crud = new SimpleCrud();
view.add(crud);
this.addComponents(view);
return componentPage;
}
public class SimpleCrud extends CrudPanel {
public SimpleCrud() {
super("test", "简单测试", "link.ejf");
this.setColumns(new String[][] { { "title", "名称" },{ "url", "网址" },
{ "rss", "RSS" } });
this.getPagingToolbar().setDisplayInfo(true);
this.getGrid().load();
}
@Override
public Function getCreateWin() {
return new Function("return this.initWin(438,300,'连接管理');");
}
@Override
public Form. getForm() {
Form. f = new Form();
f.add(new TextField("title", "主题"));
f.setLazy(false);
return f;
}
}



  访问simple.ejf?cmd=crud将会得到一个添删改查及分页的界面,点击“添加”、“修改”、“删除”、“刷新”等按钮可以执行相应的操作,如下图所示:

080218-8883.JPG

二、其它Ajax支持的改进及完善

  1、在以前EasyJWeb的Ajax支持引擎基础上,对远程脚本调用引擎中的脚本engine.js作了调整,使得回调函数可以选择作用域scope。
服务器业务组件:

Java代码
  1. public class PersonServiceImpl {   
  2. /**  
  3. * 得到服务器当前时间  
  4. * @return  
  5. */  
  6. public Date getTime() {   
  7. return new Date();   
  8. }   
  9. }  
public class PersonServiceImpl {
/**
* 得到服务器当前时间
* @return
*/
public Date getTime() {
return new Date();
}
}


  Bean配置文件:

Java代码
  1. "PersonService" class="easyjweb.demo.service.impl.PersonServiceImpl" />  


  在javascript中调用:

Java代码
  1. var s="作用域2";   
  2. var o=new function()   
  3. {   
  4. this.s="作用域1";   
  5. }   
  6. function callback(d)   
  7. {   
  8. alert("服务器时间:"+d);   
  9. alert(this.test);   
  10. }  
var s="作用域2";
var o=new function()
{
this.s="作用域1";
}
function callback(d)
{
alert("服务器时间:"+d);
alert(this.test);
}


  客户端读取服务器端时间的代码:
  PersonService.getTime(callback);//没有使用作用域
  PersonService.getTime(callback,new o());//回调函数在o实例作用域中使用域
  PersonService.getTime(callback,window);//回调函数在window作用域中执行

  2、增加向客户端输出JSon对象数据的快速方法。

Java代码
  1. public Page doList(WebForm form) {   
  2. QueryObject qo = form.toPo(QueryObject.class);   
  3. IPageList pageList = service.getLinkBy(qo);   
  4. form.jsonResult(pageList);   
  5. return Page.JSONPage;   
  6. }  
public Page doList(WebForm. form) {
QueryObject qo = form.toPo(QueryObject.class);
IPageList pageList = service.getLinkBy(qo);
form.jsonResult(pageList);
return Page.JSONPage;
}
  上面的代码实现把服务器端的pageList对象转换成JSON数据对象,并给客户端返回这个JSon数据对象。

  客户端可以这样使用:
Java代码
  1. var s=eval(req.responseText);   
  2. alert(s.rowCount);   
  3. for(var i=0;ialert(s.result[i].title);  
 var s=eval(req.responseText);
 alert(s.rowCount);
 for(var i=0;ialert(s.result[i].title);
  3、另外还对表单ajax提交等作了其它一些调整,详细请参考最新的api文档。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11310314/viewspace-181498/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/11310314/viewspace-181498/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值