wood burning stoves 2.0*
The moose likes Struts and the fly likes Problem with logic:iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with logic:iterate " Watch "Problem with logic:iterate " New topic
Author

Problem with logic:iterate

adrian mills
Ranch Hand

Joined: Dec 09, 2004
Posts: 63
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
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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"/>


A good workman is known by his tools.
adrian mills
Ranch Hand

Joined: Dec 09, 2004
Posts: 63
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with logic:iterate
 
Similar Threads
html:select and pulling out value
help with html radio tag
Nested:iterate
Null value from struts tag !
Struts Logic Tag problem