This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 7, 2011, 7:11 PM
10 Posts

Enter key for Edit box - open xpage and save session variable.

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
I have an edit box which is used for searching the site.  This is mapped to a scoped variable within the session scope.  Next to it is an image (of a magnifying glass) with an onclick event assigned to it which opens an xpage called xSearch.
 
The onclick event is a http post request which saves the session variable so on the page load, it can be used as the search term.
 
What I want to do is check for the enter key being pressed in the text box and perform exactly the same event.  Checking for the return key is done on the client side using the onkeypress event handler and checking for keyCode==13.  I could do location.assign('xSearch.xsp') and pass the search term as a parameter in an http get request but it'd be much neater to trigger the same even as that of the image.
 
Has anybody done this?  I see from the page source that theres the following code for the image:
 
 XSP.attachEvent("view:_id1:include1:_id10", "view:_id1:include1:image2", "onclick", null, true, false)
 
How can I trigger this event in client side javascript?
 
Many thanks
 
 
Adam.
Aug 7, 2011, 8:23 PM
272 Posts
Re: Enter key for Edit box - open xpage and save session variable.
Hi Adam,
 
you could try the JS method XSP.fireEvent  as described here.
 
But wouldn't it be easier to open a page and add a parameter to the URL which contains the search value?
F.e. http://www.example.org/db.nsf/search.xsp?query=TERM
 
Then you just have to do a redirect to a specific page, and don't have to use the sessionScope. This would be easier to implement, could be cache, and is just a simple link (that's why I have implemented it this way.)
 
Sven
Aug 9, 2011, 8:35 PM
6 Posts
Re: Enter key for Edit box - open xpage and save session variable.
if you return a true onkeypress thisEvent.keycode == "13" then it should pass it to the server side for processing.  You can then get your sessionScope value and construct the url and use facesContext to redirect to however you like
 
facesContext.getExternalContext().redirect(url);
 
BTW, why do you need to pass the search term? Couldn't you save it in sessionScope and have search.xsp read it directly from sessionScope on the server side?
 

 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal