Archive

Archive for March, 2009

Adding Tiles in your Struts Project

March 22nd, 2009 kumarasamy No comments
Tiles is a framework for the development user interface. Tiles is enables the developers to develop the web applications by assembling the reusable tiles (jsp, html, etc..). Tiles uses the concept of reuse and enables the developers to define a template for the web site and then use this layout to populate the content of the web site. For example, if you have to develop a web site having more that 500 page of static content and many dynamically generated pages. The layout of the web site often changes according to the business requirement. In this case you can use the Tiles framework to design the template for the web site and use this template to populate the contents. In future if there is any requirement of site layout change then you have to change the layout in one page. This will change the layout of you whole web site
Steps To Create Tiles Application
Tiles is very useful framework for the development of web applications. Here are the steps necessary for adding Tiles to your Struts application:
  1. Add the Tiles Tag Library Descriptor (TLD) file to the web.xml.
  2. Create layout JSPs.
  3. Develop the web pages using layouts.
  4. Repackage, run and test application.
Add the Tiles TLD to web.xml file
Tiles can can be used with or without Struts. Following entry is required in the web.xml file before you can use the tiles tags in your application.
		<jsp-config>
			<taglib>
				<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
				<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
			</taglib>
		</jsp-config>
		
Struts-Config.xml Changes
		<plug-in className="org.apache.struts.tiles.TilesPlugin" >
			<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
			<set-property property="moduleAware" value="true" />
		</plug-in>
		
The above configuration will add Tiles support in your project.My tiles definition as follows in tiles-defs.xml
			<definition name="IT.rootLayout" path="/rootLayout.jsp">
				<put name="topBanner" value="top.html"/>
				<put name="leftMenu" value="leftMenu.html"/>
				<put name="Desktop" value="Desktop.jsp"/>
				<put name="footer" value="footer.html"/>
			</definition>
		
In the above code i have defined a Tile element, IT.rootLayout. The page is rootLayout.jsp and it has four components, Which is topBanner,leftMenu,Desktop,footer.My rootLayout.jsp will look like the following.
		<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
		<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
			<html:html locale="true">
			<head>
				<title>Test Tiles</title>
			</head>
			<body>
			<table width="100%" cellspacing="0" cellpadding="0" border="1">
			<tr>
				<td><tiles:insert attribute="topBanner"/></td>
			</tr>
			<tr>
				<td><tiles:insert attribute="leftMenu"/></td>
			</tr>
			<tr>
				<td>
					<table cellspacing="0" cellpadding="0" border="1" width="100%">
					<tr valign="top">
						<td ><tiles:insert attribute="Desktop" /></td>
					</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td><tiles:insert attribute="footer"/></td>
			</tr>
		</table>
		</body>
		</html:html>
	
To call the tile component IT.rootLayout, i”m going to add the following definition in struts-config.xml
		<action path="/IT.rootLayout" forward="IT.rootLayout"/>
		
We are done!!!! We have added a Tile definition and pages also
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Toad for MySQL 4.1.0.220 Review!!!

March 10th, 2009 kumarasamy 1 comment
Toad Review
About Toad Quest Software’’s Toad for MySQL leverages Quest Software’’s database expertise to empower MySQL developers and administrators, of varying skill levels, to rapidly create and execute queries, automate database object management and develop SQL code more efficiently. Toad for MySQL also provides utilities to compare, extract and search for objects, manage projects, import/export data and administer the database. This database development and administration solution increases your productivity and offers access to a solid community for interactive support.With Toad, you can use a familiar, proven tool to manage MySQL databases that run on Windows. Quest Software has an established track record for providing management solutions that deliver, manage and control the quality of application and database development. You can rely on Quest to provide you with an intuitive, graphical tool with all the features necessary to enable you to take MySQL to the next level
Improved Object Browser in Toad for MySQL
About Toad Improved object browser in Toad now. Which allows the user to create the following
  • Tables
  • Views
  • Indexes
  • Procedures
  • Triggers
  • Functions
  • Users
It allows the user to administer to the following
  • Session Variables
  • Env Vaiables
Working on a Table
Permitted Operations on Table Operations permitted on a Table.
  • Create a new Table
  • Create Like
  • Alter Table
  • Drop Table
  • Create Index
  • Create Trigger
  • Truncate Table
  • Analyze Table
  • Optimize Table
  • Check Table
Designers on a Table
Send To
Query Browser in Toad
Query Browser
ER Diagram in Toad
ER-Diagram
Scheduling Jobs
Job Scheduling
Auto Commit
Auto Commit
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Categories: General, Tools Tags: , , ,

Apache Commons-Email

March 5th, 2009 kumarasamy No comments
Apache Commons has many built-in utils. One of the most used util is Commons-Email. Couple of week back had a situation need to send a mail to the users from my application. So i ended here.
The implementation is very simple. Commons-Email is built on top of the Java Mail API.
Some of the mail classes that are provided are as follows:
  • SimpleEmail-This class is used to send basic text based emails.
  • MultiPartEmail-This class is used to send multipart messages.
  • HtmlEmail-This class is used to send HTML formatted emails.
  • EmailAttachment-This is a simple container class to allow for easy handling of attachments.
The following piece of code will send an mail by using Commons-Email
				package com.techmaddy;

				import org.apache.commons.mail.HtmlEmail;
				public class MailMan {
					public static void main(String[] args) {
						try {
							HtmlEmail email = new HtmlEmail();
							email.setHostName("mysmtp.server.com");
							email.addTo("test@test.com", "KMK");
							email.setFrom("admin@ttext", "Admin");
							email.setSubject("WARNING::Be Aware of this");
							email.setHtmlMsg("<b>Read this from techmaddy.com</b>");
							email.send();
						}
						catch(Exception e) {
							e.printStackTrace();
						}
					}
				}
			
If you SMTP Server needs authentication
email.setAuthentication("username", "password");
For more ref Commons-Email
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Categories: General, Java Tags: , , ,
Get Adobe Flash playerPlugin by wpburn.com wordpress themes