Hi
The following ones are my sample ones, but when I'm using optionsCollection with the property attribute it gives an error saying that "No getter method available for property label for bean under name com.mreddy.sample.DepartmentUtil" . Pls let me know how to solve this issue ASAP.
I have in
jsp the following tag Custome tag (dataSet and DatSource tags)
ds
ataSet var="DepartmentSet">
<ds
ataSource name="com.mreddy.sample.DepartmentDS">
<ds:argument name="TYPE_OF_ELEMENTS_IN_DATA_ARGUMENT_NAME" value="DepartmentUtil" />
</ds
ataSource>
</ds
ataSet>
Departments :<html:select property="departmentListSelection">
<html
ptionsCollection name="DepartmentSet" property="departments" />
</html:select>
And in DepartmentUtil.java file I have the following code
public class DepartmentUtil implements Serializable{
private
String deptNo;
private String dName;
private String loc;
public DepartmentUtil() {super();
}
public DepartmentUtil(String deptNo,String dName,String loc) {
this.deptNo = deptNo;
this.dName = dName;
this.loc = loc;
}
public String getDeptNo() {
return deptNo;
}
public void setDeptNo(String deptNo) {
this.deptNo = deptNo;
}
public String getDName() {
return dName;
}
public void setDName(String dName) {
this.dName = dName;
}
public String getLoc(){
return loc;
}
public void setLoc(String loc){
this.loc=loc;
}
static ArrayList departments = new ArrayList();
static {
departments.add(new DepartmentUtil("A10","DEV","A1"));
departments.add(new DepartmentUtil("B10","Arch","B1"));
departments.add(new DepartmentUtil("C10","DA","C1"));
departments.add(new DepartmentUtil("D10","BA","D1"));
}
public static ArrayList getDepartments(){
return departments;
}
}
And I created a dataSource DepartmentDS.java class
public class DepartmentDS implements DataSource{
//private EmployeeRAS employeeRAS;
//private Department dept;
private Criteria criteria;
private List depts;
private UtilBean utilbean;
private DepartmentUtil deptutil;
public List getData(Criteria criteria) throws Exception {
String elementsInData = getArgumentValue(criteria.getQuery().getArguments(),TYPE_OF_ELEMENTS_IN_DATA_ARGUMENT_NAME );
String kindOfData=getArgumentValue(criteria.getQuery().getArguments(),KIND_OF_DATA_ARGUMENT_NAME );
return DepartmentUtil.getDepartments();
}
private String getArgumentValue(Map arguments, String key){
if (arguments == null) {
return null;
}
List values = (List) arguments.get(key);
if (values != null) {
return (String) values.get(0);
}
else{
return null;
}
}
}
And I have the ActionForm and Action classes as usual. Please advise.
Regards
Shyam