• 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

Problem with logic:iterate

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am using struts 1.2.
I am getting the following problem.
I am trying to iterate through hospitaldata which is stored in request in an ArrayList.

On the JSP side I am using the following code
<td>5 Hospital Name:---</td>
<td>
<select Name="hospitalid">

<logic:iterate id="hosp" name="allhospitallist">
<option value='<bean:write name="hosp" property="hospitalid"/>'><bean:write name="hosp" property="hospitalname"/></option>
</logic:iterate>

</select>
</td>

hospitalData.hospitalid field is a java.lang.Long.
I am getting the following error:

javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.CreateUser_jsp._jspService(org.apache.jsp.CreateUser_jsp:244)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

When I use

<logic:iterate id="hosp" name="allhospitallist">
<option value='<bean:write name="hosp" property="hospitalname"/>'><bean:write name="hosp" property="hospitalname"/></option>
</logic:iterate>

There is no problem.


It seems that it has got to do something with the data type of id which is java.lang.Long.
Can anyone tell me what the problem is???

Thanks for your help in advance
Regards
Adrian
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The stack trace does not look like it has anything to do with rendering the tags. Does the problem happen when the page is rendered or when the page is submitted?

Also, that iteration should not be necessary. There are Struts tags for handling that. Off the top of my head, it should look something like this:
<html ptionsCollection name="allhospitallist" value="hospitalid" label="hospitalname"/>
 
adrian mills
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marc
Thanks for your answers.
I tried both the methods which you told but with no success.
I want to tell you some points.
Actually
HospitalData is a value object with
Long hospitalid
String hospitalname
String hospitalcity


I add mulptile such dataobjects to my arraylist collection(allhospitallist).


So my allhospitallist contains mulitple HospitalData objects.

When I try the following code on my front end.
<html:select property="hospitalId">


<logic:iterate id="hospitalData" name="allhospitallist">
<option value=''><bean:write name="hospitalData" property="hospitalID"/></option>
</logic:iterate>

</html:select>


I get the following exception

javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.AddHospitalAdmin_jsp._jspService(org.apache.jsp.AddHospitalAdmin_jsp:239)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)


The case is when I am trying to display the Long value hospitalid on the front end.If I try to acces anyother field from this data object such as hospitalcity etc everything is displayed properly.
Can you tell me how will i get access to the hospital id using the logic:iterate tag.

Action html ptionsCollection cannot be used as there is no label and property.

Both the hospital name field an hospitalid field are independent.

Thanks a lot Marc for your help.Hope u get to know what my real problem is.

Thanks once again.
Regards
Adrian
 
reply
    Bookmark Topic Watch Topic
  • New Topic