posts - 33,  comments - 70,  trackbacks - 0

buffalo文档之buffalo-demo(1)--除法运算器 <br>
buffalo
官方站: http://www.amowa.com   <br>
国内的ajax,amowa开源项目<br>

doc.simle.jsp

<%@ page contentType="text/html;charset=utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
除法运算器</title>
<script language="JavaScript" src="js/prototype.js"></script>
<script language="JavaScript" src="js/buffalo.js"></script>
<script language="JavaScript" src="js/template.js"></script>

<script language="javascript">
var endPoint="<%=request.getContextPath()%>/BUFFALO";
var buffalo = new Buffalo(endPoint);

function cmdDivide() {
 var double1 = parseFloat(Buffalo.getElementById("double1").value);
 var double2 = parseFloat(Buffalo.getElementById("double2").value);
 var d3Handle = Buffalo.getElementById("double3");
 
 buffalo.remoteCall("simpleService.divide",[double1,double2], function(reply) {
  d3Handle.value = reply.getResult();
 })
}
</script>
<input name="double1" type="text" class="input_text" id="double1" size="12">
  /
  <input name="double2" type="text" class="input_text" id="double2" size="12">
  <input type="button" name="Submit" value=" = " onclick="cmdDivide()">
  <input name="double3" type="text" class="input_text" id="double3">
</html>

web.xml
<servlet>
  <servlet-name>service</servlet-name>
  <servlet-class>net.buffalo.server.BuffaloServiceServlet</servlet-class>
  <init-param>
   <param-name>debug</param-name>
   <param-value>true</param-value>
  </init-param>
 </servlet>
 
 <servlet-mapping>
  <servlet-name>service</servlet-name>
  <url-pattern>/BUFFALO</url-pattern>
 </servlet-mapping>

SimpleService.java

package net.buffalo.demo.simple;

import ;

public class SimpleService {
 
 
public double divide(double a, double b) {
     System.out.println(
"Calling Divide,a="+a+", b="+b);
  
try {
      Thread.sleep(
1000);
  }
 catch (Exception e) {
      e.printStackTrace();
  }

     
return a/b;
 }


}



 buffalo.remoteCall("simpleService.divide",[double1,double2], function(reply) {
  d3Handle.value = reply.getResult();
 })
buffalo对象访问 SimpleService.java 中divide方法。 返回结果(reply.getResult();)赋值给d3Handle.

如此简单清晰的方法调用,实在是简洁。慢慢的进入buffalo,就可能清楚的明白它的原来。没什么好说的,再清楚不过的代码了。if try it first yourself again when you konw it very well.

posted on 2005-12-04 23:40 地狱男爵(hellboys) 阅读(297) 评论(0)  编辑  收藏

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


网站导航:
 
<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

随笔分类

随笔档案

文章档案

相册

连接

最新随笔

搜索

  •  

最新评论

阅读排行榜

评论排行榜