jidalhl
jidalhl
2012-10-03 09:54

如何让DWR中的2个方法都起作用啊?请帮帮我,谢谢!

  • dwr

我写了一个DWR通用工具类,页面DWR请求都通过这个工具类找相应的方法。

public class DwrServiceUtil {
    private DepartmentService departmentService;
    private SupplierService supplierService;
    
    public List getUsersByDepartmentId(int departmentId){
        List<Employee> employees = departmentService.getEmployeesByDepartmentId(departmentId);
        System.out.println("list:"+employees.size());
        
        return employees;
    }
    public List getGoodsesBySupplierId(int supplierId){
        List<Goods> goodses = supplierService.getGoodsesBySupplierId(supplierId);
        return goodses;
    }
    public void setDepartmentService(DepartmentService departmentService) {
        this.departmentService = departmentService;
    }
    public void setSupplierService(SupplierService supplierService) {
        this.supplierService = supplierService;
    }
}

 dwr.xml中的代码如下:

<dwr>
    <allow>
        <create javascript="dwrserviceutil" creator="spring">
            <param name="beanName" value="dwrServiceUtil"/>
        </create> 
        <convert match="com.erp.entity.Goods" converter="bean"></convert>
        <convert match="com.erp.entity.Employee" converter="bean"></convert>
    </allow>
</dwr>

 以下是2个实体的xml的部分配置:

beans-department.xml

<bean id="dwrServiceUtil" class="com.erp.util.DwrServiceUtil">
         <property name="departmentService" ref="departmentService"></property>
</bean>

beans-supplier.xml

<bean id="dwrServiceUtil" class="com.erp.util.DwrServiceUtil">
         <property name="supplierService" ref="supplierService"></property>
</bean>

 在dwr的测试页面进行测试时发现,只有1个方法有效。后来经过调试,只要注释掉上面2个实体xml中的其中一个的代码,另一个方法才有效,请问,怎样才能让2个方法都有效啊?谢谢!

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答