Disable the Back Button in browser

Reuirment-To Disable the Browser Back Button you need to use java script code in your jsp page.

For example, You have Page 1 and Page 2 .And you are navigation from page1 to page 2.now you click on browser bck button.
We need to disable this thing.We will be writing a javascript code into the page 1.We will use forward method.Let check what does it do-

forward()– method loads the next URL in the history list.This is the same as clicking the Forward button in the browser.JavaScript window history forward method provides the functionality to navigate the user to the next page visited by him. Actually history forward method works only if the user navigates to the previous page using back button of browser of history back method provided by JavaScript. This back history navigation enables the forward history navigation. JavaScript History object belongs to JavaScript window object that allows you to access the forward method using window.history.forward. You can also access the forward method directly as history.forward.

<script type ="text/javascript">
function stopGoingBack()
{
window.history.forward();
}
</script>
<html>
    <head>
    <title> Using the forward method of the History object</title>
    </head>
    <body>
    <form name=form1>
    Click on the button to go to the forward browser page.
    <input type="button" value="Go Forward" onload='stopGoingBack()'>
    </form>
    </body>
    </html>

Call this method on onload on the body of page.

Happy coding with techartifact with Vinay . 🙂

Book Review : KnockoutJS Starter

The folks at Packt asked me to review one of their book on KnockOut Js If you are interested in buying it (a judgment you may reserve until after you have read the review)KnockOutJs is on packt site
this is link you can go.

Eric Barnard is a Software Engineer in Champaign-Urbana, Illinois. You can find his blog at http://www.ericbarnard.com

The Packt model is an interesting one. They are an online publishing house who approach subject matter experts and offer them an advance and a good commission for writing a book for them. They have approached me a couple of times but I have turned them down on both occasions simply due to a lack of time. Given the movement towards e-readers and related devices I believe it is a business model most publishers will eventually adopt.
Overview and Structure of the Book

The first thing you will probably notice is the size of the document. This is no brief summary of the new features. This is small book of over 40 pages covering to learn a new java script librart with a full index in the back. The structure of the book is:

Business overview
Step 1 – Defining a namespace
Step 2 – Creating our Model
Step 3 – Creating a View for our Model
Step 4 – Creating a ViewModel to manage our Models
Step 5 – Working with Observable Arrays
Step 6 – Adding and removing Models from an Observable Array
Step 7 – Editing properties of a Model
Step 8 – Setting up a Master-Details view
Step 9 – Applying bindings

• There are some key features as well like MVVM model and other important features of KnockOut JS

I like this structure as it parallels the steps one would take in setting up a KnockOut JS. To add a bit of a flow to the book, they also put it in the examples,real life scenarios.

What is missing is – This book is not covering the detailed code description.Although it have how to install this library.Creating a demo application.How to start creating site, MVVM library.

Its more a starter book.This book focuses on giving the reader a firm understanding of the core concepts of Knockout, such as MVVM and data binding,
and works through real-life app development scenarios. All core components of Knockout’s amazing library are covered in detail, and strategies are outlined for getting the best use of time when developing with Knockout .

Knockout – A JavaScript library
Knockout, at its core, is a simple JavaScript file that can be included in a website or a web application to add JavaScript functionality, and provides the ability to enhance a user’s experience. By default, Knockout does nothing to your website or web application until you specifically write code to utilize it. It is important to understand the difference between Knockout and many other JavaScript “frameworks” or “libraries” as some frameworks actually change how a website or web application works when included.

The difference between this library and other java script library is as below :

Subscribables – It give an edge of catching subscriber and receiver event.A Subscribable is simply an object that has three methods and an array of Subscriptions.

Observables -The Knockout Observable is one of the first objects that leverages the Subscribable functionality, and is one of the most simple, yet powerful pieces of the Knockout library.

Observable Arrays – There are multiple value of observable .

Computed Observables-Computed Observables are arguably the most powerful feature of Knockout. You may have noticed that creating a ViewModel with nothing but Observables and Observable Arrays is a huge step up from plain JavaScript, but it would be really nice to have other properties on your
ViewModel that simply depended upon other Observables and Observable Arrays and updated themselves when their dependencies change.

Utilities -Knockout is full of many useful utilities that you can use in your application development.You can find these by exploring the
ko.utils namespace.One of utility is extend.

Data-bind statements – Knockout was designed to make binding JavaScript objects and HTML extremely easy. The API that is given to us to use is through the HTML5 compliant data-bind statement.

Applying bindings – This is key feature of knockOut JS.Book describer it very well with example.Many examples show the applyBindings function being called with a ViewModel object being passed in as the only argument, but you can also specify a DOM node as the second argument.
When passing a DOM node as the second argument, Knockout only binds your ViewModel to that node and its children.

Conclusions
This book is not a comprehensive guide to the learn knockout JS. Rather, it is It presents a Starter guide to learn and work on KnockOut JS. It descrive MVVM model with detailed description.Worth of reading.

Introduction to JSON (Javascript Object Notation)

What is JSON?
JSON (Javascript Object Notation) is a light weight data interchange format. JSON is a subset of the literal object notation in JavaScript. It can be compared to XML but parsing of JSON is very much easier than XML data. It is a text format of data and is programming language independent. In fact it very much looks like unnamed array.

Example of data in JSON
Shown below is a object declared in JSON format.

var individual = {
     "firstName": "Anky",
     "lastName": "Singh",
     "address": {
                       "streetAddress": "4th Avenue",
                       "city": "Moorpark",
                       "state": "CA",
                       "postalCode": 34523
                    },
     "phoneNumbers": [
                                 "212 555-1234",
                                 "646 555-4567"
                             ]
 };

alert("The name of Individual is " + individual.firstName + " " +  individual.lastName);
alert("The Street Address is " + individual.address.streetAddress);
alert("The Postal code is " + individual.address.postalCode);
alert("First Phone Number  is " + individual.phoneNumbers[0]);
alert("Second Phone Number  is " + individual.phoneNumbers[1]);

<em>Output would be alert windows with following messages</em>:
The name of Individual is Anky Singh
The Street Address is 4th Avenue
The Postal code is 34523
First Phone Number  is 212 555-1234
Second Phone Number  is 646 555-4567

Above code shows how an Individual object is declared using JSON. Alert statements provide an example how the properties of the object can be accessed in the same way as we do in C# or Java.

Being subset of literal notation JSON standard has got stricter rules. See www.json.org or RFC 4627 for a more formal description of the standard.

But all said simplicity of JSON data is the specialty of the standard.

kick it on DotNetKicks.com