aspose file tools*
The moose likes Struts and the fly likes Clarification for jstl <c:foreach> tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Clarification for jstl <c:foreach> tag" Watch "Clarification for jstl <c:foreach> tag" New topic
Author

Clarification for jstl <c:foreach> tag

vamsi Pabbisetty
Greenhorn

Joined: Feb 04, 2009
Posts: 6
HI,
I am facing one issue regarding following scenario.

I am getting one array list to jsp page .I am using Jstl (<c:foreach>) for looping through Arraylist. But Arraylist contains Dto which intern contains Arraylist of Vo(value objects)

Problem : I am not able to access Arraylist which is available in Dto.

Code Sample


<c:forEach var="PresentationListDTO" begin="0" items="${modifyList}" step="1" varStatus="status">


<tr>
<td class="table_field"><cut value="${PresentationListDTO.request}"/></td>
<td class="table_field"><cut value="${PresentationListDTO.name}"/></td>
<td class="table_field"><cut value="${PresentationListDTO.company_desc}"/></td>
<td class="table_field"><cut value="${PresentationListDTO.location_desc}"/></td>
<td class="table_field"><cut value="${PresentationListDTO.office_desc}"/></td>
<td class="table_field"><cut value="${PresentationListDTO.dept_desc}"/></td>
<td class="table_field"><cut value="${PresentationListDTO.category_desc}"/></td>
<td>
<c:forEach var="PresentationListVo" begin="0" items="${PresentationListDTO.voList}" step="1">
<td class="table_field"><cut value="${PresentationListVo.item}"/></td>
</c:forEach>

</td>

</
</c:forEach>

Geiing error while executing Inner <c:foreach> loop.
error - "${PresentationListDTO.voLis}": Unable to find a value for "voLis" in object of class
Balagopal Kannampallil
Ranch Hand

Joined: Oct 18, 2004
Posts: 136

You are accessing ${PresentationListDTO.voList} but in the error you are getting something like "voLis" . Which is correct? The error or the jsp?


SCJP 5.0 and now fighting with ExtJS
vamsi Pabbisetty
Greenhorn

Joined: Feb 04, 2009
Posts: 6
Thanks for quick response

Error i am getting is

"${PresentationListDTO.voList}": Unable to find a value for "voList" in object of class 'Dto class'
using operator "." (null)

Balagopal Kannampallil
Ranch Hand

Joined: Oct 18, 2004
Posts: 136

Have you written the getter and setter methods for the voList in the PresentationListDTO class?
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
when you use the "." operator in EL language the first item should be a Bean or a Map however i think that PresentationListDTO is neither one, so i would suggest to use the [ ] operators to access it.


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
vamsi Pabbisetty
Greenhorn

Joined: Feb 04, 2009
Posts: 6
I have wriiten setter and getter methods.
Balagopal Kannampallil
Ranch Hand

Joined: Oct 18, 2004
Posts: 136

when you use the "." operator in EL language the first item should be a Bean or a Map however i think that PresentationListDTO is neither one, so i would suggest to use the [ ] operators to access it.

If PresentationListDTO was not a bean then it would have thrown error at this line itself

Am I right?
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
Yes unless you have a getRequest in PresentationListDTO.

but here is another question what is the type of voList ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please ask this on the JSP forum; this has nothing to do with Struts.
Balagopal Kannampallil
Ranch Hand

Joined: Oct 18, 2004
Posts: 136

Hi Vamsi,

Please publish your classes here so that we can investigate the issue further. Don't forget to embed your code inside the [code] tag.
vamsi Pabbisetty
Greenhorn

Joined: Feb 04, 2009
Posts: 6
David Newton wrote:Please ask this on the JSP forum; this has nothing to do with Struts.


I do post in Jsp forum
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Clarification for jstl <c:foreach> tag