dcoco 2009-05-21 06:33
浏览 290
已采纳

DWR调用带参数的方法

TblFwxx

[code="java"]
package com.accp.myhouse.pojo;

import java.util.Date;

/**

  • TblFwxx entity.
  • @author MyEclipse Persistence Tools */

public class TblFwxx implements java.io.Serializable {

// Fields

private Integer fwid;
private TblJd tblJd;
private TblFwlx tblFwlx;
private TblUser tblUser;
private Integer shi;
private Integer ting;
private String fwxx;
private Double zj;
private String title;
private Date date;
private String telephone;
private String lxr;

private Double zjLow;
private Double zjHigh;
private Date startDate;
// Constructors

/** default constructor */
public TblFwxx() {
}

/** minimal constructor */
public TblFwxx(TblJd tblJd, TblFwlx tblFwlx, TblUser tblUser) {
    this.tblJd = tblJd;
    this.tblFwlx = tblFwlx;
    this.tblUser = tblUser;
}

/** full constructor */
public TblFwxx(TblJd tblJd, TblFwlx tblFwlx, TblUser tblUser, Integer shi,
        Integer ting, String fwxx, Double zj, String title, Date date,
        String telephone, String lxr) {
    this.tblJd = tblJd;
    this.tblFwlx = tblFwlx;
    this.tblUser = tblUser;
    this.shi = shi;
    this.ting = ting;
    this.fwxx = fwxx;
    this.zj = zj;
    this.title = title;
    this.date = date;
    this.telephone = telephone;
    this.lxr = lxr;
}

// Property accessors

public Integer getFwid() {
    return this.fwid;
}

public void setFwid(Integer fwid) {
    this.fwid = fwid;
}

public TblJd getTblJd() {
    return this.tblJd;
}

public void setTblJd(TblJd tblJd) {
    this.tblJd = tblJd;
}

public TblFwlx getTblFwlx() {
    return this.tblFwlx;
}

public void setTblFwlx(TblFwlx tblFwlx) {
    this.tblFwlx = tblFwlx;
}

public TblUser getTblUser() {
    return this.tblUser;
}

public void setTblUser(TblUser tblUser) {
    this.tblUser = tblUser;
}

public Integer getShi() {
    return this.shi;
}

public void setShi(Integer shi) {
    this.shi = shi;
}

public Integer getTing() {
    return this.ting;
}

public void setTing(Integer ting) {
    this.ting = ting;
}

public String getFwxx() {
    return this.fwxx;
}

public void setFwxx(String fwxx) {
    this.fwxx = fwxx;
}

public Double getZj() {
    return this.zj;
}

public void setZj(Double zj) {
    this.zj = zj;
}

public String getTitle() {
    return this.title;
}

public void setTitle(String title) {
    this.title = title;
}

public Date getDate() {
return this.date;  

}

public void setDate(Date date) {
    this.date = date;
}

public String getTelephone() {
    return this.telephone;
}

public void setTelephone(String telephone) {
    this.telephone = telephone;
}

public String getLxr() {
    return this.lxr;
}

public void setLxr(String lxr) {
    this.lxr = lxr;
}

public Double getZjLow() {
    return zjLow;
}

public void setZjLow(double zjLow) {
    this.zjLow = zjLow;
}

public Double getZjHigh() {
    return zjHigh;
}

public void setZjHigh(double zjHigh) {
    this.zjHigh = zjHigh;
}

public Date getStartDate() {
    return startDate;
}

public void setStartDate(Date startDate) {
    this.startDate = startDate;
}

}
[/code]

TblJd
[code="java"]
package com.accp.myhouse.pojo;

import java.util.HashSet;
import java.util.Set;

/**

  • TblJd entity.
  • @author MyEclipse Persistence Tools */

public class TblJd implements java.io.Serializable {

// Fields

private Integer jdid;
private TblQx tblQx;
private String jd;
private Set tblFwxxes = new HashSet(0);

// Constructors

/** default constructor */
public TblJd() {
}

/** minimal constructor */
public TblJd(TblQx tblQx, String jd) {
    this.tblQx = tblQx;
    this.jd = jd;
}

/** full constructor */
public TblJd(TblQx tblQx, String jd, Set tblFwxxes) {
    this.tblQx = tblQx;
    this.jd = jd;
    this.tblFwxxes = tblFwxxes;
}

// Property accessors

public Integer getJdid() {
    return this.jdid;
}

public void setJdid(Integer jdid) {
    this.jdid = jdid;
}

public TblQx getTblQx() {
    return this.tblQx;
}

public void setTblQx(TblQx tblQx) {
    this.tblQx = tblQx;
}

public String getJd() {
    return this.jd;
}

public void setJd(String jd) {
    this.jd = jd;
}

public Set getTblFwxxes() {
    return this.tblFwxxes;
}

public void setTblFwxxes(Set tblFwxxes) {
    this.tblFwxxes = tblFwxxes;
}

}
[/code]

我用DWR做的AJAX

现在我要根据jdid来查询房屋信息
该怎么办啊?
查询方法的代码如下:
[code="java"]
public int findFwxxTotalNumByCondition(final TblFwxx fwxx) {
return (Integer)getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Criteria c = session.createCriteria(TblFwxx.class);
c.setProjection(Projections.count("fwid"));
if(fwxx.getTblJd()!=null){
c.add(Restrictions.eq("tblJd.jdid", fwxx.getTblJd().getJdid()));
}
return c.uniqueResult();
}
});
}
[/code]
任何用DWR调用这样的方法啊?
谢谢各位大大了!

DWR配置文件
[code="XML"]
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">

<create>
    <param name="location" value="applicationContext.xml"></param> 
</create>

<create creator="new" javascript="JDate">
    <param name="class" value="java.util.Date"/>
</create>

<create creator="new" javascript="Demo">
    <param name="class" value="your.java.Bean"/>
</create>
<create creator="spring" javascript="findJd">  
    <param name="beanName" value="jdService" />  
</create>  
<create javascript="findFwxx" creator="spring">
    <param name="beanName" value="fwxxService"></param>
    <include method="findFwxxForPageListByCondition"/>
</create>

<convert converter="bean" match="com.accp.myhouse.pojo.TblJd">
</convert>  

<convert converter="bean" match="com.accp.myhouse.pojo.TblFwxx">

</convert>  

[/code]

  • 写回答

1条回答 默认 最新

  • iteye_10298 2009-05-21 10:47
    关注

    步骤如下:

    1)在dwr.xml中添加com.accp.myhouse.pojo.TblFwxx极其依赖的Converter



    2)在dwr.xml中声明Action



    3)在客户端引用Action

    4)调用

    var fwxx = { }; //构造参数

    FwxxAction.findFwxxTotalNumByCondition(fwxx, function(){
    });

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料