Wednesday, December 22, 2010

MultiLanguage enabled JSPs

Step-1 : Load the jstl and fmt tag libraries in your jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

Step-2 : Check the locale
<c:if test="${param.locale == 'de_DE'}">
   <fmt:setLocale value="de_DE" />
</c:if>

Step-3 : Based on the locale, load appropriate bundle. Here if the locale is de_DE then message_de_DE.properties will be loaded.
<fmt:bundle basename="message">

Step-4 : Externalize(localize) the text in jsp, to the appropriate properties file, below statement will load the text corresponding to "LblHeading" from message_de_DE.properties file.
<fmt:message key="LblHeading"/>

Thursday, October 28, 2010

Hibernate Connection


Connecting to SQL server through Hibernate
Jar required: sqljdbc.jar
Jdbc driver name: com.microsoft.sqlserver.jdbc.SQLServerDriver
Connection string: jdbc: sqlserver://:1433;DatabaseName=

Connecting to AS400 through Hibernate
Jar required: jt400.jar
Jdbc driver name: com.ibm.as400.access.AS400JDBCDriver
Connection string: jdbc:as400:///;transaction isolation=none

Connecting to DB2 through Hibernate
Jar required: db2jcc.jar
Jdbc driver name: com.ibm.db2.jcc.DB2Driver
Connection string: jdbc:db2://:50000/

Sunday, October 17, 2010

Software Engineering - A Recall..


                                    Best Practices of Software Engineering



Best practices are a set of commercially proven approaches to software development which, when used in combination, strike at the root causes of software development problems. They are observed to be commonly used in industry by successful organizations.

The above mentioned best practices are documented in The Rational Unified Process – An Introduction


A model is a complete description of a system from a particular perspective.
 
Diagrams are views of a model.



  •  Use-case diagrams illustrate user interactions with the system.
  •  Class digrams illustrate logical structure.
  •  Object diagrams illustrate objects and links.
  •  State diagrams illustrate behavior
  •  Component diagrams illustrate physical structure of the software.
  •  Deployment diagrams show the mapping of software to hardware configurations
  •  Interaction diagrams ( i.e. collaboratoin and sequence diagrams) illustrate behavior
  •  Activity diagrams illustrate the flow of events in a use-case.


An architectural view is a simplified description of a system from a particular perspective or vantage point, covering particular concerns and omitting entities that are not relevant to this perspective.



                  Representing Architecture: The 4+1 View Model

Logical View – addresses the functional requirements of the system.

Implementation view
– describes the organization of static software modules in the development environment, in terms of packaging, layering and configuration management.

Process view – addresses the concurrent aspect of the system at sun-time: tasks, threads or processes, and their interactions. 

Deployment view – shows how the various executables and other run-time components are mapped onto the underlying platforms or computing nodes.


                                         Analysis Versus Design

Analysis, focus is on understanding the problem

Design, focus is on understanding the solution


Monday, September 27, 2010

Configuring TestNG in Eclipse



Installing TestNG


Installing Eclipse Plugin for TestNG

1.       Download the TestNG eclipse plugin from (http://beust.com/eclipse/)
2.       Copy the downloaded jar file into following directory structure



3.       Create the “TestNG.link” file in ‘links’ folder of Eclipse installation
4.       Edit the file to provide the path of plugin
path=C:/Eclipse - Helios/eclipse-jee-helios-win32/eclipse/ExternalPlugins/TestNG
5.       Restart the Eclipse.




Verifying Installation

1.       Open Windows -> Show Views -> Others  to see if TestNG is listed as follows

Testing ( A simple Example )


1.       Create a TestNG class. 




2.       Specify the following details.  For more details on the annotations visit the TestNG site. They are pretty much same as Junit annotations.

3.       You also need to add the ‘testng.jar’ file so that the annotations can be recognized. In order to add this to your projects classpath. Select ‘Configure Build Path -> Add Variable -> Select the TESTNG_HOME -> Extend Variable to include testng.jar’




4.       Following generated Class should now be compiled

5.       Creating a ‘Launch Configuration’

6.       In the launch configuration select the TestNG class













7.       Select ‘Run’ from the launch configuration. You should see following in the “TestNG” dialog

8.       Above steps tested a method “f()” . The test was successful because there was no error or exceptions encountered in the method “f()” .
9.       Now intentionally modify the method to throw a new RuntimeException.
10.   Run the same Launch Configuration, and see the test results as below


Sunday, August 22, 2010

Validating XML against schema - Visual Studio 2008

This section assumes that schema, is present in local system.
For validating XML through schema, you have to specify below two attributes in root element of XML document.

1. Using absolute path
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.example.com/ file://C:/schema/test/SampleOne.xsd'

2. Using relative path
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.example.com/ ./SampleOne.xsd'

Suggested Reading
http://www.wrox.com/WileyCDA/Section/Editing-XML-and-XML-Schema-in-Visual-Studio-2008.id-320326.html