smartgwt browser history - smartgwt

is there a way in smartgwt to go back in history?
E.g. I have an page with a button which does a Ajax page change of the current page to another. And on this new page there should be a button to return back to the previous page?
Can this be done with smartGWT? or do I have to make a new Ajax call to switch back to the previous page?

The functionality you want is provided by History class. Need to declare in web.xml and then use History.fireItem("SomeURL"), this will appear in app url as the string after # in URL is History ID ( something like http://google.com#SomeURL), you can use arbitrary IDs.
Use History.registerCallback() to register a function that opens requested History ID (eg. tab name/ID) on URL change (History's ValueChange function) and use History.addHistoryEntry() to update the page URL when other tab is selected.
If you implement this History class then you can use the browser's forward and back icon for the same purpose.

Related

How do I open the previous active tab when returning from a new html page

How do I return back to the previous active tab if I am moving back from another html page?
I am having 5 tabs and within content of each tab there are links to another set of html pages. For example I am having a page called 'school.html' and it has 5 tabs. In tab 2 content (it shows individual student details) I am having a link to "Add new student" to a new page named addNewStudent.html.
After adding a new student in addNewStudent.html, I need to automatically comeback to original page with tabs (window.location = 'school.html'). So how to make tab 2 active showing the tab 2 content (student details).
This can be done in two ways depends upon your usage..
1)if you use browser back in addNewStudent.html to go to school.html.Better to use cookie concept.
For ex: when going to addNewStudent.html from school.html setcookie("tabchange","tab2")
when coming back from addNewStudent.html to school.html(onload of school.html check whether the cookie exist or not,if exists depends upon cookie enable your tab);
2) if you use any button or link in addNewStudent.html to go to school.html.Better to use queryparams.
for ex: pass tabchange queryparam for school.html to addNewStudent.html?tabchange=tab1
get that queryparam from addNewStudent.html and assign to link or button your as href="/school.html?tabchange=tab1"
after clicking that button onload of school.html get the queryparam and enable the tab..

Change the url of a pagination in grails

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.

JQuery Mobile & passing variables in links via the querystring - but the querystring doesn't refresh

I am doing a PhoneGap app with JQuery Mobile and I have two pages, one that has a dynamic list of pages and one that has a form to either edit or create a page. These are in a single html file.
Tapping on a list item passes ?action=edit and tapping the "Add" button I have, passes ?action=add querystrings.
Here is a jsfiddle to visualize the pages
NOTE: The example doesn't act quite the same as the live code.
I am running my app on an Android phone and if I do these actions, the correct querysting is observed in the alert box: -
Click the add button on list page
Click back on the form page
Click the an edit list item link on list page
However, if I do it the other why around (click edit first, then the add button) clicking the add button never shows the add querystring in the alert box
(the jsfiddle example always locks the first clicked link's querystring, which is even worse than the live code!)
The problem here is that you're using a multiple template to do this. If you were using this as separate pages, this would work as normal. As a multiple app, the best way to handle this would be to make a link trigger the setting of some global variable that keeps track of the current state of the app.
Make the edit links like this
Page 15
Then make the script something like this:
var editingId = 0
function editPage(id){
editingId = id;
$.mobile.changePage("#editingPage");
});
$("div#editingPage").live("pageshow", function(){
loadDataForPage(editingId);
});

How can one change the url for a jquery ui tab added via 'add' and 'tabTemplate' functionality?

I might be making this more difficult than I need to but I am in some need of assistance. I have some jquery ui tabs which are added via the add functionality. these tabs are via ajax.
I have a tabTemplate set as follows on the initial addition of the tabs.
tabTemplate: "<li><a href='#{href}'>#{label},/a><li>"
And the add tab functionality is done via
$tabs.tabs('add', 'http://thanksforyourhelp/greatly/appreciated/, some_title_var)
If a form is submitted on that tab, data is written to the database. The response gives an ID of the row added to the database.
Next time that specific tab is visited the link should actually be 'http://thanksforyourhelp/greatly/appreciated/ID' where the ID is now known since the response from the form (ajax here as well) sent it back. This will pre-populate the forms on the page based off the data in the database for "ID."
I've looked at the example here, but my href is an id for the tab in question (and not a url). Where is the actual url stored?
The tab looks like this.
new
I have tried changing the href on that, but upon clicking the tab the content is loaded without ajax instead of within the tab as desired. What might I be doing wrong here? Thanks for your help.
Edit: removed edits with references of no longer existent urls.
I haven't worked with AJAX-powered tabs too much, but I think you want the url method:
$("#tabs").tabs("url", index, url)
Change the url from which an Ajax
(remote) tab will be loaded. The
specified URL will be used for
subsequent loads. Note that you can
not only change the URL for an
existing remote tab with this method,
but also turn an in-page tab into a
remote tab.
Above answer will not work in JQuery 1.9+ as describer here. To work with jquery ui tabs 1.9+ you have to do something like this
var tabs = $("#tabs");
var tab = $(tabs.data('uiTabs').tabs[TAB_INDEX]);
tab.find('.ui-tabs-anchor').attr('href', "NEW_URL");
// If cached initially. Remove cache then
tab.data( "loaded", false);
tabs.tabs( "option", "active", TAB_INDEX);
tabs.tabs("load", TAB_INDEX);
This will change the URL of tab at particular index and load that tab.

GWT History Problem

when i am adding a new history item like this
History.newItem("Register");
the url correcly changes to
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#Register
and loads the register form
but then the url automatically rechanges to
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#
why??
because I want to remain as
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#Register
so that user can reload
The problem is that I was using an hyperlink for acting like a click handler. with a hyperlink, event if u place an empty string, it gonna change the url.
e.g. if the current URL is something like http:...//#This and a hyperlink has an empty target history token then, the url is to change to http:...//#.
The solution i used that worked for me is that because i does not want to use a button, i make use of label and adding some css to it to make it look like a hyperlink
for e.g.
Label Register= new Label("register");
Label.setStyleName("FalseHyperlink");
then in the css
.FalseHyperlink
{
color:blue;
}
.FalseHyperlink:hover
{
text-decortion:underline;
}
Here this solution worked for me because i was not interested in other hyperlink services such as visited or others
Check if any empty string added to History after page rendered or correct history token added to history? URL is changed when a string added to History.

Resources