Ajax is simple and practical framework of DWR

1. First of all, on the site to download the relevant jar package, dwr.jar, the jar package on the project under the lib directory

2. Write dao, service

dao methods:

/ *
* Based on the information store queries bsoid
* /
public JfFranInfo findByBsoid (Long bsoid) (
return (JfFranInfo) getHibernateTemplate (). get (JfFranInfo.class, bsoid);
)

The method of service:

/ *
* DWR to use, according to the current user bsoid inquiries balance inquiries
* /
public double findInfoByBsoid (long bsoid) (
JfFranInfo franinfo = jfFranInfoDAO.findByBsoid (bsoid);
double balance = franinfo.getFranBalance ();
return balance;
)

3. Is the dwr configuration file, and pay attention to dwr.xml name is on the WEB-INF directory

<? xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE dwr PUBLIC "- / / GetAhead Limited / / DTD Direct Web Remoting 2.0 / / EN" " http://getahead.org/dwr/dwr20.dtd ">
<dwr>
<allow>
<create creator="spring" javascript="PaymentManagerService">
<param name="beanName" value="PaymentManagerService"/>
<include method="findInfoByBsoid"/>
</ create>
</ allow>
</ dwr>

Should be introduced 4.JSP

<script type = "text / javascript" src ="<%= request.getContextPath ()%>/ dwr / interface / PaymentManagerService.js "> </ script>
<script type = "text / javascript" src ="<%= request.getContextPath ()%>/ dwr / engine.js "> </ script>
<script type = "text / javascript" src ="<%= request.getContextPath ()%>/ dwr / util.js "> </ script>
5. To perform the operation with event-triggered

js in writing:

function checkBalance () (
var bsoid = $ ( 'bsoid'). value;
PaymentManagerService.findInfoByBsoid (bsoid, callback);
)
function callback (msg) (
DWRUtil.setValue ( 'balance', msg);
)

JS page to add a reference

<script type = "text / javascript" src ="<%= request.getContextPath ()%>/ script / findBalance.js "> </ script>
Trigger events in the page with the location of onclick = "checkBalance ()". On the OK

Ability to express himself very poor, and if the statements do not understand, please forgive
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Ajax is simple and practical framework of DWR

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • JAVA EE JSP_JNDI

    dsfdsa http://lindows.javaeye.com/admin/blogs/213348 Tomcat 6 with the connection pool data source configuration http://www.blogjava.net/ec2008/archive/2008/07/19/216063.html project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • Hibernate.cfg.xml configuration file (including the primary key generation strategy Introduction)

    Hibernate.cfg.xml configuration file: <? xml version = "1.0" encoding = "utf-8"?> <! DOCTYPE hibernate-configuration PUBLIC "- / / Hibernate / Hibernate Configuration DTD / / EN" "hibernate-configuration-2.0.dtd

  • The EJB3 Persistence

    EJB3 persistence with Hibernate is very similar to the mechanism: Environment: Server: JBOSS5.0 Database: MySQL5.0 1. Set up a data source First of all, in jboss-5.0.0.GA \ server \ default \ deploy, the establishment of a database used to connect the dat

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries