chaitu chaitu
asked on
The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer
javax.servlet.ServletExcep tion: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.
public ModelAndView handleRequest(HttpServletR equest request,
HttpServletResponse response) throws
Exception {
return new ModelAndView("ViewAllMyObj ects","myO bjectModel ",empObjec tDao.getAl lMyObjectV Os(1));
}
empObjectDao.getAllMyObjec tVOs(1) return Object ;in that object myObjectModel.Results returns List ;
javax.servlet.ServletExcep tion: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.
<c:forEach items="${myObjectModel.Res ults}" var="mobj" varStatus="status">
<tr>
<td> <a href="MyObjectForm.html?id =${mobj.id }">${mobj. id}</a> </td>
<td> ${mobj.name}</td>
<td> ${mobj.address}</td>
<td> ${mobj.email}</td>
<td> ${mobj.phone}</td>
</tr>
</c:forEach>
public ModelAndView handleRequest(HttpServletR
HttpServletResponse response) throws
Exception {
return new ModelAndView("ViewAllMyObj
}
empObjectDao.getAllMyObjec
javax.servlet.ServletExcep
<c:forEach items="${myObjectModel.Res
<tr>
<td> <a href="MyObjectForm.html?id
<td> ${mobj.name}</td>
<td> ${mobj.address}</td>
<td> ${mobj.email}</td>
<td> ${mobj.phone}</td>
</tr>
</c:forEach>
>> In that case, mobj.id will not be able to identify "id".
should be
>In that case, mobj.id will not be able to identify "id", "name", "address"..etc
fargo
should be
>In that case, mobj.id will not be able to identify "id", "name", "address"..etc
fargo
<c:forEach items="${myObjectModel.Res ults}" var="mobj" varStatus="status">
<tr>
<td> <a href='MyObjectForm.html?id =<c:out value="${mobj.id}"/>' ><c:out value="${mobj.id}"/></a> </td>
<td> <c:out value="${mobj.name}" /></td>
<td> <c:out value="${mobj.address}"/>< /td>
<td> <c:out value="${mobj.email}"/></t d>
<td> <c:out value="${mobj.phone}"/></t d>
</tr>
</c:forEach>
try this out , it will most probably work.
Cheers
<tr>
<td> <a href='MyObjectForm.html?id
<td> <c:out value="${mobj.name}" /></td>
<td> <c:out value="${mobj.address}"/><
<td> <c:out value="${mobj.email}"/></t
<td> <c:out value="${mobj.phone}"/></t
</tr>
</c:forEach>
try this out , it will most probably work.
Cheers
ASKER
i already tried its not working
just to check what mobj is returning,
print it on the page..
<c:forEach items="${myObjectModel.Res ults}" var="mobj" varStatus="status">
<td> <c:out value="${mobj}" /></td>
</c:forEach>
I think Fargo is correct in his assumption that the list being returned is not of beans...
print it on the page..
<c:forEach items="${myObjectModel.Res
<td> <c:out value="${mobj}" /></td>
</c:forEach>
I think Fargo is correct in his assumption that the list being returned is not of beans...
ASKER
dataBaseList is the List of beans;dataBaseList is added into mainList(this is another arraylist) and it is assigned it to searchModel.searchResults;
public SearchModel getAllMyObjectVOs(SearchMo del searchModel) {
while (maxRows > i++) {
dataBaseList.add((Employee )scr.get(0 ));
}
mainList.add(dataBaseList) ;
searchModel.totalRecords= l.size();
searchModel.searchResults = mainList;
return searchModel;
}
public SearchModel getAllMyObjectVOs(SearchMo
while (maxRows > i++) {
dataBaseList.add((Employee
}
mainList.add(dataBaseList)
searchModel.totalRecords= l.size();
searchModel.searchResults = mainList;
return searchModel;
}
Hi,
So it means you have list of list. It definitely means you have to change the handling in JSTL tags. OR in the first place why do u need to add it in another list ?
fargo
So it means you have list of list. It definitely means you have to change the handling in JSTL tags. OR in the first place why do u need to add it in another list ?
fargo
ASKER
in dataBaseList i have only Employee objects and also i need totalrecords and pagenumber that is not there in employee object so i have taken another object i.e searchModel
Hi,
May be making a copy is better for you and you need not to change the jstl handling
public SearchModel getAllMyObjectVOs(SearchMo del searchModel) {
while (maxRows > i++) {
dataBaseList.add((Employee )scr.get(0 ));
}
Object[] contents = dataBaseList.toArray();
Object[] newArray = new Object[contents.length];
System.arraycopy(contents, 0, newArray, 0, contents.length);
searchModel.totalRecords= l.size();
searchModel.searchResults = Arrays.asList(newArray);
return searchModel;
}
fargo
May be making a copy is better for you and you need not to change the jstl handling
public SearchModel getAllMyObjectVOs(SearchMo
while (maxRows > i++) {
dataBaseList.add((Employee
}
Object[] contents = dataBaseList.toArray();
Object[] newArray = new Object[contents.length];
System.arraycopy(contents,
searchModel.totalRecords= l.size();
searchModel.searchResults = Arrays.asList(newArray);
return searchModel;
}
fargo
ASKER
how do i change jstl handling
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
As you yourself said that the return from myObjectModel.Results is a List. Is it a List of Beans??? Or just a plain List.
I believe, the returned List is a plain List and NOT the list of beans. In that case, mobj.id will not be able to identify "id".
fargo