• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clarification for jstl <c:foreach> tag

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"><c:out value="${PresentationListDTO.request}"/></td>
<td class="table_field"><c:out value="${PresentationListDTO.name}"/></td>
<td class="table_field"><c:out value="${PresentationListDTO.company_desc}"/></td>
<td class="table_field"><c:out value="${PresentationListDTO.location_desc}"/></td>
<td class="table_field"><c:out value="${PresentationListDTO.office_desc}"/></td>
<td class="table_field"><c:out value="${PresentationListDTO.dept_desc}"/></td>
<td class="table_field"><c:out value="${PresentationListDTO.category_desc}"/></td>
<td>
<c:forEach var="PresentationListVo" begin="0" items="${PresentationListDTO.voList}" step="1">
<td class="table_field"><c:out 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
 
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are accessing ${PresentationListDTO.voList} but in the error you are getting something like "voLis" . Which is correct? The error or the jsp?
 
vamsi Pabbisetty
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you written the getter and setter methods for the voList in the PresentationListDTO class?
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
vamsi Pabbisetty
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have wriiten setter and getter methods.
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes unless you have a getRequest in PresentationListDTO.

but here is another question what is the type of voList ?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ask this on the JSP forum; this has nothing to do with Struts.
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Please ask this on the JSP forum; this has nothing to do with Struts.



I do post in Jsp forum
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic