Back button to execute previous function - java

I have got a webpage with a few functions on it to load different content dynamically into the content section. What I want to achieve is by pressing back button to execute last/previous function. At the moment it goes to the previous page. Is it possible to do without hash tags in the URL bar as well? Seems like create a history of function list. Thanks

I suggest you to use the session.
Note that there is a plugin named JQuery session plugin, available from here
Tutorials links :
Lassosoft
weschools

Related

How to get a web page source code with GeckoView

I am an android developer and I knew about GeckoView recently.
I can get source code of a web page by android WebView (java code).
However with my new website, android Webview can't load the webpage but GeckoView can.
Now I want to get source code of a web page by GeckoView.
Is there any body know the solution to resolve this problem ?
Thank in advance
As far as I know, you cannot use GeckoView to get the source code, but the geckoview library does have GeckoWebExecutor. Take a look at the fetch method and the WebResponse it returns.
By converting the WebResponse.body InputStream to a String you can get the source code.
One option for doing this could follow these steps:
detect which page my geckoview loaded;
save the loaded url into a sharedpref;
if user wants to see the source of the page, load the url saved within that sharedpref.
So...
(1-2) as you already know, geckoview doesn't have that handy shouldOverrideUrlLoading() method, so you will have to deal with the NavigationDelegate class, which has the onLocationChange(), where i put this line, which does nothing more than save the current url as a string into a sharedpref string named "geckoViewUrl":
sharedprefs.edit().putString("geckoViewUrl", url).apply();
having all setup before (sharedprefs etc). Detected the loaded page and saved the url into a sharedpref, let's go to the final step 3.
(3) for my use, wishing only to allow the user to see (and copy) the source, for the law of the minimum effort i used another activity with a plain and old webview to display it. This is very easy to implement and rises no confusion to the user. He/She wants to see the code, i show it in another activity. When it's done, he/she closes the new activity and life continues.
So, user wants source? Load another activity with a webview and make it load that saved sharedpref string:
addr2open = pref_out.getString("geckoViewUrl", "");
Doing this (for example), you get the url user wants to see source assigned to a string var. To finish, all you have to do is to make the webview load this string preceded by the precious word view-source:, this way:
webView.loadUrl("view-source:" + addr2open);
That's it. Of course you could implement a solution relying on the same activity, or using geckoView, showing multiple options, menus etc. I only wanted to show you a way to solve your problem in a nice 'n' easy way. You asked for "How to get a web page source code with GeckoView". Here is the answer. Works perfectly. If this is good for you, please, accept this as the correct answer. Thank you. Happy coding.
One example on the use of "view-source", from the creators of GeckoView: https://firefox-source-docs.mozilla.org/devtools-user/view_source/index.html (see item "Link to a line number").

Magento Shopgram Checkout Page

Now I have read over dozen threads and even a dozen different web pages which have asked the similar question. However the responses did not work for me. I tried all of them. Also to note I could not comment on the questions hence the reason for this thread. To be as detailed as possible FROM what i can tell in the magento checkout is something to do with SHOPGRAM? It is my current checkout cart. I have two custom attributes called license_period and another called number_of_devices.
I need to add the two fields within the checkout cart. One thing to note is that is out of the testing i have done it seems the file cart_new.phtml located # /app/design/frontend/shopgram/default/template/checkout controls the layout. this script i have tried editting I have tried alot however any change i make does not even appear. Even when i edit the default.phtml #/app/design/frontend/shopgram/default/template/checkout/cart/item It does not make any changes i have even deleted most of the files in these directorys and it causes no change to the content. Only the cart_new.phtml controls the content.
Now i do not know magento too well so i might be mistaken. However when i did try a lot of different queries and most of them do nothing. some of them cause the table to disapear.
The following are just a 2 out of the 100 links I have tried. However I can only post two links.
Display Magento Custom Option Values in Shoping Cart
https://magento.stackexchange.com/questions/5057/magento-checkout-getting-custom-attribute-value
Posting this script Here incase anyone needs to know how to add custom attributes into your shopping cart.
/**
** This will load the product attributes. Now you can create a plugin to do this which will
**help with performance however in my case the plugin was not working correctly.
**/
<?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()) ?>
/**
**Use javascript to add the attribute into the correct location in the shopping cart.
**
**/
<script>
var elements = document.getElementsByClassName('item-options'), last = elements.length - 1;
elements[last].innerHTML = "<dt>Odkaz </dt><dd>Instalační soubor</dd> <dt>No Of Devices:</dt> <dd><?php echo $_product->getResource()->getAttribute('number_of_devices')->getFrontend()->getValue($_product); ?></dd> <dt>License Period:</dt> <dd><?php echo $_product->getResource()->getAttribute('licence_period')->getFrontend()->getValue($_product); ?></dd> ";
</script>
PS
You will find This script was placed in the cart_new.php which is located #app/design/frontend/shopgram/default/template/checkout.
Another piece of advice is that if you place this code anywhere in the script it will not work. So do not get fustrated if it does not work. It has to go somewhere where it will not block the other scripts from working. I placed mine within the the actual for each items as items loop where it draws the data for the shopping cart.

Where to code when leave a jsp

I am using spring mvc and storing some data in session. I want to delete those data when the user leave that menu and moved to next menu. I don't know where to code for it.
Also if the user is clicking other menu and if that page have any unsaved data, I want to get confirmation from the user.
Is jspDestroy() will help me for this.
Please help me.
As from the various comments above your problem is little bit clear, you want to perform some action when user is leaving the current page.
You can use unload event
window.onunload = function(){
//give ajax call here and remove whatever you want to remove from session
}
unload event
A user agent must dispatch this event when the DOM Implementation removes from the environment the resource (such as the document) or any dependent resources (such as images, style sheets, scripts). The document must be unloaded after the dispatch of this event type.
From the comments you want to remove some particular objects not all so you can use session.removeAttribute()
For removing all sessions use session.invalidate()

How to dectect modification on page? Which Listener in java?

Is there any Listener in Java, which can detect, if the content of the page has been changed? "changed" means text in the page has been added/removed...
Process: Author modifys the page and activate it. In publish Instance it must be checked if the page content has been modified/changed
I don't think there is such listener. You're gonna have to reload/access the page or you can hook it up so when the author submits his changes you insert a value to the database that this specific page has been modified. After that you just read the data from the DB using a timer that triggers every now and then and if new line appears you do your action.
This is more of a design question and you should think about what project you're working on and what's the best approach to implement this feature.
Apache sling can handle events. There is nice tutorial here http://sling.apache.org/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html .
Basically create a listener ad check if the event relates to a page node (or its subnode). Then apply whatever logic you want.
Be careful to check whether you are in an author or publish instance ( or turn off the service in author)

how to let servlet know which link has been accessed

I have a code here that opens a new window when i click the hyperlink.
Chapter 1<br/>
Chapter 2<br/>
How can we return a value to the servlet so that it knows which link has been accessed??
Ive made the pages for the two links i've made here. But i need the servlet to know which page has been accessed. Inside the servlet a function is calling a jexcel app. The return value is different for both pages. That is why i need a UNIQUE return value for each link.
The link visited state is stored in the browser, it is not a really good idea to rely on that! It will be gone after a cache clear for instance. You should maintain a DB of user activity, if you need this info on a user level.

Categories

Resources