• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Generating Action for multiple search option

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a JSP page where there are multiple options for search, i.e. "search by Application id", "search by Applicant name" etc. I have used struts EventDispatchAction to catch the event generated by a particular submit button. This is working fine. Below is the snap of the struts-config file for this:

<action name="SearchApplicationForm" path="/searchApplication" scope="session" parameter="idSubmit,nameSubmit" type="SearchApplicationAction" validate="false">
<forward name="idForward" path="searchApplication"/>
<forward name="nameForward" path="searchApplication"/>
</action>

Now if I am facing problem in paginating the search results, because I am not able to generate event when the page numbers are clicked. They are hyperlinks. Below is the code used to generate the page numbers:

<c:forEach items="${pagelist}" var="emp">

<td><a href="#?page=${emp}">${emp}</a></td>
</c:forEach>

I am not sure what to put in place of # to generate event for EventDispatchAction.
Any help in this regard will be very helpful. Thanks
 
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set the url to be used in paging from the action class. Declare the Paging_Url_var and set the values accordingly from the action class. If it is for searchByEmployeeId and set it to “/searchByEmployeeId/someaction”, If it is for searchBySomethingElse and set it to “/searchBySomethingElse /someaction”. And you can user that variable in jsp page.
 
June Rajkhowa
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

[quote=Anbarasu Aladiyan] If it is for searchByEmployeeId and set it to “/searchByEmployeeId/someaction”, If it is for searchBySomethingElse and set it to “/searchBySomethingElse /someaction”. And you can user that variable in jsp page.[/quote]

The problem is, to create the url I have to detect the event in the JSP page itself and not in the action class (which is the case at present).

<c:forEach items="${pagelist}" var="emp">

<td><a href="searchApplication.do?nameSubmit&page=${emp}">${emp}</a></td>

</c:forEach>

The above code works but I have hard-coded "nameSubmit" in it.
Surely handling multiple search-options in one page is not something radically new. But I am at a loss
 
Anbarasu Aladiyan
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[quote=June Rajkhowa]The problem is, to create the url I have to detect the event in the JSP page itself and not in the action class (which is the case at present).
[/quote]
I am not sure why you can't do that from action class. Since the action is different for different search types, you can do that easily. Without that this is not possible, coz when the request come back from the action, jsp does not knows about the parameters/fields were available in the previous JSPs (Assuming that search page and result page are different).

Or even you can set the EventType/SearchType from the action class, so that make the URL from JSP by depending on the 'EventType/SearchType' set from the action class. (Please note that again you need to do that from your action class)

Please let me know, if i miss something
 
Anbarasu Aladiyan
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And Welcome to JavaRanch
 
June Rajkhowa
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anbarasu Aladiyan wrote:
I am not sure why you can't do that from action class. Since the action is different for different search types, you can do that easily.



why dont you try with the code I have provided with. Maybe you can see where i am going wrong.
 
June Rajkhowa
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anbarasu Aladiyan wrote:And Welcome to JavaRanch



Thanks. But I have been present in this place since 2008. I forgot my userid and password. So had to create a new account
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic