Back Forum Reply New

Help to track error in this code

Hello All,

I am new to DWR, I tried one example available at web. Please help me to track the reason and solution of error.

EmployeeBean.java

Code:
package com.deepak.beans;

public class EmployeeBean {

private String employeeName;
private String employeeAddress;
private String employeePhoneNo;
private String employeeDepartment;public EmployeeBean(String employeeName, String employeeAddress, String employeePhoneNo, String employeeDepartment) {
super();
this.employeeName = employeeName;
this.employeeAddress = employeeAddress;
this.employeePhoneNo = employeePhoneNo;
this.employeeDepartment = employeeDepartment;
}

public String getEmployeeAddress() {
return employeeAddress;
}
public void setEmployeeAddress(String employeeAddress) {
this.employeeAddress = employeeAddress;
}
public String getEmployeeDepartment() {
return employeeDepartment;
}
public void setEmployeeDepartment(String employeeDepartment) {
this.employeeDepartment = employeeDepartment;
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public String getEmployeePhoneNo() {
return employeePhoneNo;
}
public void setEmployeePhoneNo(String employeePhoneNo) {
this.employeePhoneNo = employeePhoneNo;
}
}
EmployeeService.java

Code:
package com.deepak.service;

import java.util.ArrayList;
import java.util.List;

import com.deepak.beans.EmployeeBean;

public class EmployeeService {

private final EmployeeBean[] employeeList = {
new EmployeeBean(quot;Deepakquot;, quot;Sector-11quot;, quot;9971851678quot;, quot;JAVAquot;),
new EmployeeBean(quot;Ajayquot;, quot;Sector-51quot;, quot;9212316153quot;, quot;.NETquot;),
new EmployeeBean(quot;KAPILquot;, quot;Laxmi Nagarquot;, quot;1235698458quot;, quot;ACCOUNTSquot;),
new EmployeeBean(quot;RPSquot;, quot;Sector-22quot;, quot;1234567891quot;, quot;JAVAquot;),
new EmployeeBean(quot;Nirmalquot;, quot;Sector-52quot;, quot;3216549873quot;, quot;HRquot;),
new EmployeeBean(quot;Jasveerquot;, quot;Shipraquot;, quot;1239874569quot;, quot;JAVAquot;)
};public List getEmployeeList(){
List employeeList = new ArrayList();
EmployeeBean employeeBean = null;
for (int i = 0; i lt; this.employeeList.length; i++) {
employeeBean = this.employeeList[i];
employeeList.add(employeeBean);
}
return employeeList;
}

public EmployeeBean getEmployee(String employeeName){
EmployeeBean employeeBean = null;
for (int i = 0; i lt; this.employeeList.length; i++) {
employeeBean = this.employeeList[i];
if(employeeBean.getEmployeeName().equalsIgnoreCase(employeeName)){
return employeeBean;
}
}
return null;
}
}
web.xml

Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;web-app version=quot;2.4quot;
xmlns=quot;xml/ns/j2eequot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xsi:schemaLocation=quot;xml/ns/j2ee
xml/ns/j2ee/web-app_2_4.xsdquot;gt;

lt;servletgt;
lt;servlet-namegt;dwrlt;/servlet-namegt;
lt;servlet-classgt;org.directwebremoting.servlet.DwrServletlt;/servlet-classgt;
lt;init-paramgt;
lt;param-namegt;debuglt;/param-namegt;
lt;param-valuegt;truelt;/param-valuegt;
lt;/init-paramgt;
lt;/servletgt;

lt;servlet-mappinggt;
lt;servlet-namegt;dwrlt;/servlet-namegt;
lt;ucl-patterngt;/dwr/*lt;/ucl-patterngt;
lt;/servlet-mappinggt;

lt;/web-appgt;
dwr.xml

Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;!DOCTYPE dwr PUBLIC quot;-//GetAhead Limited//DTD Direct Web Remoting 1.0//ENquot;
quot;dwr/dwr10.dtdquot;gt;

lt;dwrgt;
lt;allowgt;
lt;convert match=quot;com.deepak.beans.EmployeeBeanquot; converter=quot;beanquot;/gt;
lt;create javascript=quot;Employeequot; creator=quot;newquot;gt;
lt;param name=quot;classquot; value=quot;com.deepak.service.EmployeeServicequot;/gt;
lt;/creategt;
lt;/allowgt;
lt;/dwrgt;
employeeform.html

Code:
lt;htmlgt;
lt;headgt;
lt;script type=quot;text/javascriptquot; src=quot;dwr/engine.jsquot;/gt;
lt;script type=quot;text/javascriptquot; src=quot;dwr/interface/Employee.jsquot;/gt;
lt;script type=quot;text/javascriptquot; src=quot;dwr/utils.jsquot;/gt;

lt;script type=quot;text/javascriptquot; language=quot;javascriptquot;gt;

function getConsumers(){
Employee.getEmployeeList(updateTable);
}
function updateTable(results){
DWRUtils.removeAllRows(quot;employeeTablequot;);
DWRUtils.addRows(quot;employeeTablequot;, results, cellFuncs);
}
function cellFuncs = [
function(data) {return data.employeeName}
function(data) {return data.employeeAddress}
function(data) {return data.employeePhoneNo}
function(data) {return data.employeeDepartment}
];
lt;/scriptgt;

lt;/headgt;

lt;input type=quot;buttonquot; value=quot;Get All Employeesquot; onclick=quot;getConsumers();quot;/gt;
lt;brgt;
lt;brgt;
lt;tablegt;
lt;theadgt;
lt;trgt;
lt;tdgt;
Name
lt;/tdgt;
lt;tdgt;
Address
lt;/tdgt;
lt;tdgt;
Phone No
lt;/tdgt;
lt;tdgt;
Department
lt;/tdgt;
lt;/trgt;
lt;/theadgt;
lt;tbody id=quot;employeeTablequot;gt;lt;/tbodygt;
lt;/tablegt;

lt;/htmlgt;
This page has one button, i need that when i click on button the list of employees should be populated in the table. I tried this on IE 6.0 but is is giving javascript error-Object Not Found - on line 26. Please help to track the reason and how to resolve this.

Have you tried the DWR debug site? does the exposed DWR service(s) work from the debug site? No errors in your application server log?
¥
Back Forum Reply New