• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

How to pass the search criteria parameter.

<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<pg:pager maxPageItems='10'>
<pg:param name="keywords"/>

...
StringBuffer sb = new StringBuffer();
sb.append("SELECT USERID, FIRST_NAME, LAST_NAME where 1=1")

String se = request.getParameter("search");
if (se != null)
{
out.print("<pg:param name='search' value='"+se+"')/>");
String lname = request.getParameter("lname");
if(lname!=null && !lname.equals(""))
{
sb.append(" AND LAST_NAME LIKE '"+lname+"'");
}

..
...
}
<ex:searchresults>
<pg:item>
..
.. // Get Data from DB and display here. 10 record per page.
...
</pg:item>
</ex:searchresults>
..
<pg:index>
<font face=Helvetica size=-1>Result Pages:
<pg:prev>
<a href="<%= pageUrl %>">[<< Previous ]</a>
</pg:prev>
<pg:pages>
<a href="<%= pageUrl %>"><%= pageNumber %></a>
</pg:pages>
<pg:next>
<a href="<%= pageUrl %>">[ Next >> ]</a>
</pg:next>
</pg:index>
</pg:param>
</pg:pager>

The above code display 10 records at a time. Now when someone search with lastname on search page. And let say they are 14 match the lastname. so my code displays first 10 records search query correctly. And when user click next or 2(Numberic 2 ) to see rest 4 records. 2nd Page don't show remaining 4 records but shows 10 records which is same 2nd page if search was not performed.

thx in advance.
0
princehyderabad
Asked:
princehyderabad
  • 4
  • 3
1 Solution
 
objectsCommented:
looks like it should be passing the lname parameter, and not search.
0
 
princehyderabadAuthor Commented:
I have top page [search colum page] and bottom page displays default records. so in default page I'm checking if "search=Y" which is declare in top page.

When somone search and submit it calls the same (default) page but this time it append the query with corresponding search colum.

0
 
objectsCommented:
yes, but the lname parameter is needed to do the query.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
princehyderabadAuthor Commented:
lname is just given in sample code, but they are actually few more fields.  Can you please kindly put one sample.
I hv been working on this for while still cant find solutions.
0
 
objectsCommented:
then you need to pass all fields that arte required. otherwise how can you make the correct query.
0
 
princehyderabadAuthor Commented:
U mean pass here as:
<a href="<%= pageUrl %>?lname=<%=lname%>& .....">
0
 
objectsCommented:
thats one way, or use pg:param
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now