📄 tutorial.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Buffalo AJAX - 1 Minute Tutorial</title>
<style type="text/css" media="all">
@import url("./css/maven-base.css");
@import url("./css/maven-theme.css");
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body class="composite">
<div id="banner">
<a href="index.html" id="bannerLeft">
<img src="images/buffalo-title.gif" alt="" />
</a>
<a href="http://sourceforge.net" id="bannerRight">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=178867&type=1" alt="" />
</a>
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
Last Published: 10/08/2006
</div>
<div class="xright"> <a href="http://www.amowa.net/buffalo/zh">Chinese Docs</a>
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>Quick Start</h5>
<ul>
<li class="none">
<strong>1 Minute Tutorial</strong>
</li>
<li class="none">
<a href="http://demo.amowa.net/buffalo-demo/">Demo</a>
</li>
<li class="none">
<a href="download.html">Download</a>
</li>
<li class="none">
<a href="features.html">Features</a>
</li>
<li class="none">
<a href="faq.html">FAQ</a>
</li>
</ul>
<h5>Mastering Buffalo</h5>
<ul>
<li class="none">
<a href="best_practice.html">Best Practise</a>
</li>
<li class="none">
<a href="howto.html">How to...</a>
</li>
</ul>
<h5>Reference</h5>
<ul>
<li class="none">
<a href="jsapi.html">JavaScript API</a>
</li>
</ul>
<a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
<img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<div class="section"><h2>1 Minute Tutorial </h2><div class="section"><h3>Prepare</h3><p>Please download the latest version of buffalo distribution. Create a directory structure as follows:</p><div class="source"><pre>buffalo-example
WEB-INF/classes
WEB-INF/lib
script
</pre></div><p>Copy burlap-2.1.2.jar, buffalo-<i>version</i>.jar to WEB-INF/lib, copy prototype.js, buffalo.js to script.</p></div><div class="section"><h3>Edit web.xml</h3><p>Create a web.xml in WEB-INF with content as follow:</p><div class="source"><pre><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Buffalo Example Application</display-name>
<servlet>
<servlet-name>bfapp</servlet-name>
<servlet-class>net.buffalo.web.servlet.ApplicationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>bfapp</servlet-name>
<url-pattern>/bfapp/*</url-pattern>
</servlet-mapping>
</web-app>
</pre></div></div><div class="section"><h3>Edit buffalo-service.properties</h3><p>Create a text file buffalo-service.properties to WEB-INF/classes with content as follow:</p><div class="source"><pre># Example Service
helloService=example.HelloService
</pre></div></div><div class="section"><h3>Edit JSP file</h3><p>Create example.jsp in the web root:</p><div class="source"><pre><html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Example::Hello</title>
<script language="javascript" src="script/prototype.js"></script>
<script language="javascript" src="script/buffalo.js"></script>
<script language="javascript">
var END_POINT="<%=request.getContextPath()%>/bfapp";
var buffalo = new Buffalo(END_POINT);
function hello() {
var p1 = $("myname").value;
buffalo.remoteCall("helloService.hello",[p1], function(reply) {
alert(reply.getResult());
});
}
</script>
</head>
<body>
<p>Buffalo Hello World</p>
<p>&nbsp;</p>
<form name="form1" method="post" action="">
Your name:
<input name="myname" type="text" id="myname">
<input type="button" name="Submit" value="Hello" onclick="hello()">
</form>
</body>
</html>
</pre></div></div><div class="section"><h3>Adding a Service</h3><div class="source"><pre>package example;
public class HelloService {
public String hello(String name) {
try {
// to see the loading status
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "Hello, " + name;
}
}
</pre></div><p>Compile it and copy the binary class file to WEB-INF/classes.</p></div><div class="section"><h3>Final step: run the application</h3><p>Copy the whole buffalo-exmaple directory to TOMCAT_HOME/webapps, start tomcat, open browser and visit http://localhost:8080/buffalo-example/example.jsp, input your name and click "Hello" button, see the result.</p></div><div class="section"><h3>Further more</h3><p>Please read spring integration and best practice for more information</p></div></div>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">©
2004-2006
</div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -