• 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 in displaying multiple search results

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me in this issue.

I have the following problem.

Am able to search a person by giving his first name and display the search result

But am not able to display multiple results.

For eg if two persons are having same same first name like Merril and Merril john

Am not getting multiple results for that

Am getting result as Merril John itself twice

How to get Merril and Merril John displayed in the same search results


Search Member Action

Search Member Data


SearchResults.jsp
<logic:iterate id="memberinfo" name="Member" scope="request">


<tr height=20px bgcolor=#FFFFFF>
<td align=left class=tdBorderRightBottom><bean:write name="memberinfo" property="firstName"/></td>
<td align=left class=tdBorderRightBottom><bean:write name="memberinfo" property="lastName"/></td>
<td align=left class=tdBorderRightBottom><bean:write name="memberinfo" property="employeeID"/></td>
<td align=center class=tdBorderRightBottom><bean:write name="memberinfo" property="emailID"/></td>
<td align=center class=tdBorderRightBottom><bean:write name="memberinfo" property="vnet"/></td>
<td align=left class=tdBorderRightBottom><bean:write name="memberinfo" property="extension"/></td>
<td align=left class=tdBorderRightBottom><bean:write name="memberinfo" property="mobileNumber"/></td>
</tr>

</logic:iterate >
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I think at this point

you need to specify the 'property' you want to iterate through as well.

You haven't posted code for the ActionForm, so I cannot tell you what this is.

As an aside, declaring variables like this:

or this:

will probably get you lynched by future maintenance programmers. Follow the java coding guidlines, specifically these ones and your code will magically transform into readable statements like


hope this helps
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, all of your seach methods are wrong. In every case, you only create one instance of the MemberInfo bean. Then, in your loop as you read through the result set, you're replacing the data in the same instace of the bean rather than creating a new instance for every row. Then you put that same instance into the array list. You end up having a liast of say, 10 rows, each of which is pointing to the same instance of MemberInfo, which has data for the last row in the ResultSet.

To solve this, move this line:

MemberInfo memberinfo= new MemberInfo();

from its current location to right after:

while(rs.next())
{

Do this in each of your search methods.

You also have a problem in your Action.

Remove the following statement from SearchMemberHNTeamProfileAction:

request.setAttribute("MemberInfo",memberinfo);

It's creating a neame conflict. In your <logic:iterate> tag in the JSP, you are also using a bean name of memberinfo. Here's what you're telling Struts to do when you write this tag:

<logic:iterate id="memberinfo" name="Member" scope="request">

Loop through every element of the ArrayList identified by the name "Member" in request scope. For each item in the array, create a bean with the name "memberinfo" that represents the current item in the loop. Any statements below this can use the name "memberinfo" to identify that bean.
[ July 24, 2006: Message edited by: Merrill Higginson ]
 
rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot
I created the instance for member info inside the result set and now
Am Getting multiple search results now
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic