[jboss-user] [JBoss Seam] - Re: Junk characters after validation.

muralikri_bng do-not-reply at jboss.com
Mon Oct 22 06:30:13 EDT 2007


Hi 

Pls find the xhtml file and 2 beans which are refferecned from this xhtml and also the action class.


------ xhtml starts here -----------
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  | 	xmlns:ui="http://java.sun.com/jsf/facelets"
  | 	xmlns:h="http://java.sun.com/jsf/html"
  | 	xmlns:f="http://java.sun.com/jsf/core"
  | 	xmlns:s="http://jboss.com/products/seam/taglib"
  | 	xmlns:a="https://ajax4jsf.dev.java.net/ajax"
  | 	template="../common/template.xhtml">
  | 
  | 	<ui:define name="header">
  | 		<ui:include src="../common/header.xhtml">
  | 		</ui:include>
  | 	</ui:define>
  | 	<ui:define name="menu">
  | 		<ui:include src="../common/erpmenu.xhtml" />
  | 	</ui:define>
  | 
  | 	<ui:define name="body">
  | 		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  | 			<tr>
  | 				<td colspan="3" valign="top">
  | 				<table width="100%" border="0" cellspacing="0" cellpadding="0">
  | 					<tr>
  | 						<td valign="top" class="space"><h:form id="applicant"
  | 							enctype="multipart/form-data">
  | 							<fieldset><h:messages globalOnly="true" /> <f:facet
  | 								name="beforeInvalidField">
  | 								<s:span styleClass="errors" />
  | 							</f:facet> <f:facet name="afterInvalidField">
  | 								<s:message />
  | 							</f:facet> <s:div styleClass="errors">
  | 								<s:message globalOnly="true" />
  | 							</s:div> <s:validateAll>
  | 								<table width="100%" border="0" cellpadding="0" cellspacing="0"
  | 									class="table">
  | 									<tr>
  | 										<td colspan="8" class="pageflow"><s:link
  | 											action="/pages/ERP_homepage.seam">Home</s:link> » <b>#{applicant.id > 0 ? 'Edit Profile' : 'Register'}</b></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td colspan="8" align="left" class="hr"></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td colspan="8" align="left" valign="top" nowrap="nowrap"
  | 											class="t_small">( * fields are mandatory)</td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td valign="top" nowrap="nowrap"><h:outputLabel
  | 											for="email">Email  *</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:inputText id="email" value="#{applicant.email}" readonly="#{employee.id > 0}"
  | 												 type="text" class="TF" style="width: 150px;" required="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 								
  | 									<tr class="table">
  | 										<td width="20%" align="left" valign="top"><h:outputLabel
  | 											for="password">Password *</h:outputLabel></td>
  | 										<td width="84%" colspan="7" align="left" nowrap="nowrap"><s:decorate>
  | 											<h:inputSecret id="password" value="#{applicant.password}"
  | 												type="text" class="TF" style="width: 150px;" required="true"
  | 												redisplay="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td width="20%" align="left" valign="top"><h:outputLabel
  | 											for="confirmPassword">Confirm Password *</h:outputLabel></td>
  | 										<td width="84%" colspan="7" align="left" nowrap="nowrap"><s:decorate>
  | 											<h:inputSecret id="confirmPassword"
  | 												value="#{erpAction.confirmPassword}" type="text" class="TF"
  | 												style="width: 150px;" required="true" redisplay="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td width="20%" align="left" valign="top"><h:outputLabel
  | 											for="LoginId">Employee Id *</h:outputLabel></td>
  | 										<td width="84%" colspan="7" align="left" nowrap="nowrap"><s:decorate>
  | 											<h:inputText id="LoginId" value="#{employee.employeeId}"
  | 												readonly="#{employee.id > 0}" type="text" class="TF"
  | 												style="width: 150px;" required="true" /> 
  | 										</s:decorate></td>
  | 									</tr><tr class="table">
  | 										<td width="20%" align="left" valign="top"><h:outputLabel
  | 											for="firstName">First Name *</h:outputLabel></td>
  | 										<td width="84%" colspan="7" align="left" nowrap="nowrap"><s:decorate>
  | 											<h:inputText id="firstName" value="#{applicant.firstName}"
  | 												type="text" class="TF" style="width: 150px;" required="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td align="left" valign="top" nowrap="nowrap"><h:outputLabel
  | 											for="lastName">Last Name *</h:outputLabel></td>
  | 										<td width="84%" colspan="7" align="left" nowrap="nowrap"><s:decorate>
  | 											<h:inputText id="lastName" value="#{applicant.lastName}"
  | 												type="text" class="TF" style="width: 150px;" required="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td align="left" valign="top" nowrap="nowrap"><h:outputLabel
  | 											for="mobile">Mobile *</h:outputLabel></td>
  | 										<td colspan="7" align="left"><s:decorate>
  | 											<h:inputText id="mobile" value="#{applicant.mobile}"
  | 												type="text" class="TF" style="width: 150px;" required="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr class="table">
  | 										<td align="left" valign="top" nowrap="nowrap"><h:outputLabel
  | 											for="deskPhone">Desk Phone *</h:outputLabel></td>
  | 										<td colspan="7" align="left"><s:decorate>
  | 											<h:inputText id="deskPhone" value="#{employee.deskPhone}"
  | 												type="text" class="TF" style="width: 150px;" required="true" /> 
  | 										</s:decorate> - Ext <span> </span> <s:decorate>
  | 											<h:inputText id="deskPhoneExt"
  | 												value="#{employee.deskPhoneExt}" type="text" class="TF_nl"
  | 												size="5" maxlength="5" /> </s:decorate></td>
  | 									</tr>
  | 									
  | 									<tr>
  | 
  | 										<td valign="top"><h:outputLabel for="dateOfBirth">Date Of Birth *</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:inputText id="dateOfBirth" styleClass="TF"
  | 												value="#{applicant.dateOfBirth}" style="width: 150px;"
  | 												required="true">
  | 												<s:convertDateTime pattern="MM/dd/yyyy" type="date" />
  | 											</h:inputText>
  | 											<s:selectDate for="dateOfBirth">
  | 												<h:graphicImage url="../images/calender.gif"
  | 													style="margin-left:5px;cursor:pointer" />
  | 											</s:selectDate> </s:decorate></td>
  | 
  | 									</tr>
  | 									<tr>
  | 										<td colspan="8" valign="top"> </td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel
  | 											for="highestQualification">Highest Level Of Education *</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:selectOneMenu
  | 												value="#{erpAction.selectedHighestQualification}"
  | 												id="highestQualification" class="Ts" required="true">
  | 												<f:selectItem itemLabel="Select" itemValue="" />
  | 												<f:selectItems value="#{erpAction.highestQualifications}" />
  | 											</h:selectOneMenu> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top" nowrap="nowrap"><h:outputLabel
  | 											for="otherQualification">Other Qualification</h:outputLabel></td>
  | 										<td colspan="7"><h:inputText id="otherQualification"
  | 											value="#{applicant.otherQualification}" type="text"
  | 											class="TF" style="width: 150px;" /></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top" nowrap="nowrap"><h:outputLabel
  | 											for="certification">Certifications</h:outputLabel></td>
  | 										<td colspan="7"><h:inputText id="certification"
  | 											value="#{employee.certification}" type="text" class="TF"
  | 											style="width: 150px;" /></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel>Total Work Experience</h:outputLabel></td>
  | 										<td colspan="7"><h:selectOneMenu
  | 											value="#{erpAction.selectedExpYear}" id="totalExpYear"
  | 											styleClass="TF_nl"  style="width: 60px;" required="false">
  | 											<f:selectItem itemLabel="Year" itemValue="0" />
  | 											<f:selectItems value="#{erpAction.years}" />
  | 										</h:selectOneMenu><br></br>
  | 										
  | 										 <h:selectOneMenu value="#{erpAction.selectedExpMonth}"
  | 											id="totalExpMonth" styleClass="TF_nl" style="width: 60px;" required="false">
  | 											<f:selectItem itemLabel="Month" itemValue="0" />
  | 											<f:selectItems value="#{erpAction.months}" />
  | 										</h:selectOneMenu>
  | 										</td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel>Duration In Current Role / Job</h:outputLabel></td>
  | 										<td colspan="7"><h:selectOneMenu
  | 											value="#{erpAction.selectedDurationYear}"
  | 											id="totalDurationYear" styleClass="TF_nl" style="width: 60px;" required="false">
  | 											<f:selectItem itemLabel="Year" itemValue="0" />
  | 											<f:selectItems value="#{erpAction.years}" />
  | 										</h:selectOneMenu><br></br>
  | 										
  | 										<h:selectOneMenu value="#{erpAction.selectedDurationMonth}"
  | 											id="totalDurationMonth" styleClass="TF_nl" style="width: 60px;" required="false">
  | 											<f:selectItem itemLabel="Month" itemValue="0" />
  | 											<f:selectItems value="#{erpAction.months}" />
  | 										</h:selectOneMenu>
  | 										</td>
  | 									</tr>
  | 									<tr>
  | 										<td colspan="8"> </td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="employeeSince">Employee Since *</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:inputText id="employeeSince" styleClass="TF"
  | 												value="#{employee.employeeSince}" style="width: 150px;"
  | 												required="true">
  | 												<s:convertDateTime pattern="MM/dd/yyyy" type="date" />
  | 											</h:inputText> 
  | 										 <s:selectDate for="employeeSince">
  | 												<span class="t_small"> <h:graphicImage
  | 													url="../images/calender.gif" /> </span>
  | 											</s:selectDate>
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="division">Division *</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:selectOneMenu value="#{erpAction.selectedDivision}"
  | 												id="division" class="Ts" required="true">
  | 												<f:selectItem itemLabel="Select" itemValue="" />
  | 												<f:selectItems value="#{erpAction.divisions}" />
  | 											</h:selectOneMenu> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="currentPosition">Current Position</h:outputLabel></td>
  | 										<td colspan="7"><label for="fileField"> <h:inputText
  | 											id="currentPosition" value="#{employee.currentPosition}"
  | 											type="text" class="TF" style="width: 150px;" /> </label></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="managerName">Reporting Manager's Name</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:inputText id="managerName" value="#{employee.managerName}"
  | 												type="text" class="TF" style="width: 150px;">
  | 												<s:validate />
  | 											</h:inputText>
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="primarySkill">Primary Skills *</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:inputTextarea id="primarySkill"
  | 												value="#{applicant.primarySkill}" cols="45" rows="5"
  | 												class="TF_nl" required="true" /> 
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="secondarySkill">Secondary Skills</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate>
  | 											<h:inputTextarea id="secondarySkill"
  | 												value="#{applicant.secondarySkill}" cols="45" rows="5"
  | 												class="TF_nl" />
  | 										</s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td valign="top"><h:outputLabel for="additionalComment">Additional Comments</h:outputLabel></td>
  | 										<td colspan="7"><s:decorate><h:inputTextarea id="additionalComment"
  | 											value="#{applicant.additionalComment}" cols="45" rows="5"
  | 											class="TF_nl" /></s:decorate></td>
  | 									</tr>
  | 
  | 									<tr>
  | 										<td colspan="8"><h:outputLabel for="uploadResume">
  | 											<b>Upload Resume</b>
  | 											<span class="t_small">(you can paste your resume here
  | 											or you can upload the File)</span>
  | 										</h:outputLabel></td>
  | 									</tr>
  | 									<tr>
  | 										<td colspan="8"><h:outputLabel>
  | 											<span class="t_small">Browse and upload resume<br />
  | 											</span>
  | 											<s:fileUpload data="#{applicant.attachedResume}"
  | 												fileName="#{applicant.attachedResumeName}"
  | 												contentType="#{applicant.resumeContentType}" accept="" />   (Maximum size of the file that can be uploaded is 50 Kb).
  | 										</h:outputLabel> <s:link value="View Resume"
  | 											action="#{erpAction.downloadFileContent}"
  | 											rendered="#{erpAction.visible}" target="_blank" /></td>
  | 									</tr>
  | 									<tr>
  | 										<td></td>
  | 									</tr>
  | 									<tr>
  | 										<td colspan="8"><h:outputLabel>
  | 											<span class="t_small">Paste Your Resume Here </span>
  | 										</h:outputLabel><br /><s:decorate>
  | 										<h:inputTextarea id="resume" value="#{applicant.resume}"
  | 											cols="80" rows="10" class="TF_nl" /></s:decorate></td>
  | 									</tr>
  | 									<tr>
  | 										<td colspan="8" align="center" valign="middle"><br />
  | 										<h:commandButton id="applyEmployee"
  | 											action="#{erpAction.applyJob}" value="Save and Apply"
  | 											class="button"
  | 											rendered="#{(applicant.id > 0 and erpAction.apply == true)}" /><span>
  | 										</span><h:commandButton id="registerEmployee"
  | 											action="#{erpAction.register}" value="Register"
  | 											class="button" rendered="#{applicant.id == 0}" /><span>
  | 										</span> <h:commandButton id="updateEmployee"
  | 											action="#{erpAction.register}" value="Update" class="button"
  | 											rendered="#{(applicant.id > 0 and erpAction.update == true)}" /><span>
  | 										</span> <h:commandButton id="cancelEmployee"
  | 											action="#{erpAction.cancel}" value="Cancel" class="button"
  | 											immediate="true" /></td>
  | 									</tr>
  | 								</table>
  | 							</s:validateAll></fieldset>
  | 						</h:form></td>
  | 					</tr>
  | 					<tr>
  | 						<td colspan="2" align="right" valign="top"></td>
  | 					</tr>
  | 				</table>
  | 				</td>
  | 			</tr>
  | 		</table>
  | 		<script>
  | 	function foucsOnFirstField(){
  | 	
  | 		if(document.getElementById("applicant:email") != null){
  | 			if(document.getElementById("applicant:email").readOnly == false){
  | 				document.getElementById("applicant:email").focus();
  | 			}else{
  | 				document.getElementById("applicant:password").focus();
  | 			}
  | 		}else{
  | 			document.getElementById("applicant:password").focus();
  | 		}
  | 	}
  | </script>
  | 	</ui:define>
  | </ui:composition>
------ xhtml ends here -----------


The xhtml reffers to 2 beans

--------------- first bean starts here-------------
package com._3iinfotech.applications.vedaenterprise.persistance;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Past;
import org.hibernate.validator.Pattern;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import com._3iinfotech.applications.vedaenterprise.common.DatabaseTables;


@Entity
@Name("applicant")
@Scope(ScopeType.SESSION)
@Table(name = DatabaseTables.APPLICANT_TABLE)

public class Applicant implements Serializable {
	
	/* constructor for Applicant */
	public Applicant(){
	}
	
	// This is the foreign key reference to usergroups table
    public static final String APPLICANT_ID = "applicantId";
    public static final String FOLDER_ID = "folderId";
   
    
	/* id : this is primary key and auto generated */
	public static final String ID_COLUMN = "id";
	@Id
	@Column(name = ID_COLUMN, length = 11, nullable = false, unique = true, updatable = false, insertable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;	
	
	/* password - appicant's password */
	public static final String PASSWORD_COLUMN = "password";
	@NotNull
	@Length(min = 8, max = 32)
	@Column(name = PASSWORD_COLUMN, nullable = false)
	@Pattern(regex = "^\\S(\\S)*$", message = "Invalid Password!")
	private String password;

	/* firstName - applicant first name */
	public static final String FIRST_NAME_COLUMN = "firstName";
	@NotNull
	@Length(min = 3, max = 25)
	@Pattern(regex="[A-Za-z]+[ A-Za-z]+" , message="Invalid Name! Numbers/Special characters are not allowed!")
	@Column(name = FIRST_NAME_COLUMN, nullable = false)
	private String firstName;

	/* lastName - applicant last name */
	public static final String LAST_NAME_COLUMN = "lastName";
	@NotNull
	@Length(min = 3, max = 25)
	@Pattern(regex="[A-Za-z]+[ A-Za-z]+" , message="Invalid Name! Numbers/Special characters are not allowed!")
	@Column(name = LAST_NAME_COLUMN, nullable = false)
	private String lastName;
	
	/* mobile - applicant mobile number */
	public static final String MOBILE_COLUMN = "mobile";
	@NotNull
	@Pattern(regex = "(\\d*\\d*)" , message="Use Only Integers. No spaces or special characters are allowed")
	@Column(name = MOBILE_COLUMN, nullable = false)
	private String mobile;
	
	/* email - applicant email id */
    public static final String EMAIL_COLUMN = "email";
    @NotNull
    @Pattern(regex ="[a-zA-Z0-9\\-_\\.]++@[a-zA-Z0-9\\-]++(.[a-zA-Z\\-]++)++",  message="Not a valid Email")
    @Column(name = EMAIL_COLUMN, unique = true)
    private String email;
	
    /* dateOfBirth - applicant dateOfBirth */
    public static final String DATE_OF_BIRTH_COLUMN = "dateOfBirth";
    @Temporal (TemporalType.DATE)
    @NotNull
    @Past
    @Column(name = DATE_OF_BIRTH_COLUMN, nullable = false)
    private Date dateOfBirth;
    
    /* totalExpYear - Applicant total number of year experience */
	public static final String TOTAL_EXP_YEAR_COLUMN = "totalExpYear";
	@ManyToOne
	@JoinColumn(name = TOTAL_EXP_YEAR_COLUMN)
	private DictionaryValue totalExpYear;

	/* totalExpMonth - Applicant total number of month experience */
	public static final String TOTAL_EXP_MONTH_COLUMN = "totalExpMonth";
	@ManyToOne
	@JoinColumn(name = TOTAL_EXP_MONTH_COLUMN)
	private DictionaryValue totalExpMonth;
    
    /* otherQualifiction - applicant otherQualifiction */
    public static final String OTHER_QUALIFICATION_COLUMN = "otherQualification";
    @Column(name = OTHER_QUALIFICATION_COLUMN)
    private String otherQualification;
    
    /* primaryskill - applicant Primary skills */
    public static final String PRIMARY_SKILL_COLUMN = "primarySkill";
    @NotNull
    @Length(min = 10, max = 5000, message = "Primary skill should be between {min} and {max} characters.")
    @Pattern (regex = "^\\S+((\\s)*(\\S)*)*(\\s)*$", message = "Invalid Primary Skills")
    @Column(name = PRIMARY_SKILL_COLUMN, nullable = false, columnDefinition="TEXT")
    private String primarySkill;
    
    /* SecondarySkill - applicant Secondary skills */
    public static final String SECONDARY_SKILL_COLUMN = "secondarySkill";
    @Length(min = 10, max = 5000, message = "Secondary Skill should be between {min} and {max} characters.")
    @Column(name = SECONDARY_SKILL_COLUMN, columnDefinition="TEXT")
    private String secondarySkill;
    
    /* additionalComment - applicant additional Comment */
    public static final String ADDITIONAL_COMMENT_COLUMN = "additionalComment";
    @Length(min = 10, max = 5000, message = "Additional Comment should be between {min} and {max} characters.")
    @Column(name = ADDITIONAL_COMMENT_COLUMN, columnDefinition="TEXT")
    private String additionalComment;
    
    public static final String ATTACHED_RESUME_NAME_COLUMN = "attachedResumeName";
    @Column(name = ATTACHED_RESUME_NAME_COLUMN)
    private String attachedResumeName;

    /* FILE: attached file */
    public static final String ATTACHED_RESUME_COLUMN = "attachedResume";
    @Lob
    @Column(name = ATTACHED_RESUME_COLUMN)
    private byte[] attachedResume;

    /* FILE: Content type for resume*/
    public static final String RESUME_CONTENT_TYPE = "resumeContentType";
    @Column(name = RESUME_CONTENT_TYPE)
    private String resumeContentType;
    
    /* resume: resume */
    public static final String RESUME_COLUMN = "resume";
    @Length(min = 10, max = 10000, message = "Resume should be between {min} and {max} characters.")
    @Column(name = RESUME_COLUMN, columnDefinition="TEXT")
    private String resume;
        
    /* status - whether the user is active or inActive */
    public static final String STATUS_COLUMN = "status";
    @Column(name = STATUS_COLUMN, columnDefinition = "BOOLEAN")
    private boolean status;
    
    /* createdOn: created on which date */
    public static final String CREATED_ON_COLUMN = "createdOn";
    @Column(name = CREATED_ON_COLUMN)
    private Date createdOn;

    /* modifiedOn: modifiedOn which date */
    public static final String MODIFIED_ON_COLUMN = "lastModifiedOn";
    @Column(name = MODIFIED_ON_COLUMN)
    private Date lastModifiedOn;
    
    /* createdByAdminId :created by admin */
    public static final String CREATED_BY_USER_ID_COLUMN = "createdByUserId";
    @ManyToOne 
    @JoinColumn (name = CREATED_BY_USER_ID_COLUMN)
    private UserMaster createdByUser;
    
    /*
     * lastModifiedByUser - contains the id of the user who last modified this
     * profile, should be like a foreign key
     */
    public static final String LAST_MODIFIED_BY_USER_ID_COLUMN = "modifiedByUserId";
    @ManyToOne
    @JoinColumn(name = LAST_MODIFIED_BY_USER_ID_COLUMN)
    private UserMaster lastModifiedByUser;
    
    /* jobApplications - list containing the jobs applied by the applicant */
    @OneToMany
    @JoinColumn (name = JobApplication.APPLICANT_ID_COLUMN, referencedColumnName = ID_COLUMN)
    private List jobApplications;
  
    
    /* jobApplications - list containing the jobs applied by the applicant */
    @OneToMany
    @JoinColumn (name = JobCart.APPLICANT_ID_COLUMN, referencedColumnName = ID_COLUMN)
    private List cartJobs;
    
    /* candidate - candidate reference bean */
    @OneToOne (cascade = CascadeType.ALL)
    @JoinColumn(name = Candidate.CANDIDATE_COLUMN)
    private Candidate candidate;
    
    /* employee - employee reference bean */
    @OneToOne (cascade = CascadeType.ALL)
    @JoinColumn(name = Employee.EMPLOYEE_COLUMN)
    private Employee employee;
    
    public static final String JOB_ID = "jobId";
    @ManyToMany
    @JoinTable(name="jobapplication", joinColumns = { @JoinColumn(name = APPLICANT_ID) }, 
            inverseJoinColumns = { @JoinColumn(name = JOB_ID) })
    private List jobs;
    
  //Bug no -5398-- this is used to get the applicant list add to  each folder.
    //jobApplications - list containing the jobs applied by the applicant 
    @ManyToMany(targetEntity = Folder.class, mappedBy = "appList", cascade={CascadeType.PERSIST, CascadeType.MERGE})
	private List applicantFolderList;
    
    /**
	 * 
	 * @return lastModifiedByUser
	 */
	public UserMaster getLastModifiedByUser() {
		return lastModifiedByUser;
	}
	
	/**
	 * 
	 * @param lastModifiedByUser
	 */
	public void setLastModifiedByUser(UserMaster lastModifiedByUser) {
		this.lastModifiedByUser = lastModifiedByUser;
	}
	
	/**
	 * 
	 * @return createdByUser
	 */
	public UserMaster getCreatedByUser() {
		return createdByUser;
	}
	
	/**
	 * 
	 * @param createdByUser
	 */
	public void setCreatedByUser(UserMaster createdByUser) {
		this.createdByUser = createdByUser;
	}
	
	/**
	 * 
	 * @return createdOn
	 */
	public Date getCreatedOn() {
		return createdOn;
	}
	
	/**
	 * 
	 * @param createdOn
	 */
	public void setCreatedOn(Date createdOn) {
		this.createdOn = createdOn;
	}
	
	/**
	 * 
	 * @return lastModifiedOn
	 */
	public Date getLastModifiedOn() {
		return lastModifiedOn;
	}
	
	/**
	 * 
	 * @param lastModifiedOn
	 */
	public void setLastModifiedOn(Date lastModifiedOn) {
		this.lastModifiedOn = lastModifiedOn;
	}
	
	/**
	 * 
	 * @return status
	 */
	public boolean isStatus() {
		return status;
	}
	
	/**
	 * 
	 * @param status
	 */
	public void setStatus(boolean status) {
		this.status = status;
	}
	
	/**
	 * 
	 * @return resume
	 */
	public String getResume() {
		return resume;
	}
	
	/**
	 * 
	 * @param resume
	 */
	public void setResume(String resume) {
		this.resume = resume;
	}
	
	/**
	 * 
	 * @return attachedResume
	 */
	public byte[] getAttachedResume() {
		return attachedResume;
	}
	
	/**
	 * 
	 * @param attachedResume
	 */
	public void setAttachedResume(byte[] attachedResume) {
		this.attachedResume = attachedResume;
	}
	
	/**
	 * 
	 * @return attachedResumeName
	 */
	public String getAttachedResumeName() {
		return attachedResumeName.substring(attachedResumeName.lastIndexOf("\\")+1);
	}
	
	/**
	 * 
	 * @param attachedResumeName
	 */
	public void setAttachedResumeName(String attachedResumeName) {
		this.attachedResumeName = attachedResumeName;
	}
	
	/**
	 * 
	 * @return resumeContentType
	 */
	public String getResumeContentType() {
		return resumeContentType;
	}
	
	/**
	 * 
	 * @param resumeContentType
	 */
	public void setResumeContentType(String resumeContentType) {
		this.resumeContentType = resumeContentType;
	}
	
	/**
	 * 
	 * @return additionalComment
	 */
	public String getAdditionalComment() {
		return additionalComment;
	}
	
	/**
	 * 
	 * @param additionalComment
	 */
	public void setAdditionalComment(String additionalComment) {
		this.additionalComment = additionalComment;
	}
	
	/**
	 * 
	 * @return primarySkill
	 */
	public String getPrimarySkill() {
		return primarySkill;
	}
	
	/**
	 * 
	 * @param primarySkill
	 */
	public void setPrimarySkill(String primarySkill) {
		this.primarySkill = primarySkill;
	}
	
	/**
	 * 
	 * @return secondarySkill
	 */
	public String getSecondarySkill() {
		return secondarySkill;
	}
	
	/**
	 * 
	 * @param secondarySkill
	 */
	public void setSecondarySkill(String secondarySkill) {
		this.secondarySkill = secondarySkill;
	}
	
	/**
	 *  
	 * @return dateOfBirth
	 */
	public Date getDateOfBirth() {
		return dateOfBirth;
	}
	
	/**
	 * 
	 * @param dateOfBirth
	 */
	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
	
	/**
	 * 
	 * @return email
	 */
	public String getEmail() {
		return email;
	}
	
	/**
	 * 
	 * @param email
	 */
	public void setEmail(String email) {
		this.email = email;
	}
			
	/**
	 * 
	 * @return otherQualifiction
	 */
	public String getOtherQualification() {
		return otherQualification;
	}
	
	/**
	 * 
	 * @param otherQualifiction
	 */
	public void setOtherQualification(String otherQualification) {
		this.otherQualification = otherQualification;
	}
	
	/**
	 * 
	 * @return firstName
	 */
	public String getFirstName() {
		return firstName;
	}
	
	/**
	 * 
	 * @param firstName
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	/**
	 * 
	 * @return lastName
	 */
	public String getLastName() {
		return lastName;
	}
	
	/**
	 * 
	 * @param lastName
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	/**
	 * 
	 * @return mobile
	 */
	public String getMobile() {
		return mobile;
	}
	
	/**
	 * 
	 * @param mobile
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	/**
	 * 
	 * @return password
	 */
	public String getPassword() {
		return password;
	}
	
	/**
	 * 
	 * @param password
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	/**
	 * 
	 * @return
	 */
	public List getJobApplications() {
		return jobApplications;
	}

	/**
	 * 
	 * @param jobApplications
	 */
	public void setJobApplications(List jobApplications) {
		this.jobApplications = jobApplications;
	}

	/**
	 * 
	 * @return applicantId
	 */
	public int getId() {
		return id;
	}

	/**
	 * 
	 * @param applicantId
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * 
	 * @return totalExpMonth
	 */
	public DictionaryValue getTotalExpMonth() {
		return totalExpMonth;
	}

	/**
	 * 
	 * @param totalExpMonth
	 */
	public void setTotalExpMonth(DictionaryValue totalExpMonth) {
		this.totalExpMonth = totalExpMonth;
	}

	/**
	 * 
	 * @return totalExpYear
	 */
	public DictionaryValue getTotalExpYear() {
		return totalExpYear;
	}

	/**
	 * 
	 * @param totalExpYear
	 */
	public void setTotalExpYear(DictionaryValue totalExpYear) {
		this.totalExpYear = totalExpYear;
	}

	public Candidate getCandidate() {
		return candidate;
	}

	public void setCandidate(Candidate candidate) {
		this.candidate = candidate;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	/**
	 * @return the cartJobs
	 */
	public List getCartJobs() {
		return cartJobs;
	}

	/**
	 * @param cartJobs the cartJobs to set
	 */
	public void setCartJobs(List cartJobs) {
		this.cartJobs = cartJobs;
	}
	
	@Override
	public boolean equals(Object arg0) {
		if (arg0 instanceof Applicant) {
			return (this.getId()==((Applicant) arg0).getId());
		}else{
			return super.equals(arg0);
		}
	}
	
	

	/**
	 * @return the applicantFolderList
	 */
	public List getApplicantFolderList() {
		return applicantFolderList;
	}

	/**
	 * @param applicantFolderList the applicantFolderList to set
	 */
	public void setApplicantFolderList(List applicantFolderList) {
		this.applicantFolderList = applicantFolderList;
	}

	/**
	 * @param jobs the jobs to set
	 */
	public void setJobs(List jobs) {
		this.jobs = jobs;
	}

	/**
	 * @return the jobs
	 */
	public List getJobs() {
		return jobs;
	}

}	

--------------- first bean ends here-------------

--------------- second bean ends here-------------
package com._3iinfotech.applications.vedaenterprise.persistance;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.NotNull;
import org.hibernate.validator.Past;
import org.hibernate.validator.Pattern;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import com._3iinfotech.applications.vedaenterprise.common.DatabaseTables;
/**
 * Employee class is designed to set and to get the values of the employee
 * table
 * 
 * 
 * Reviewer Name: Murali/Pradeep 
 * Review Date:   
 * Comments:  
 * 
 * 
 * @author Amit Kumar Jain
 * @version 1.0 14-August-2007
 * 
 */

@Entity
@Name("employee")
@Scope(ScopeType.SESSION)
@Table(name = DatabaseTables.EMPLOYEE_TABLE)
public class Employee implements Serializable {

	public Employee() {
	}
	/**	
	 * registration id - should be primary key and auto generated Your
	 * annotations
 	 */ 
	public static final String ID_COLUMN = "id";
	@Id
	@Column(name = ID_COLUMN, unique = true, nullable = false, updatable = false, insertable = false, length = 11)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	/* telephone - Employee telephone number */
	public static final String DESK_PHONE_COLUMN = "deskPhone";
	@NotNull
	@Pattern(regex = "(\\d*\\d*)" , message="Use Only Integers. No spaces or special characters are allowed")
	@Column(name = DESK_PHONE_COLUMN, nullable = false)
	private String deskPhone;

	/* ext - Employee telephone number */
	public static final String DESK_PHONE_EXT_COLUMN = "deskPhoneExt";
	@Pattern(regex = "(\\d*\\d*)" , message="Use Only Integers. No spaces or special characters are allowed")
	@Column(name = DESK_PHONE_EXT_COLUMN)
	private String deskPhoneExt;
	
	/* totalDurationYear - Employee total number of year duration in current job */
	public static final String TOTAL_DURATION_YEAR_COLUMN = "totalDurationYear";
	@ManyToOne
	@JoinColumn(name = TOTAL_DURATION_YEAR_COLUMN)
	private DictionaryValue totalDurationYear;

	/*
	 * totalDurationMonth - Employee total number of month duration in current
	 * job
	 */
	public static final String TOTAL_DURATION_MONTH_COLUMN = "totalDurationMonth";
	@ManyToOne
	@JoinColumn(name = TOTAL_DURATION_MONTH_COLUMN)
	private DictionaryValue totalDurationMonth;

	/* dateOfJoining - Employee joining date */
	public static final String EMPLOYEE_SINCE_COLUMN = "employeeSince";
	@Temporal (TemporalType.DATE)
	@NotNull
	@Past
	@Column(name = EMPLOYEE_SINCE_COLUMN, nullable = false)
	private Date employeeSince;

	/* division - Employee division in the current company */
	public static final String DIVISION_COLUMN = "division";
	@NotNull
	@ManyToOne
	@JoinColumn(name = DIVISION_COLUMN, nullable = false)
	private DictionaryValue division;
	
	/* certification - Employee certification */
    public static final String CERTIFICATION_COLUMN = "certification";
    @Column(name = CERTIFICATION_COLUMN)
    private String certification;
    
    /* highestQualification - Employee highestQualification */
    public static final String HIGHEST_QUALIFICATION_COLUMN = "highestQualification";
    @NotNull
    @ManyToOne
	@JoinColumn(name = HIGHEST_QUALIFICATION_COLUMN, nullable = false)
    private DictionaryValue highestQualification;


	/* designation - Employee designation in the current company */
	public static final String CURRENT_POSITION_COLUMN = "currentPosition";
	@Column(name = CURRENT_POSITION_COLUMN)
	private String currentPosition;

	/* managerName - Employee reporting manager's name */
	public static final String MANAGER_NAME_COLUMN = "managerName";
	@Column(name = MANAGER_NAME_COLUMN)
	@Pattern(regex="[A-Za-z]+[ A-Za-z]+" , message="Invalid Name! Numbers/Special characters are not allowed!")
	private String managerName;

	/* some comments */
	public static final String EMPLOYEE_COLUMN = "employee";
	@OneToOne (mappedBy = EMPLOYEE_COLUMN)
	private Applicant applicant;
	
	/* loginId: applicant's login id */
	public static final String EMPLOYEE_ID_COLUMN = "employeeId";
	@Column(name = EMPLOYEE_ID_COLUMN, nullable = false, unique = true)
	@Pattern (regex = "^\\S+((\\s)*(\\S)*)*(\\s)*$", message = "Invalid Employee ID")
	private String employeeId;

	
	
	/**
	 * @return Returns the employeeSince.
	 */
	public Date getEmployeeSince() {
		return employeeSince;
	}

	/**
	 * @param employeeSince
	 *            The employeeSince to set.
	 */
	public void setEmployeeSince(Date employeeSince) {
		this.employeeSince = employeeSince;
	}

	/**
	 * @return Returns the currentPosition.
	 */
	public String getCurrentPosition() {
		return currentPosition;
	}

	/**
	 * @param currentPosition
	 *            The currentPosition to set.
	 */
	public void setCurrentPosition(String currentPosition) {
		this.currentPosition = currentPosition;
	}

	/**
	 * @return Returns the division.
	 */
	public DictionaryValue getDivision() {
		return division;
	}

	/**
	 * @param division
	 *            The division to set.
	 */
	public void setDivision(DictionaryValue division) {
		this.division = division;
	}

	/**
	 * @return Returns the id.
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            The id to set.
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return Returns the managerName.
	 */
	public String getManagerName() {
		return managerName;
	}

	/**
	 * @param managerName
	 *            The managerName to set.
	 */
	public void setManagerName(String managerName) {
		this.managerName = managerName;
	}

	/**
	 * @return Returns the telephone.
	 */
	public String getDeskPhone() {
		return deskPhone;
	}

	/**
	 * @param telephone
	 *            The telephone to set.
	 */
	public void setDeskPhone(String deskPhone) {
		this.deskPhone = deskPhone;
	}

	/**
	 * @return Returns the totalDurationMonth.
	 */
	public DictionaryValue getTotalDurationMonth() {
		return totalDurationMonth;
	}

	/**
	 * @param totalDurationMonth
	 *            The totalDurationMonth to set.
	 */
	public void setTotalDurationMonth(DictionaryValue totalDurationMonth) {
		this.totalDurationMonth = totalDurationMonth;
	}

	/**
	 * @return Returns the totalDurationYear.
	 */
	public DictionaryValue getTotalDurationYear() {
		return totalDurationYear;
	}

	/**
	 * @param totalDurationYear
	 *            The totalDurationYear to set.
	 */
	public void setTotalDurationYear(DictionaryValue totalDurationYear) {
		this.totalDurationYear = totalDurationYear;
	}

	/**
	 * @return Returns the deskPhoneExt.
	 */
	public String getDeskPhoneExt() {
		return deskPhoneExt;
	}

	/**
	 * @param deskPhoneExt
	 *            The deskPhoneExt to set.
	 */
	public void setDeskPhoneExt(String deskPhoneExt) {
		this.deskPhoneExt = deskPhoneExt;
	}

	/**
	 * @return certification.
	 * 
	 */
	public String getCertification() {
		return certification;
	}

	/**
	 * @param certification
	 * 
	 */
	public void setCertification(String certification) {
		this.certification = certification;
	}

	/**
	 * 
	 * @return highestQualification
	 */
	public DictionaryValue getHighestQualification() {
		return highestQualification;
	}

	/**
	 * 
	 * @param highestQualification
	 */
	public void setHighestQualification(DictionaryValue highestQualification) {
		this.highestQualification = highestQualification;
	}

	/**
	 * 
	 * @return applicant
	 */
	public Applicant getApplicant() {
		return applicant;
	}

	/**
	 * 
	 * @param applicant
	 */
	public void setApplicant(Applicant applicant) {
		this.applicant = applicant;
	}

	/**
	 * 
	 * @return employeeId
	 */
	public String getEmployeeId() {
		return employeeId;
	}

	/**
	 * 
	 * @param employeeId
	 */
	public void setEmployeeId(String employeeId) {
		this.employeeId = employeeId;
	}
}
--------------- second bean ends here-------------


--------------- action class starts here ------------
package com._3iinfotech.applications.vedaenterprise.webapp.actions;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletRequest;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
import org.jboss.seam.Seam;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.log.Log;

import com._3iinfotech.applications.vedaenterprise.common.Constants;
import com._3iinfotech.applications.vedaenterprise.common.DatabaseTables;
import com._3iinfotech.applications.vedaenterprise.common.ExportConstants;
import com._3iinfotech.applications.vedaenterprise.persistance.Applicant;
import com._3iinfotech.applications.vedaenterprise.persistance.DictionaryValue;
import com._3iinfotech.applications.vedaenterprise.persistance.Employee;
import com._3iinfotech.applications.vedaenterprise.persistance.Job;
import com._3iinfotech.applications.vedaenterprise.persistance.JobApplication;
import com._3iinfotech.applications.vedaenterprise.persistance.Referral;
import com._3iinfotech.applications.vedaenterprise.persistance.UserMaster;
import com._3iinfotech.applications.vedaenterprise.persistance.UserType;
import com._3iinfotech.applications.vedaenterprise.webapp.util.Pagination;
import com._3iinfotech.applications.vedaenterprise.webapp.util.Util;

/**
 * ErpAction class is designed to implement all the functionality of ERP module
 * such as to register/update an employee, referred a candidate for a job, IJP
 * and searching.
 * 
 * 
 * Reviewer Name: Murali/Pradeep 
 * Review Date: 
 * Comments: 
 * 
 * 
 * @author Amit Kumar Jain
 * @version 1.0 20-August-2007
 * 
 */

@Name("erpAction")
@Scope(ScopeType.SESSION)
public class ErpAction extends Pagination {

	/* variable - cinfirmPassword */
	@NotNull
	@Length(min = 8, max = 32)
	private String confirmPassword;

	/* this is the employee bean declaration */
	@In(create = true)
	@Out(required = false)
	private Employee employee;

	/* this is the applicant bean declaration */
	@In(required = false, create = true)
	private Applicant applicant;

	/* this is the userMaster bean declaration */
	@In(required = false, create = true)
	private UserMaster currentUserMaster;

	/* this is the userTypeAction class declaration */
	@In(create = true)
	private UserTypeAction userTypeAction;

	/* this is the dictionaryAction declaration */
	@In(create = true)
	private DictionaryAction dictionaryAction;

	/* this is the referral bean declaration */
	@In(create = true)
	private Referral referral;

	/* this is the job bean declaration */
	@In(create = true)
	@Out(required = false)
	private Job job;

	/* this is the jobApplication bean declaration */
	@In(required = false, create = true)
	@Out(required = false)
	private JobApplication jobApplication;

	/* this is the session name to get the hibernate session injected. */
	@In
	private Session vedaenterpriseDatabase;

	/* this face message is used to display the message */
	@In
	private FacesMessages facesMessages;

	/* this is the declaration for log */
	@Logger
	private Log log;

	/* this variable is used to get the selected qualification form the UI */
	private int selectedHighestQualification;

	/* this variable is used to get the locationId form the UI */
	private int locationId;

	/* this variable is used to get the selected year of experience form the UI */
	private int selectedExpYear;

	/* this variable is used to get the selected year of experience form the UI */
	private int selectedExpMonth;

	/*
	 * this variable is used to get the selected duration of year in this
	 * company form the UI
	 */
	private int selectedDurationYear;

	/*
	 * this variable is used to get the selected duration of month in this
	 * company form the UI
	 */
	private int selectedDurationMonth;

	/* this variable is used to get the selected division form the UI */
	private int selectedDivision;

	/* this variable is used to get the divisionId for job object form the UI */
	private int divisionId;

	/* this variable is used to get the typeId form the UI */
	private int typeId;

	/* this datamodel contains hot jobs list from the database. */
	@DataModel
	private List hotJobs;

	/* this datamodel contains all jobs list from the database. */
	@DataModel
	private List searchJobsErp;

	/* this variable is used to get exportSelectedJobs. */
	private List exportSelectedJobs;

	/* this datamodel contains all jobs list of export jobs. */
	@DataModel
	private List exportJobs;

	/* this field is used to store list of header */
	private List fields;

	/* this field is used to define export format */
	private String exportFormat;

	/* this variable is used to get the keyword form the UI */
	public String keyword;

	/* this variable is used show or hide search criteria fields */
	private boolean showHide = true;

	/* this variable is used to define export type */
	private int exportId;

	/* this variable is used to define export type */
	private String exportIdString;

	/* this variable is used to forget password purpose */
	private int forgetPassword;

	/* this variable is used for loginId */
	private String loginId;

	/* This is used to get the jobs which belongs to hot jobs */
	private boolean hotJob;

	/* set the status of hot jobs */
	private boolean hotJobOrList = false;

	/* this variable is used to set flag to render button */
	private boolean apply = false;

	/* this variable is used to set flag to render button */
	private boolean update = true;
		
	/* this variable is used to set flag to return appropriate location */
	private boolean isFromERPHome = false;
	
	/* this variable is used to set flag to return appropriate location */
	private boolean isFromERPUpdate = false;
	
	
	/* constructor for ErpAction */
	public ErpAction() {
	}

	/**
	 * This method is used to validate applicant is already register or not,
	 * validate the password .
	 * 
	 * @return isValidate
	 */
	private boolean validate() {

		boolean isValidate = true;

		/* check it is registered employee or not. */
		if (applicant.getId() == 0) {

			/* check email is already exist or not. */
			if ((Long) vedaenterpriseDatabase.createQuery(
					" SELECT COUNT(*) FROM " + DatabaseTables.APPLICANT_CLASS
							+ " A WHERE A." + Applicant.EMAIL_COLUMN
							+ " = #{applicant.email}").uniqueResult() != 0) {

				/*
				 * faceMessages is used to display the message from the resource
				 * bundle property file.
				 */
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
								"duplicateEmail", new Object[] { applicant
										.getEmail() });
				isValidate = false;
			}
		
			// Task ID: 7187
			/* check EmployeeId is already exist or not. */
			if ((Long) vedaenterpriseDatabase.createQuery(
					" SELECT COUNT(*) FROM " + DatabaseTables.EMPLOYEE_CLASS
							+ " E WHERE E." + Employee.EMPLOYEE_ID_COLUMN
							+ " = #{employee.employeeId}").uniqueResult() != 0) {

				/*
				 * faceMessages is used to display the message from the resource
				 * bundle property file.
				 */
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
						"duplicateEmployeeId", new Object[] { employee
								.getEmployeeId() });
				isValidate = false;
			}
		}


		/* check password is matched or not. */
		if (!applicant.getPassword().equals(confirmPassword)) {

			/*
			 * faceMessages is used to display the message from the resource
			 * bundle property file.
			 */
			facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
					"matchpassword");
			log.info(" password and confirm password does not match. ");
			isValidate = false;
		}

		/* check Employee Since date is greater than DOB. */
		if (applicant.getDateOfBirth().after(employee.getEmployeeSince())) {

			/*
			 * faceMessages is used to display the message from the resource
			 * bundle property file.
			 */
			facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
					"employeesincelessthandob");
			log.info("Employee Since date should be greater than DOB");
			isValidate = false;
		}
		// if total year of exp. is less than Relevant Year of Exp. then
		// add faces message and set validate flag to false.
		if (selectedDurationYear > selectedExpYear) {

			// adding the message in the properties file.
			facesMessages.addFromResourceBundle("relevantexplessthantotal",
					FacesMessage.SEVERITY_INFO, "relevantexplessthantotal",
					new Object[] {});

			// adding the information in the log file.
			log
					.error("Relevant work experience should be less than total work experience.");
			isValidate = false;
		}
		if (selectedDurationYear == selectedExpYear) {
			if (selectedDurationMonth > selectedExpMonth) {

				// adding the message in the properties file.
				facesMessages.addFromResourceBundle("relevantexplessthantotal",
						FacesMessage.SEVERITY_INFO, "relevantexplessthantotal",
						new Object[] {});

				// adding the information in the log file.
				log
						.error("Relevant work experience should be less than total work experience.");
				isValidate = false;
			}
		}
		
		
		if (applicant.getAttachedResume() != null) {
			if (applicant.getAttachedResume().length > 54857) {
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
						"overload", applicant.getAttachedResumeName());
				log.info("File size more than 50 kb");
				isValidate = false;
			}
		}
		
		//Check if file name is edited or not
		if (applicant.getAttachedResumeName().length()>0&&applicant.getAttachedResume()==null) {
			
			if(!(new File(applicant.getAttachedResumeName().trim()).exists())) 
			{
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,			
					"The file path specified doesnt exist");
				isValidate = false;
			return isValidate;
			}
		}
	
		
		
		return isValidate;
	}

	/**
	 * This method is used to register/update an employee to access ERP program.
	 * 
	 * @return status
	 */
	public String register() {

		applicant.setEmployee(employee);
		UserMaster userMaster = null;
		String status = null;
		String message = null;
		boolean saveOrUpdate = false;

		try {

			/*
			 * calling the validate method to check applicant is satisfied all
			 * the requirements before persisting
			 */
			if (validate()) {

				/*
				 * check it is registered applicant or not. if it is new
				 * applicant then persisting user master object.
				 */
				if (applicant.getId() == 0) {
					saveOrUpdate = true;
					applicant.setStatus(true);
					applicant.setCreatedOn(new Date());
					userMaster = new UserMaster();
					userMaster.setUserName(applicant.getEmail());
					userMaster.setUserType(userTypeAction
							.getUserTypeByName(Constants.USER_EMPLOYEE));
					vedaenterpriseDatabase.save(userMaster);

				} else {
					saveOrUpdate = false;
					checkResume();
					this.applicant = (Applicant) vedaenterpriseDatabase
							.merge(this.applicant);
				}

				/* set the corresponding message based on saved or updated */
				message = (applicant.getId() == 0) ? "saved" : "updated";
				
				// Task ID: 6560
				applicant = (Applicant) vedaenterpriseDatabase.merge(applicant);
				
				/* persisting applicant object into the database. */
				vedaenterpriseDatabase.saveOrUpdate(applicant);
				vedaenterpriseDatabase.flush();
				vedaenterpriseDatabase.evict(applicant);
				if(!saveOrUpdate){
					applicant = (Applicant)vedaenterpriseDatabase.load(Applicant.class, applicant.getId());
					vedaenterpriseDatabase.refresh(applicant );
				}else{
					FacesContext ctx = FacesContext.getCurrentInstance();
					
					HttpServletRequest request = (HttpServletRequest) ctx
							.getExternalContext().getRequest();
					
					employee = new Employee();
					request.getSession().removeAttribute("applicant");
					
				}

				/*
				 * faceMessages is used to display the message from the resource
				 * bundle property file.
				 */
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
						message, new Object[] { applicant.getEmail() });

				/*
				 * Log is used to display the information applicant is persist
				 * or not.
				 */
				log.info(" #{applicant.email} Successfully saved. ");
				status = Constants.NAVIGATION_STATUS_SUCCESS;
			} else {
				status = Constants.NAVIGATION_STATUS_FAILURE;
			}
		} catch (Exception e) {

			/* Log is used to display the catch exception. */
			facesMessages.add(FacesMessage.SEVERITY_ERROR, "Exception occured : " + e.getMessage());
			log.error("Exception when implementing register() method in ERPAction class "
							+ e.getMessage());
			status = Constants.NAVIGATION_STATUS_FAILURE;
		}
		// this.applicant = null;
		// this.employee = null;
		return status;
	}

	/**
	 * This method load the Applicant object and set the old resume if new
	 * resume is not uploaded.
	 * 
	 * @return
	 */
	private void checkResume() {

		Applicant loadApplicant = null;

		/* loading the Applicant object */
		loadApplicant = (Applicant) vedaenterpriseDatabase.load(
				Applicant.class, new Integer(applicant.getId()));

		/* check the length of the resume name */
		if (!(applicant.getAttachedResumeName().length() > 0)) {

			/* load the persisted Resume. */
			applicant.setAttachedResumeName(loadApplicant
					.getAttachedResumeName());
			applicant.setAttachedResume(loadApplicant.getAttachedResume());
			applicant
					.setResumeContentType(loadApplicant.getResumeContentType());
		}
	}

	/**
	 * This method is used to apply for a job for internal employee in IJP
	 * program.
	 * 
	 * @return status
	 */
	public String applyJob() {

		String status = null;
		Long count;
		List jobs;

		/* check applicant is logged in or not */
		if (applicant.getId() > 0) {

			/* query to check applicant is already applied for this job or not */
			if ((Long) vedaenterpriseDatabase.createQuery(
					" SELECT COUNT(*) FROM "
							+ DatabaseTables.JOB_APPLICATION_CLASS
							+ " JA WHERE JA.applicant = " + applicant.getId()
							+ " AND JA.job = " + job.getId()).uniqueResult() == 0) {

				/*
				 * initializing the object setting the field value for
				 * jobApplication object and persisting it into the database.
				 */
				// Task ID: 7104
				if(register().equals("success")){
				jobApplication = new JobApplication();
				jobApplication.setAppliedBy(currentUserMaster);
				jobApplication.setApplicantId(applicant);
				jobApplication.setAppliedDate(new Date());
				jobApplication.setJob(job);
				vedaenterpriseDatabase.save(jobApplication);

				/*
				 * faceMessages is used to display the message from the resource
				 * bundle property file.
				 */
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
						"applied", new Object[] { applicant.getEmail() });

				/*
				 * Log is used to display the information applicant is applied
				 * or not.
				 */
				log.info(" Successfully applied ");
				status = Constants.NAVIGATION_STATUS_SUCCESS;
				}else{
					
					status = Constants.NAVIGATION_STATUS_FAILURE;
				}
			} else {
				facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
						"alreadyApplied",
						new Object[] { applicant.getEmail() });
				status = Constants.NAVIGATION_STATUS_FAILURE;
			}
		} else {

			/*
			 * faceMessages is used to display the message from the resource
			 * bundle property file.
			 */
			facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
					"login");

			/*
			 * Log is used to display the information applicant is logged in or
			 * not.
			 */
			log.info(" You are not loged in, first login they access jobs. ");
			status = Constants.NAVIGATION_STATUS_FAILURE;
		}
		jobApplication = null;
		return status;
	}

	/**
	 * This method is used to show the image at the time of edit only.
	 * 
	 * @return Returns the visible.
	 */
	public boolean isVisible() {
		return applicant.getAttachedResume() == null ? false : true;
	}

	/**
	 * This method is used to download the resume of the applicant.
	 * 
	 * @return
	 */
	public void downloadFileContent() {

		/* access downloadFileContent() method from util class */
		Util.downloadFileContent(FacesContext.getCurrentInstance(), applicant
				.getAttachedResume(), applicant.getAttachedResumeName(),
				applicant.getResumeContentType());
	}

	/**
	 * This method is used for navigation purpose.
	 * 
	 * @return status
	 */
	public String updateRegister() {

		/*
		 * get the employee object to display employee information at the update
		 * time
		 */
		update = true;
		apply = false;
		isFromERPUpdate = true;
		employee = applicant.getEmployee();
		this.confirmPassword = applicant.getPassword();
		
		return Constants.NAVIGATION_STATUS_SUCCESS;
	}

	/**
	 * This method is method is used for navigation purpose.
	 * 
	 * @return status
	 */
	public String flushRegister() {
		confirmPassword = null;
		isFromERPUpdate = true;
		return Constants.NAVIGATION_STATUS_SUCCESS;
	}

	

	/**
	 * This method is used to set the current date to display on the referral
	 * page.
	 * 
	 * @return
	 */
	public String accessJobToApply() {

		String status = null;

		/* get the employee object to display employee information */
		if (applicant.getId() != 0) {
			apply = true;
			update = false;
			isFromERPUpdate = false;
			this.employee = applicant.getEmployee();
			this.confirmPassword = applicant.getPassword();
			applicant.setEmployee(employee);
			this.applicant = (Applicant) vedaenterpriseDatabase
					.merge(applicant);
			status = Constants.NAVIGATION_STATUS_ACCESS_JOB_TO_APPLY;
		} else {

			/*
			 * faceMessages is used to display the message from the resource
			 * bundle property file.
			 */
			apply = false;
			facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
					"login");

			/*
			 * Log is used to display the information applicant is logged in or
			 * not.
			 */
			log.info(" You are not loged in, first login they access jobs. ");
			status = Constants.NAVIGATION_STATUS_RETURN_ERP_HOME;
		}
		return status;
	}

	/**
	 * This method is used to go back to the home page.
	 * 
	 * @return status
	 */
	public String cancel() {
		if (isFromERPUpdate) {
			isFromERPHome = false;
			return Constants.NAVIGATION_STATUS_CANCEL;
		} else {
			return Constants.NAVIGATION_STATUS_CANCEL_TO_JOB;
		}
	}

	/**
	 * This method is used to go back to the home page.
	 * 
	 * @return
	 */
	public String returnHome() {
	  this.job = null;

	  	if(isFromERPHome){
	  		isFromERPHome = false;
			return Constants.NAVIGATION_STATUS_RETURN_ERP_HOME;
		}
	  	
		/* check applicant id job application id is 0 or not */
		if (applicant.getId() != 0 && jobApplication.getId() != 0) {
			this.jobApplication = null;
			return Constants.NAVIGATION_STATUS_RETURN_TO_APPLIED_JOB;
		} else{
			return Constants.NAVIGATION_STATUS_RETURN;
		}
	}

	/**
	 * This method is used to merge the job object and navigation
	 * 
	 * @return
	 */
	public String jobDetail(Job hotJob) {
		isFromERPHome = true;
		this.job = (Job) vedaenterpriseDatabase.merge(hotJob);
		return Constants.NAVIGATION_STATUS_SEARCH_SUCCESS;
	}

	/**
	 * @return Returns the confirmPassword.
	 */
	public String getConfirmPassword() {
		return confirmPassword;
	}

	/**
	 * @param confirmPassword
	 *            The confirmPassword to set.
	 */
	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	/**
	 * @return Returns the selectedHighestQualification.
	 */
	public int getSelectedHighestQualification() {

		/* check employee is logged in or not */
		if (employee.getId() != 0 && employee.getHighestQualification() != null) {
			return employee.getHighestQualification().getId();
		} else {
			return selectedHighestQualification;
		}
	}

	/**
	 * @param selectedHighestQualification
	 *            The selectedHighestQualification to set.
	 */
	public void setSelectedHighestQualification(int selectedHighestQualification) {

		DictionaryValue highestQualificationdictionaryValue;

		/* set the dictionary value id */
		highestQualificationdictionaryValue = new DictionaryValue();
		highestQualificationdictionaryValue.setId(selectedHighestQualification);
		employee.setHighestQualification(highestQualificationdictionaryValue);
		this.selectedHighestQualification = selectedHighestQualification;
	}

	/**
	 * @return Returns the selectedDivision.
	 */
	public int getSelectedDivision() {

		/* check employee is logged in or not */
		if (employee.getId() != 0 && employee.getDivision() != null) {
			return employee.getDivision().getId();
		} else {
			return selectedDivision;
		}
	}

	/**
	 * @param selectedDivision
	 *            The selectedDivision to set.
	 */
	public void setSelectedDivision(int selectedDivision) {

		DictionaryValue divisionDictionaryValue;

		/* set the dictionary value id */
		divisionDictionaryValue = new DictionaryValue();
		divisionDictionaryValue.setId(selectedDivision);
		employee.setDivision(divisionDictionaryValue);
		this.selectedDivision = selectedDivision;
	}

	/**
	 * @return Returns the selectedDurationMonth.
	 */
	public int getSelectedDurationMonth() {

		/* check employee is logged in or not */
		if (employee.getId() != 0 && employee.getTotalDurationMonth() != null) {
			return employee.getTotalDurationMonth().getId();
		} else {
			return selectedDurationMonth;
		}
	}

	/**
	 * @param selectedDurationMonth
	 *            The selectedDurationMonth to set.
	 */
	public void setSelectedDurationMonth(int selectedDurationMonth) {

		/* creating the dictionaryValue object to set the dictionary value */
		DictionaryValue durationMonthDictionaryValue;

		/*
		 * check dictionaryValue is 0 or not if (selectedDurationMonth == 0) {
		 * employee.setTotalDurationMonth(null); } else {
		 * 
		 * set the dictionary value id durationMonthDictionaryValue = new
		 * DictionaryValue();
		 * durationMonthDictionaryValue.setId(selectedDurationMonth);
		 * employee.setTotalDurationMonth(durationMonthDictionaryValue); } }
		 */

		if (selectedDurationMonth > 0) {
			durationMonthDictionaryValue = (DictionaryValue) vedaenterpriseDatabase
					.get(DictionaryValue.class, selectedDurationMonth);
			if (durationMonthDictionaryValue != null) {
				employee.setTotalDurationMonth(durationMonthDictionaryValue);
			} else {
				facesMessages.instance().addFromResourceBundle(
						FacesMessage.SEVERITY_INFO, "norecord");
				log.error("could not set: Record may be deleted");
			}
		}
		this.selectedDurationMonth = selectedDurationMonth;

	}

	/**
	 * @return Returns the selectedDurationYear.
	 */
	public int getSelectedDurationYear() {

		/* check employee is logged in or not */
		if (employee.getId() != 0 && employee.getTotalDurationYear() != null) {
			return employee.getTotalDurationYear().getId();
		} else {
			return selectedDurationYear;
		}
	}

	/**
	 * @param selectedDurationYear
	 *            The selectedDurationYear to set.
	 */
	public void setSelectedDurationYear(int selectedDurationYear) {

		/* creating the dictionaryValue object to set the dictionary value */
		DictionaryValue durationYearDictionaryValue;

		/*
		 * check dictionaryValue is 0 or not if (selectedDurationYear == 0) {
		 * employee.setTotalDurationYear(null); } else {
		 * 
		 * set the dictionary value id durationYearDictionaryValue = new
		 * DictionaryValue();
		 * durationYearDictionaryValue.setId(selectedDurationYear);
		 * employee.setTotalDurationYear(durationYearDictionaryValue); } }
		 */

		if (selectedDurationYear > 0) {
			durationYearDictionaryValue = (DictionaryValue) vedaenterpriseDatabase
					.get(DictionaryValue.class, selectedDurationYear);
			if (durationYearDictionaryValue != null) {
				employee.setTotalDurationYear(durationYearDictionaryValue);
			} else {
				facesMessages.instance().addFromResourceBundle(
						FacesMessage.SEVERITY_INFO, "norecord");
				log.error("could not set: Record may be deleted");
			}
		}
		this.selectedDurationYear = selectedDurationYear;

	}

	/**
	 * @return Returns the selectedExpMo

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4097393#4097393

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4097393




More information about the jboss-user mailing list