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 9, 2011, 10:12 PM
8 Posts
topic has been resolvedResolved

remove url parameter from the address

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: url parameter
  • Replies: 6
I have got an XPage that I call with an Url parameter i.e. http://myServer.eu/path/dbname.nsf/page.xsp?param1=999. Based on the the param1 I set some requestScope variables in the beforeRenderResponse, then the XPage displays the result for a SQLQuery and it also displays a form to modify amongst others the requestScope variable that was set using the param1. When I modify the parameter on the form and press a button to display new query results I get the result which is still based on the param1 value rather than on the new value entered. Apparently it is because the XPage is getting the original  url which is still http://myServer.eu/path/dbname.nsf/page.xsp?param1=999.
 
What I need is to get rid off the param1 on subsequent postings of the form via a form button so that it no longer presets the requestScope variable in the beforeRenderResponse. Is that possible somehow? 
Mar 10, 2011, 11:58 AM
149 Posts
Re: remove url parameter from the address
 
Not sure I got the whole picture.
Are you using partial refresh? in that case this is why url is not updating, Would it help to post the new request as a full refresh?
 
 
Thomas
Mar 10, 2011, 1:14 PM
8 Posts
Re: remove url parameter from the address
No I am not using partial updates. The button action is set to full update and it runs one line of server-side javascript that sets one of the requestScope variables to true.
 
The XPage is a form with fields bound to requestscope variables and a button. The buttons sets a requestScope variable to true and search results from SQL database are displayed. To facilitate a search from live text action and from excel I wanted to employ urlParameters. This works fine, but subsequent searches still use the value from the urlParameter rather than the values entered into the form.
 
Mar 10, 2011, 4:21 PM
41 Posts
Re: remove url parameter from the address
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