I need to set a flag in the session hash when a link is clicked (to toggle between basic/advanced views of a page). Is there a way to do this?
I'm thinking I can do it if I add a route for something like "change_mode" and a parameter that it accepts and the method in the controller for it would just set the value in the hash and link back to the previous page, but that feels like a hack...
Thanks.
How is it a hack? That's how you get information from the browser to the server, through a request.
Related
How can i get the URL of the previous page in JavaScript?
I mean the value of this function:
history.back()
or this one :
history.go(-1)
For privacy reasons, you will never be able to do that.
In JavaScript, you use the document.referrer property, which will give you the URL of the page where the user came from.
Can anyone help me how to change the url displayed in the address bar in grails.
Here I have a data table. Once i click on the pagination list displayed at the bottom, lets say 2, then the url changes to
http://localhost:8080/test/account/list?searchText=%25&paginationNumber=10&advancedSearchText=&searchCriteria=&searchOperator=&offset=10&max=10
from
http://localhost:8080/test/account/list
Now I need the same url
http://localhost:8080/test/account/list
even i navigate to different pages.
Whether it is possible to override the url in grails.
It looks like your original page was the result of a form POST, with these additional parameters as fields on the form. When you use <g:paginate> it generates a normal <a> link for each button, which means a GET request, so the params go into the URL.
You might be able to get it to do what you want with a bit of JavaScript, wrapping a POST form around the paginate buttons with hidden fields for the additional data, and attach an event handler to the pagination links to trigger a submit of the form.
Alternatively, store the extra parameters server side in the session instead of passing them back and forth, and accept the offset and max in the URL.
I want to point my Page Tab to a URL with querystring arguments like this:
http://domain.com/page.php?arg=CONSTANT
arg's value is a constant so I'm not trying to pass any dynamic data from the facebook page to my PHP page. It's just supposed to be a constant URL, with a constant querystring parameter.
I'm having problems getting this to work (nothing is shown on the facebook page tab), however when I use an URL without querystring parameters like this:
http://domain.com/page.php
it works right.
I couldn't find any information in the documentation saying that it's impossible to use URLs with querystring arguments. Is it? or am I doing something wrong?
Your answer lives in the something facebook calls app_data in the signed_request specifically made for page tab apps. See http://developers.facebook.com/docs/authentication/signed_request/
Even If the url is same can i go to different action using Html.RouteLink and Action Link.Like when i click on news link i will go to news details.The url of this page is http://localhost:1390/en-US/latestnews/125.Now if i select the ddl of language in the site header in this pagei need to
go to the home page of the site.The ddl (on change) will take the same url but this time it needs to go to action in the sane controller.
The URL will direct to the controller/action on the first routing entry that it matches regardless of how you generate it. I'm not sure exactly what you are trying to accomplish, but I suspect that what you need to do is use javascript to direct to a different url, perhaps generated with Html.RouteLink instead of Html.ActionLink based on the value of the drop down list when it's selected. If I'm misunderstanding what you are trying to do, please clarify.
What the appropriate way to do this?
ViewData["PreviousPage"]=Request.UrlReferrer.PathAndQuery;
this doesnt work if directly accessing.
EDIT: I did a null check on Request.UrlReferrer, seems to be fine (?)
If directly, it's impossible this way. URL referer is set only when clicking a link.
If you're interested only in "Previous Page" link working inside your website, then you can store current URL in session, and retrieve it during next request, then replace with a new current url. Ugly, but working.
Is there some reason this needs to be server-side instead of client-side? If you can deal with client side, Javascript is the answer:
<input type=button value="Back" onClick="history.go(-1)">
This uses the browser's built-in back functionality -- it essentially mimics clicking the "Back" button.
Put this somewhere in your Base Controller or Custom Filter:
TempData["PreviousPage"] = TempData["CurrentPage"];
TempData["CurrentPage"] = Request.Url;