However the problem comes when I tested it on the IE7 and Netscape 7.0 and Netscape 7.1. IE7 gives me a prompt which is asking whether to close the window or not. The script is not at all functioning in the Netscape browser.
After a lot of research I came to know that the problem is that we are closing the window using the script which was not opened by the script. So I made changes to the code which opens some new file in the same window using the javascript.
The new file contains the window.close() method in its onload() method of BODY tag.So the code looks like this..
function closeWindow(){
var agt=navigator.userAgent.toLowerCase();
var pos = agt.indexOf('msie');
version = navigator.userAgent.substring(pos + 5).substring(0, 1);
if((agt.indexOf("msie") != -1) && (version 7)
top.opener=top;top.close();
}else{
window.top.open("w2Close.html","_self");
}
}
This will works fine for the Internet Explorer v6 and above and Netscape v7 and above. The idea here is the browsers IE7 and Netscape support tabbed browsing so we cannot close them using window.close(). So we close the browser by opening a new file in the same window using script.
The two types of methods that can be written in a JSF managed bean class are:
- Standard methods
- JSF specific methods
Standard Methods
These are simple getter and setter methods of the properties that are available with the bean. Generally we do not allow the client to access the properties directly by name, instead provide the intermediatery methods to access or set the values of the properties.The access modifier of these methods should be public so that they can be accessible anywhere. The name of the getter method normally starts with "get" and appended with the name of the variable with first letter of the variable in capital letter.
private String name;Similarly, the setter method starts with the "set" and follows the same conventions as above. The setter methods will not return a value and are void type methods as they do not require any value to be returned.
public String getName(){
return this.name;
}
JSF Specific Methods
There are four different types of JSF specific methods that can be found in the managed beans.- Action Listener Methods
- Value Change Event Listener Methods
- Navigation Handler Methods
- Validation Methods
Action Listener Methods
These are the methods we write to handle the specific events that can be triggered by invoking the actions on the JSF components like Submit buttons, Command Links etc. When an action event handler is associated with such component and the action is triggered by the user, the corresponding method in the managed bean will automatically gets executed by the Faces Controller before the actual action is performed.Say for example, your application wanted to invoke a business method which require the prior information to process, the action event handled will be useful in making that information available before the actual business methods starts execution.
To be able to qualify a method in managed bean as an action event handler method, it needs to have javax.faces.event.ActionEvent object passed as a parameter to the method and the return type should be void.
public void myActionListener(ActionEvent e){
....
}
Now you can register this event with a component in a JSF page by using the actionListener property of the component.
<h:commandButton
action="#{MyBean.myAction}"
actionListener="#{MyBean.myActionListener}" ....>
Value Change Listener Methods
Value change event listener methods are used associate the UIInput components which accepts the user input for its value such as text boxes, check boxes etc. When the value of these components changed, the registered value change listeners on these components will automatically gets executed when the form on page gets submitted.
These are very useful in situations like examining the new data entered by the user before our business logic acts on that data. You can manipulate the old data and new data before the data gets applied on to the business model.
Similar to the action listener, the value change listener method of backing bean should have defined a parameter called ValueChangeEvent and return void.
public void myValueChangeListener(ValueChangeEvent e){The event can be registered on a JSF input component by using the valueChangeListener parameter of the component.
....
}
<h:inputText valueChangeListener="#{MyBean.myValueChangeListener}" ...>
Navigation Handler Methods
Navigation Handler, also called as Action Handler, used to handle the user actions/requests. These methods accepts no parameters and returns String. The return value should be one of the navigation rule name that will render the associated view. If the return value is null or empty then the same page will be rendered.These methods generally used as a handler methods to accept the user request and invoke the actual business logic. However these can contain the actual business logic as well.
The Navigation Handler methods can be referenced in a JSF page using the Unified Expression Language in a action parameter of the component.
<h:commandButton action="#{MyBean.myAction}" ...>
Validation methods
Validation methods are used to register a user defined validation criteria on a JSF UIInput component value. The validation method must accept FacesContext, UIInput and Object objects as parameters. The Object parameter is the value that gets validated and to be typecasted in order to validate it.public void validateEmail(FacesContext context,The setValid method on the UIInput component can be used to set the validation failed flag so that the same page will render back with the error messages set if any.
UIInput component, Object value){
....
if(failed){
( ( UIInput ) component ).setValid( false );
}
}
GWT uses the javascript for creating the user interfaces. It has overcomed the browser dependancies efficiently. So your pages generated with GWT are simple HTML/DHTML pages and they can run on any browser.
One more advantage is that these pages will load very quickly as they are simple HTML pages.
To download the Google Web Toolkit follow the link below. The size of the download is about 22MB only..
http://code.google.com/webtoolkit/download.html
<iframe style="DISPLAY: none" src="/" name="iframe1"></iframe>;
<a href="http://www.yoursite.com/..." target="iframe1">Download</a>
Now in this puzzle, we have to print as shown below:
"I am developer 1
You are developer 2"
Below are the conditions:
1. We have to use the code that we modified in the puzzle Java Puzzle of The Month - February 2009.
2. No changes should be made to any of Programmers, Developer1, Developer 2 classes.
2. As usual, the minimal changes should be made to the code.