Hi,
Last time i wrote about Project Management System(PMS). URL for PMS is
http://pms.iitk.ernet.in/
Thanks!!
Deepak
Tuesday, March 30, 2010
Friday, March 19, 2010
Add Graphs by Using JFree Chart
Recently i want to add graphs in PMS application. There are too many ways to do this.One of them is JFree Chart.Steps for this are following..
Step1: Download Demo Application of JfreeChart demo and get library jar.
Step2: Add following lines in your code and import files which is required.
JFreeChart chart = ChartFactory.createPieChart("Pie Chart created by Deepak Pandey", pieDataset, true, true,true);
BufferedImage bi = chart.createBufferedImage(500, 500);
chart.setBackgroundPaint(new Color(173, 230, 163));
BufferedImage buf = chart.createBufferedImage(500, 500, null);
try {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
param.setQuality(0.75f, true);
encoder.encode(buf, param);
} catch (Exception e) {
System.out.println("Exception in JSP"+e);
}
Step3: Run you application
You can create this chart on a frame.
Create JFrame Object. and then add JFreeChart object and make this JFrame Object visible.
More Information of this JFreeChart,access following link
http://www.jfree.org
Thanks!!!
Step1: Download Demo Application of JfreeChart demo and get library jar.
Step2: Add following lines in your code and import files which is required.
JFreeChart chart = ChartFactory.createPieChart("Pie Chart created by Deepak Pandey", pieDataset, true, true,true);
BufferedImage bi = chart.createBufferedImage(500, 500);
chart.setBackgroundPaint(new Color(173, 230, 163));
BufferedImage buf = chart.createBufferedImage(500, 500, null);
try {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
param.setQuality(0.75f, true);
encoder.encode(buf, param);
} catch (Exception e) {
System.out.println("Exception in JSP"+e);
}
Step3: Run you application
You can create this chart on a frame.
Create JFrame Object. and then add JFreeChart object and make this JFrame Object visible.
More Information of this JFreeChart,access following link
http://www.jfree.org
Thanks!!!
Tuesday, March 2, 2010
Custom tag
1)Create a class which extends BodyTagSupport or implements Tag
package deep;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class Deepak extends BodyTagSupport {
BodyContent bodyContent;
public int doStartTag() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public void setBodyContent(BodyContent
bodyContent) {
this.bodyContent = bodyContent;
}
public int doAfterBody() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}
//If It returns SKIP_PAGE,then code after the tag will not be executed ,in case of EVAL_PAGE it willbe calculated
2)Create tld(For ex:deep.tld)

3)Edit your web.xml


4)Add line in your JSP page
<%@ taglib uri="/WEB-INF/tag/name.tld" prefix="n" %>
and use tag which you defined earlier
5)Run your application
These are the steps which involved in making custom tag.Any suggestion or correction,plz leave comment.
Thanks
Deepak
package deep;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class Deepak extends BodyTagSupport {
BodyContent bodyContent;
public int doStartTag() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public void setBodyContent(BodyContent
bodyContent) {
this.bodyContent = bodyContent;
}
public int doAfterBody() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}
//If It returns SKIP_PAGE,then code after the tag will not be executed ,in case of EVAL_PAGE it willbe calculated
2)Create tld(For ex:deep.tld)
3)Edit your web.xml
4)Add line in your JSP page
<%@ taglib uri="/WEB-INF/tag/name.tld" prefix="n" %>and use tag which you defined earlier
5)Run your application
These are the steps which involved in making custom tag.Any suggestion or correction,plz leave comment.
Thanks
Deepak
Sunday, February 7, 2010
Project Management System
This system(PMS) can be used to manage projects. This includes project creation, task allocation, daily task monitoring, Gantt charts, sharing of documents, messaging and report generation.
Features
Managing project: User can add projects,view project according to enable/disable,update its detail
Monitoring task: Add task under projects,update its status etc
Gantt chart: User can analyze project status by using Graphical Interface.
Managing resource: Add Member for your project.
N-level user: Every level of user can add its subordinate user.
Document sharing: Upload/download document for projects.
Reporting on demand:Report generation according to project status,user,task etc
Security:Proper authentication etc
E-mail notification: When a user is added or he assign task etc, a notification mail hasbeen sent.This mail configuration is configurable.
We are still working for features,for good graphics desgin and more user friendly,more graphics. And i request you to everyone,plz give suggession for more correction.It is an open source project and anyone can use and customize acording to their needs.
URL for this application:
http://202.141.40.218/
Thanks
Deepak
Features
Managing project: User can add projects,view project according to enable/disable,update its detail
Monitoring task: Add task under projects,update its status etc
Managing organization:Add,View and edit organisation.Admin user will assign project to user for an organisation.
Gantt chart: User can analyze project status by using Graphical Interface.
Managing resource: Add Member for your project.
N-level user: Every level of user can add its subordinate user.
Document sharing: Upload/download document for projects.
Reporting on demand:Report generation according to project status,user,task etc
Security:Proper authentication etc
E-mail notification: When a user is added or he assign task etc, a notification mail hasbeen sent.This mail configuration is configurable.
We are still working for features,for good graphics desgin and more user friendly,more graphics. And i request you to everyone,plz give suggession for more correction.It is an open source project and anyone can use and customize acording to their needs.
URL for this application:
http://202.141.40.218/
Thanks
Deepak
Thursday, January 21, 2010
Validation using validator framework
Validation on a form using validation form
1)Create a new web application
2)Add struts capabilities
3)create new action,form and jsp
4)Add the following lines in Struts-config.xml
//This is for validator plug in
and in action tag ,add (validate="true") also.
6)Edit validation.xml
7)Edit Form JSP
onsubmit return validateFormName(this).
8)Test your application
Thanks
deepak
1)Create a new web application
2)Add struts capabilities
3)create new action,form and jsp
4)Add the following lines in Struts-config.xml
//This is for validator plug in
plug-in className="org.apache.struts.validator.ValidatorPlugIn">
set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
and in action tag ,add (validate="true") also.
6)Edit validation.xml
?xml version="1.0" encoding="UTF-8"?>
!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
form-validation>
formset>
form name="loginform" >
field property="name" depends="required,minlength" >
arg0 key="err.name" />
arg1 key="${var:minlength}" name="minlength" resource="false" />
var>
var-name>minlength
var-value>3
/field>
field property="pass" depends="required" >
arg0 key="err.pass" />
/field>
/form>
/formset>
/form-validation>
7)Edit Form JSP
html:javascript formName="loginform"/>
html:form action="login" onsubmit="return validateLoginform(this)">
onsubmit return validateFormName(this).
8)Test your application
Thanks
deepak
Thursday, January 14, 2010
Use Tiles in your Struts Application
Application Using Tiles:
For Eclise:
1) Create New Web-Project
2)Add Struts Capabilities.
3)Create "layout.jsp"
Use this Syntax:
tiles:insert attribute="header"/>
How you want to show your page.Like header,footer,main,left,body etc.Specify it here.
4)Make following Entry in "tiles-defs.xml"
tiles-definitions>
-- Base Tiles Definition
This is the main definition.You extend it in other definition.
It means if you can use same jsp or override it.
-->
definition name="base.definition" path="/Layout.jsp">
put name="header" value="/WEB-INF/JSP/header.jsp" />
put name="left" value="/WEB-INF/JSP/LeftLink.jsp"/>
put name="left" value="/WEB-INF/JSP/welcome.jsp"/>
put name="footer" value="/WEB-INF/JSP/footer.jsp" />
-- Tiles Definition of welcome page -->
definition name="page.welcome" extends="base.definition">
put name="title" value="Welcome page" />
put name="body" value="/WEB-INF/JSP/welcome.jsp" />
5)Edit Struts-Config.XML
Required part:
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" />
set-property property="definitions-parser-validate" value="true" />
And define your actions as you want.
path="/welcome.do"
redirect="true" />
action-mappings>
action path="/welcome"
type="home.WelcomeAction">
forward name="showWelcome" path="page.welcome" />
action path="/leftlink"
type="home.LinkAction">
forward name="showLink" path="page.left" />
6)Create jsp according to your view and URL which you are giving in tiles-defs package
7)Create your actions.
8)Run your application.
I think it is useful.If any required step is still remaining,plz correct it.
Thanks
Deepak
For Eclise:
1) Create New Web-Project
2)Add Struts Capabilities.
3)Create "layout.jsp"
Use this Syntax:
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
tiles:insert attribute="header"/>
How you want to show your page.Like header,footer,main,left,body etc.Specify it here.
4)Make following Entry in "tiles-defs.xml"
tiles-definitions>
-- Base Tiles Definition
This is the main definition.You extend it in other definition.
It means if you can use same jsp or override it.
-->
definition name="base.definition" path="/Layout.jsp">
put name="header" value="/WEB-INF/JSP/header.jsp" />
put name="left" value="/WEB-INF/JSP/LeftLink.jsp"/>
put name="left" value="/WEB-INF/JSP/welcome.jsp"/>
put name="footer" value="/WEB-INF/JSP/footer.jsp" />
-- Tiles Definition of welcome page -->
definition name="page.welcome" extends="base.definition">
put name="title" value="Welcome page" />
put name="body" value="/WEB-INF/JSP/welcome.jsp" />
5)Edit Struts-Config.XML
Required part:
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" />
set-property property="definitions-parser-validate" value="true" />
And define your actions as you want.
redirect="true" />
action-mappings>
action path="/welcome"
type="home.WelcomeAction">
forward name="showWelcome" path="page.welcome" />
action path="/leftlink"
type="home.LinkAction">
forward name="showLink" path="page.left" />
6)Create jsp according to your view and URL which you are giving in tiles-defs package
7)Create your actions.
8)Run your application.
I think it is useful.If any required step is still remaining,plz correct it.
Thanks
Deepak
Thursday, August 27, 2009
Tree Structure in JSP
Hi,
Its very useful if you want to show some structure in hierarchical way.
Requirement:treetag.jar and taglib49.tld (I can't upload here these files,you can download it form internet)
edit your web.xml file:
description This is the tree structure description
display-name Deepak display-name
servlet-name xmlTree servlet-name
servlet-class xmlTree servlet-class
servlet
servlet-mapping tree servlet-name
url-pattern /run1 url-pattern
servlet-mapping
taglib
taglib-uri /com/cj/tree taglib-uri
taglib-location /WEB-INF/Tag/taglib49.tld taglib-location
taglib
Now write in your jsp following line:
for JSP or in struts application,use following lines:
<%
root=new com.cj.tree.TreeBean();
root.setCode("Root");
root1=new com.cj.tree.TreeBean();
root1.setCode("deepak pandey");
rec("deepak pandey",root1);//this fuction is defined,because i want to get tree dynamically
root.addChild(root1);
%>
<%!
ResultSet rs=null;
com.cj.tree.TreeBean root;
com.cj.tree.TreeBean root1;
void rec(String s1,com.cj.tree.TreeBean root1)
{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/pms1?user=root&password=123");
PreparedStatement ps1=con.prepareStatement("SELECT user_Id,project_name FROM validate v where permittedby=? and Project_Name='PMS'");
ps1.setString(1,s1);
ResultSet rs1=ps1.executeQuery();
while(rs1.next())
{
System.out.println(rs1.getString(1));
com.cj.tree.TreeBean node11=new com.cj.tree.TreeBean();
node11.setCode(""+rs1.getString(1));
rec(rs1.getString(1),node11);
root1.addChild(node11);
}
}
catch(Exception e1){System.out.println("error is"+e1);}
}
%>
tree:createTree defaultConnectors="false" treePicture="order_asc.gif" nodePicture="order_asc.gif" openPicture="order_desc.gif" verticalConnector="vertical.gif" middleConnector="middle.gif" modelBean="<%=root%>" dhtml="true"
Another way :
<%= "This is Tree Structure" %>
tree:createTree dhtml="true"//for image etc write in this tag
tree:addNode code="Deep"
tree:addNode code="Deepak1.1"
tree:addNode code="Deepak1.2"
tree:addNode code="Deepak1.2.1"
tree:addNode code="Deepak1.2.2"
tree:addNode>
tree:addNode code="Deepak1.3"
tree:addNode>
tree:addNode code="Deepak2"
tree:createTree>
tree:createTree>
For any query,you can ask.
Its very useful if you want to show some structure in hierarchical way.
Requirement:treetag.jar and taglib49.tld (I can't upload here these files,you can download it form internet)
edit your web.xml file:
description This is the tree structure description
display-name Deepak display-name
servlet-name xmlTree servlet-name
servlet-class xmlTree servlet-class
servlet
servlet-mapping tree servlet-name
url-pattern /run1 url-pattern
servlet-mapping
taglib
taglib-uri /com/cj/tree taglib-uri
taglib-location /WEB-INF/Tag/taglib49.tld taglib-location
taglib
Now write in your jsp following line:
for JSP or in struts application,use following lines:
<%
root=new com.cj.tree.TreeBean();
root.setCode("Root");
root1=new com.cj.tree.TreeBean();
root1.setCode("deepak pandey");
rec("deepak pandey",root1);//this fuction is defined,because i want to get tree dynamically
root.addChild(root1);
%>
<%!
ResultSet rs=null;
com.cj.tree.TreeBean root;
com.cj.tree.TreeBean root1;
void rec(String s1,com.cj.tree.TreeBean root1)
{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/pms1?user=root&password=123");
PreparedStatement ps1=con.prepareStatement("SELECT user_Id,project_name FROM validate v where permittedby=? and Project_Name='PMS'");
ps1.setString(1,s1);
ResultSet rs1=ps1.executeQuery();
while(rs1.next())
{
System.out.println(rs1.getString(1));
com.cj.tree.TreeBean node11=new com.cj.tree.TreeBean();
node11.setCode(""+rs1.getString(1));
rec(rs1.getString(1),node11);
root1.addChild(node11);
}
}
catch(Exception e1){System.out.println("error is"+e1);}
}
%>
tree:createTree defaultConnectors="false" treePicture="order_asc.gif" nodePicture="order_asc.gif" openPicture="order_desc.gif" verticalConnector="vertical.gif" middleConnector="middle.gif" modelBean="<%=root%>" dhtml="true"
Another way :
<%= "This is Tree Structure" %>
tree:createTree dhtml="true"//for image etc write in this tag
tree:addNode code="Deep"
tree:addNode code="Deepak1.1"
tree:addNode code="Deepak1.2"
tree:addNode code="Deepak1.2.1"
tree:addNode code="Deepak1.2.2"
tree:addNode>
tree:addNode code="Deepak1.3"
tree:addNode>
tree:addNode code="Deepak2"
tree:createTree>
tree:createTree>
For any query,you can ask.
Subscribe to:
Posts (Atom)