Tuesday, September 14, 2010

Which Collection Should be used when?

* Use Vector if there are multiple threads and ArrayList if there is only a single thread.

* Use Hashtable if there are multiple threads and HashMap if there is only a single thread.

* Use StringBuffer if there are multiple threads and StringBuilder if there is only a single thread.

For explanation visit Skeleton Coder

Sunday, September 12, 2010

Html Host Page In GWT

For every GWT application, a html hosted page is required. This hosted page starts the GWT application. This hosted html page can be generated from Servlet or JSP.

Sunday, September 5, 2010

Creating more than one folder as client in GWT

The package does not necessarily have to be called “client,” and in fact, you can specify multiple packages to be considered for JavaScript by modifying your <module> by adding an extra <source path=""> tag. The client package is simply an implicit default value to help you out. See the full definition of modules here: http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.html#Modules.
In GWT, package structure is divided in three folders: client, public, and server. Everything in client folder is converted to javascript. public folder contains resources like css and images while server folder contains services.
Moreover, all domain objects are placed in client folder as POJOs.

Saturday, August 28, 2010

Static Imports

We use "imports" in java so that in order to refer classes we don't have to use fully qualified name. Similar, static imports are used so that we don't have to use classname to call a static method. e.g. java.lang.String class contains a lot of static methods, so you can import this class statically and later on in the code just use method name to use it without mentioning "String" class name. Static imports are usually used when you are using a class's static methods repeatedly.

Wednesday, August 18, 2010

In order get application's context path in JSF, do the following:
FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();

Friday, August 6, 2010

Programmatically Setting Filter for ADF Table

You can set the criteria programmatically to filter data in ADF table by:

DCBindingContainer bc =
(DCBindingContainer)context.getApplication().evaluateExpressionGet(facesContext,
"#{bindings}",
DCBindingContainer.class);
if (bc != null){
DCIteratorBinding ib = (DCIteratorBinding)bc.getIterBindings().get(p_binding);
if (ib != null)
ViewObject vo = ib.getViewObject();
if (vo != null)
vo.setWhereClause('your clause');
}