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



Mar 10, 2011, 4:21 PM
41 Posts

Re: remove url parameter from the address

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: url parameter
  • Replies: 6
I would suggest using the viewScope instead. This might seem backward, since you're trying to remove the filter value... except you're not really trying to remove it, you're trying to update it.
 
The viewScope survives across events on the same instance of a page. So I would recommend adjusting your beforeRenderResponse to something akin to the following: 
 
if (!viewScope.containsKey("searchCriteria")) { 
  viewScope.put("searchCriteria", param.get("param1"));
}
 
Then your button can just update the viewScope directly... whereas a new requestScope is created each time, so every time it's looking at the URL. 
Mar 10, 2011, 5:16 PM
8 Posts
Re: remove url parameter from the address
Thank you for the tip. It was the conditions. I first tested for the existance of the urlParameter, whereas you test first for the existance of the scoped variable. That is the trick. It also works with a requestScope.
 
It has one deficiency though and that is that the browser URL stays the same http://myServer.eu/path/dbname.nsf/page.xsp?param1=999 regardless of the actual search, which is somewhat confusing. Is there some way to clear the parameter from URL?
Mar 10, 2011, 5:28 PM
64 Posts
Re: remove url parameter from the address
- The only way I know to do this is to compute the new URL and reload the page completely using context.redirecToPage().  Then the address bar in the browser will reflect what's actually in force.  XPage actions on the same page, even full refreshes, tend not to update the URL for any reason, making it essentially impossible for a bookmarks to work correctly out of the box.
 
Hope this helps...
Mar 12, 2011, 12:20 PM
8 Posts
Re: remove url parameter from the address
In the end I used context.redirectToPage(). This performs the search and leaves the URL clear of any parameters. The disadvantage is that the initial search is not bookmarkable. One could probably get around that by coding the redirect to occur on the next click of the search button rather than immediately. But in my particular case that would mean adding some transfer of many requestScope variables to sessionScope ones and the back on the load of the page, which I did not do. 
 
This is the code I used. 

if((context.getUrlParameter("par1")!="")) {

sessionScope.put("par1",parseFloat(context.getUrlParameter("par1")));

sessionScope.put("renderResults", true);

sessionScope.put("urlRedirect", true);

context.redirectToPage("XPage.xsp",true);

} else {

if(sessionScope.urlRedirect) {

requestScope.par1e=sessionScope.par1;

requestScope.renderResults=sessionScope.renderResults;

sessionScope.remove("par1");

sessionScope.remove("renderResults");

sessionScope.remove("urlRedirect");

}

}

 

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