Friday, February 23, 2018

Solution : Eclipse Maven projects default JRE System Library [J2SE-1.5] change to different version

2:45 PM 0
Solution : Eclipse Maven projects default JRE System Library [J2SE-1.5] change to different version
When Icreate a new maven project and then click maven update my java version always change to java version 1.5. to resolve this problem must add below configuration in pom.xml file.


<build>
     <plugins>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                   <source>1.7</source>
                   <target>1.7</target>
                </configuration>
        </plugin>
    </plugins>
</build>

Building JAVA/J2EE projects with Apache Maven

2:36 PM 0
Building JAVA/J2EE projects with Apache Maven
Apache Maven is a software project management and comprehension tool. Maven is a build automation tool used primarily for Java projects. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Thursday, December 7, 2017

Fancytree plugiin for JQuery UI dynamic tree view

7:44 PM 0
Fancytree is a JavaScript dynamic tree view plugin for jQuery UI with support for persistence, keyboard, checkboxes, tables, drag'n'drop, and lazy loading. jQuery Fancy Tree is the designated successor of DynaTree plugin.
    Main features

    1. Optimized for large dynamic trees (DOM elements are only created when really needed).
    2. Programmable through a rich object oriented interface.
    3. Support for lazy loading and Ajax.
    4. Checkboxes and hierarchical selection.
    5. Supports drag and drop.
    6. Support for persistence.
    7. Keyboard aware.
    8. Initializes from HTML code, JSON, or JavaScript objects.



    Sunday, November 26, 2017

    Java String comparison best practice

    8:19 PM 0
    Java String comparison best practice
    "==" tests for reference equality (whether they are the same object).
    ".equals()" tests for value equality (whether they are logically "equal").
    Objects.equals() checks for nulls before calling .equals() so you don't have to check null

    Consequently, if you want to test whether two strings have the same value you will probably want to use Objects.equals().
    // These two have the same value
    new String("test").equals("test") // --> true

    // ... but they are not the same object
    new String("test") == "test" // --> false

    // ... neither are these
    new String("test") == new String("test") // --> false

    // ... but these are because literals are interned by
    // the compiler and thus refer to the same object
    "test" == "test" // --> true

    // ... but you should really just call Objects.equals()
    Objects.equals("test", new String("test")) // --> true
    Objects.equals(null, "test") // --> false
    https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java

    Monday, September 11, 2017

    What is Struts 2 and how it works

    1:30 AM 0
    Image credits: struts.apache.org


     Apache Struts framework is a free, open-source, MVC framework for creating elegant, modern Java web applications. It favors convention over configuration, is extensible using a plugin architecture, and ships with plugins to support REST, AJAX and JSON.

    Apache Struts2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts2. This new version of Struts is simpler to use and closer to how Struts was always meant to be.
    Struts 2 = Webwork + Struts 1 

    Some of the framework's best features

    Core
    • Pluggable framework architecture that allows request lifecycles to be customized for each action.
    • Flexible validation framework that allows validation rules to be decoupled from action code.
    • Hierarchical approach to internationalization that simplifies localizing applications.
    • Automatic type conversion that transparently maps values from HTTP to native Java data objects, solving one of the most tedious efforts when creating web applications.
    • Integrated dependency injection engine that manages component lifecycle and dependencies.
    • Modular configuration files that use packages and namespaces to simplify managing large projects with hundreds of actions.
    • Java 5 annotations that reduce configuration overhead. (Java 1.4 is the minimum platform.)

    View
    • Reusable user interface tags that allow for easy component-oriented development using themes and templates. Bundled tags ranges from simple text fields to advanced tags like date pickers and tree views.
    • JSTL-compatible expression language (OGNL) that exposes properties on multiple objects as if they were a single JavaBean.
    • Pluggable Result Types that support multiple view technologies, including JSP, FreeMarker, Velocity, PDF, and JasperReports.
    • Optional AJAX theme that simplifes creating interactive web applications.
    • Optional Interceptor plugins that can execute long-running queries in the background, prevent multiple form submissions, or handle custom security schemes.

    Other
    • Easy integration with other popular products, including Hibernate, Spring, SiteMesh, and JSTL.
    • Distributed under the business-friendly Apache License 2.0.


    Architecture and Request Processing Lifecycle
    Struts 2 Architecture is based on WebWork 2 framework. It leverages the standard JEE technologies such as Java Filters, JavaBeans, ResourceBundles, Locales, XML etc in its architecture.

    Image credits: struts.apache.org

    1. The normal lifecycle of struts begins when the request is sent from client. This results invoke the servlet container which in turn is passed through standard filter chain.
    2. The FilterDispatcher filter is called which consults the ActionMapper to determine whether an Action should be invoked.
    3. If ActionMapper finds an Action to be invoked, the FilterDispatcher delegates control to ActionProxy.
    4. ActionProxy reads the configuration file such as struts.xml. ActionProxy creates an instance of ActionInvocation class and delegates the control.
    5. ActionInvocation is responsible for command pattern implementation. It invokes the Interceptors one by one (if required) and then invoke the Action.
    6. Once the Action returns, the ActionInvocation is responsible for looking up the proper result associated with the Action result code mapped in struts.xml.
    7. The Interceptors are executed again in reverse order and the response is returned to the Filter (In most cases to FilterDispatcher). And the result is then sent to the servlet container which in turns send it back to client.

    https://struts.apache.org