suggestion box not working
fifijsf Feb 19, 2009 11:17 PM3 suggestionbox in pop-up panel, after select the option, it would become a icon. The problem is the second suggestionbox only work if selection box have 1 or more options. It didn't show the selection box if it dun contain any options. Any mistake i have made or it is a bug??
<rich:modalPanel id="chgPosition_PopUp" moveable="true" resizeable="false" width="462"
height="280" headerClass="popupheader" autosized="true">
<f:facet name="header">
#{sbBundle.employee_changePosition}
</f:facet>
<f:facet name="controls">
<h:panelGroup id="employeeInformationPopUp_ID_69" >
<h:form id="changePosition_header">
<a4j:commandLink
action="#{autocomplete.reset_chgPosition_PopUp_department}"
id="employeeInformationPopUp_chgPosition_PopUp_closeLink">
<h:graphicImage value="../images/icons/panelClose.png" styleClass="graphic_no_border"
id="employeeInformationPopUp_chgPosition_PopUp_closeIcon"></h:graphicImage>
</a4j:commandLink>
<rich:componentControl id="employeeInformationPopUp_ID_70" for="chgPosition_PopUp"
attachTo="employeeInformationPopUp_chgPosition_PopUp_closeLink" operation="hide"
event="onclick" />
</h:form>
</h:panelGroup>
</f:facet>
<h:form id="changePosition">
#{sbBundle.employee_currentPosition}
<h:outputText id="employeeInformationPopUp_ID_71" value="Merchandiser"
styleClass="popupreadonly" />
<a4j:outputPanel id="employeeInformationPopUp_ID_72"
layout="block" styleClass="cleardiv"></a4j:outputPanel> <a4j:outputPanel
layout="block" styleClass="popuptitle">
<h:outputText id="employeeInformationPopUp_ID_73"
value="#{sbBundle.employee_reason}" />
</a4j:outputPanel>
#{sbBundle.employee_changeReason}
<h:selectOneMenu id="employeeInformationPopUp_ID_74" value=""
styleClass="popupdropdownbox">
<f:selectItems id="employeeInformationPopUp_ID_75"
value="#{employeeInformationPopupController.chgPositionReasonItems}" />
</h:selectOneMenu>
<a4j:outputPanel id="employeeInformationPopUp_ID_76" layout="block"
styleClass="cleardiv"></a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_77" layout="block" styleClass="cleardiv"></a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_78" layout="block" styleClass="popuptitle">
<h:outputText id="employeeInformationPopUp_ID_79"
value="#{sbBundle.employee_newPosition}" />
</a4j:outputPanel>
#{sbBundle.employee_officeCode}
<h:selectOneMenu id="employeeInformationPopUp_ID_80" value="" styleClass="popupdropdownbox">
<f:selectItems id="employeeInformationPopUp_ID_81"
value="#{employeeInformationPopupController.officeSelectItems}" />
</h:selectOneMenu>
<a4j:outputPanel layout="block" styleClass="entry" id="employeeInformationPopUp_chgPosition_PopUp_department">
<a4j:outputPanel id="employeeInformationPopUp_ID_82" layout="block" styleClass="popuplabel">
#{sbBundle.employee_department}
</a4j:outputPanel>
<a4j:outputPanel layout="block" style="display:inline" id="employeeInformationPopUp_chgPosition_PopUp_department_output_block">
<h:inputText id="employeeInformationPopUp_chgPosition_PopUp_department_entry"
name="Fname2" value="#{autocomplete.inputText}"
styleClass="popinputbox" rendered="#{autocomplete.chgPosition_PopUp_department_input_show}">
<a4j:support id="employeeInformationPopUp_ID_83" event="onclick" reRender="employeeInformationPopUp_chgPosition_PopUp_department_suggestionBox"></a4j:support>
</h:inputText>
<h:outputText id="employeeInformationPopUp_ID_84"
value="#{autocomplete.selectedDepartment.departmentName}"
rendered="#{autocomplete.chgPosition_PopUp_department_label_show}"/>
<a4j:commandLink id="employeeInformationPopUp_ID_85"
reRender="employeeInformationPopUp_chgPosition_PopUp_department_output_block"
action="#{autocomplete.reset_chgPosition_PopUp_department}"
styleClass="abuttons_with_cross_text_right">
<rich:spacer id="employeeInformationPopUp_ID_86" width="1" style="border:0px" rendered="#{autocomplete.chgPosition_PopUp_department_label_show}"></rich:spacer>
<h:graphicImage id="employeeInformationPopUp_ID_87" style="border:0px" rendered="#{autocomplete.chgPosition_PopUp_department_label_show}"
value="../images/icons/cross.gif" alt="#{sbBundle.common_remove}" title="#{sbBundle.common_remove}"/>
</a4j:commandLink>
</a4j:outputPanel>
<rich:suggestionbox
id="employeeInformationPopUp_chgPosition_PopUp_department_suggestionBox"
for="employeeInformationPopUp_chgPosition_PopUp_department_entry"
width="290"
height="150"
suggestionAction="#{autocomplete.departmentautocomplete}"
var="result"
nothingLabel="#{sbBundle.common_message_noMatch}"
>
<h:column id="employeeInformationPopUp_ID_88" >
<h:outputText id="employeeInformationPopUp_ID_89"
value="#{result.departmentName}" style="width:50px" />
</h:column>
<a4j:support id="employeeInformationPopUp_ID_90" event="onselect" reRender="employeeInformationPopUp_chgPosition_PopUp_department_output_block">
<f:setPropertyActionListener value="#{result}" target="#{autocomplete.selectedDepartment}" />
<f:setPropertyActionListener value="#{uiBoolean.falseValue}" target="#{autocomplete.chgPosition_PopUp_department_input_show}" />
<f:setPropertyActionListener value="#{uiBoolean.trueValue}" target="#{autocomplete.chgPosition_PopUp_department_label_show}" />
<f:setPropertyActionListener value="#{result.departmentId}" target="#{employeeSearch.chgPosition_PopUp_EmploymentHistory.departmentId}" />
</a4j:support>
</rich:suggestionbox>
</a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_91" layout="block" styleClass="cleardiv"></a4j:outputPanel>
<a4j:outputPanel layout="block" styleClass="entry" id="employeeInformationPopUp_chgPosition_PopUp_jobTitle">
<a4j:outputPanel id="employeeInformationPopUp_ID_92" layout="block" styleClass="popuplabel">
#{sbBundle.employee_jobTitle}
</a4j:outputPanel>
<a4j:outputPanel layout="block" style="display:inline" id="employeeInformationPopUp_chgPosition_PopUp_jobTitle_output_block">
<h:inputText id="employeeInformationPopUp_chgPosition_PopUp_jobTitle_entry"
name="Fname2" value="#{autocomplete.jobTitleInputText}"
styleClass="popinputbox" rendered="#{autocomplete.chgPositionPopUpJobTitleInputShow}">
<a4j:support id="employeeInformationPopUp_ID_93" event="onclick" reRender="employeeInformationPopUp_chgPosition_PopUp_jobTitle_suggestionBox"></a4j:support>
</h:inputText>
<h:outputText id="employeeInformationPopUp_ID_94"
value="#{autocomplete.selectedJobTitle.titleName}"
rendered="#{autocomplete.chgPositionPopUpJobTitleLabelShow}"/>
<a4j:commandLink id="employeeInformationPopUp_ID_95"
reRender="employeeInformationPopUp_chgPosition_PopUp_jobTitle_output_block"
action="#{autocomplete.resetChgPositionPopUpJobTitle}"
styleClass="abuttons_with_cross_text_right">
<rich:spacer id="employeeInformationPopUp_ID_96" width="1" style="border:0px" rendered="#{autocomplete.chgPositionPopUpJobTitleLabelShow}"></rich:spacer>
<h:graphicImage id="employeeInformationPopUp_ID_97" style="border:0px" rendered="#{autocomplete.chgPositionPopUpJobTitleLabelShow}"
value="../images/icons/cross.gif" alt="#{sbBundle.common_remove}" title="#{sbBundle.common_remove}"/>
</a4j:commandLink>
</a4j:outputPanel>
<rich:suggestionbox
id="employeeInformationPopUp_chgPosition_PopUp_jobTitle_suggestionBox"
for="employeeInformationPopUp_chgPosition_PopUp_jobTitle_entry"
width="290"
height="150"
suggestionAction="#{autocomplete.jobTitleAutoComplete}"
var="result"
nothingLabel="#{sbBundle.common_message_noMatch}"
selfRendered="true"
reRender="employeeInformationPopUp_chgPosition_PopUp_jobTitle_suggestionBox">
<h:column id="employeeInformationPopUp_ID_98" >
<h:outputText id="employeeInformationPopUp_ID_99"
value="#{result.titleName}" style="width:50px" />
</h:column>
<a4j:support id="employeeInformationPopUp_ID_100" event="onselect" reRender="employeeInformationPopUp_chgPosition_PopUp_jobTitle_suggestionBox, employeeInformationPopUp_chgPosition_PopUp_jobTitle_output_block">
<f:setPropertyActionListener value="#{result}" target="#{autocomplete.selectedJobTitle}" />
<f:setPropertyActionListener value="#{uiBoolean.falseValue}" target="#{autocomplete.chgPositionPopUpJobTitleInputShow}" />
<f:setPropertyActionListener value="#{uiBoolean.trueValue}" target="#{autocomplete.chgPositionPopUpJobTitleLabelShow}" />
<f:setPropertyActionListener value="#{result.titleId}" target="#{employeeSearch.chgPosition_PopUp_EmploymentHistory.titleId}" />
</a4j:support>
</rich:suggestionbox>
</a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_101" layout="block" styleClass="cleardiv"></a4j:outputPanel>
<a4j:outputPanel layout="block" styleClass="entry" id="employeeInformationPopUp_chgPosition_PopUp_reportTo">
<a4j:outputPanel id="employeeInformationPopUp_ID_102" layout="block" styleClass="popuplabel">
#{sbBundle.employee_reportTo}
</a4j:outputPanel>
<a4j:outputPanel layout="block" style="display:inline" id="employeeInformationPopUp_chgPosition_PopUp_reportTo_output_block">
<h:inputText id="employeeInformationPopUp_chgPosition_PopUp_reportTo_entry"
name="Fname2" value="#{autocomplete.reportToInputText}"
styleClass="popinputbox" rendered="true">
<!-- #{autocomplete.addPositionPopUpReportToInputShow} -->
<a4j:support id="employeeInformationPopUp_ID_103"
event="onclick"
reRender="employeeInformationPopUp_chgPosition_PopUp_reportTo_suggestionBox"></a4j:support>
</h:inputText>
</a4j:outputPanel>
<rich:suggestionbox
id="employeeInformationPopUp_chgPosition_PopUp_reportTo_suggestionBox"
for="employeeInformationPopUp_chgPosition_PopUp_reportTo_entry"
width="290"
height="150"
suggestionAction="#{autocomplete.reporttoautocomplete}"
var="result"
nothingLabel="#{sbBundle.common_message_noMatch}"
>
<h:column id="employeeInformationPopUp_ID_104" >
<h:outputText id="employeeInformationPopUp_ID_105"
value="#{result.loginId} (#{result.position} - #{result.department} - #{result.employeePositionId})"
style="width:50px" />
</h:column>
<a4j:support id="employeeInformationPopUp_ID_106" event="onselect" reRender="employeeInformationPopUp_chgPosition_PopUp_reportTo_output_block, employeeInformationPopUp_chgPosition_PopUp_reportTo_output_List_block">
<f:setPropertyActionListener value="#{result}" target="#{autocomplete.selectedReportTo}" />
<f:setPropertyActionListener value="#{uiBoolean.falseValue}" target="#{autocomplete.chgPositionPopUpReportToInputShow}" />
<f:setPropertyActionListener value="#{uiBoolean.trueValue}" target="#{autocomplete.chgPositionPopUpReportToLabelShow}" />
<f:setPropertyActionListener value="#{autocomplete.selectedReportToList}" target="#{employeeSearch.chgPosition_PopUp_EmploymentHistory.reportToList}" />
</a4j:support>
</rich:suggestionbox>
</a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_107" layout="block" styleClass="cleardiv"></a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_108" layout="block" styleClass="entry" >
<a4j:outputPanel layout="block" id="employeeInformationPopUp_chgPosition_PopUp_reportTo_output_List_block">
<a4j:repeat id="employeeInformationPopUp_ID_109" var="reportToIndex" value="#{autocomplete.selectedReportToList}">
<a4j:outputPanel id="employeeInformationPopUp_ID_110" layout="block" styleClass="popupemptylabel">
</a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_111" layout="block" styleClass="autoCompleteIconDiv">
<h:outputText id="employeeInformationPopUp_ID_112"
value="#{reportToIndex.loginId} - #{reportToIndex.department} #{reportToIndex.employeePositionId}"
rendered="#{autocomplete.chgPositionPopUpReportToLabelShow}"/>
<a4j:commandLink id="employeeInformationPopUp_ID_113"
reRender="employeeInformationPopUp_chgPosition_PopUp_reportTo_output_block, employeeInformationPopUp_chgPosition_PopUp_reportTo_output_List_block"
action="#{autocomplete.removeAddPositionPopUpReportTo}"
styleClass="abuttons_with_cross_text_right">
<f:setPropertyActionListener value="#{reportToIndex}" target="#{autocomplete.currentRemoveReportTo}" />
<rich:spacer id="employeeInformationPopUp_ID_114" width="1" style="border:0px" rendered="#{autocomplete.chgPositionPopUpReportToLabelShow}"></rich:spacer>
<h:graphicImage id="employeeInformationPopUp_ID_115" style="border:0px" rendered="#{autocomplete.chgPositionPopUpReportToLabelShow}"
value="../images/icons/cross.gif" alt="#{sbBundle.common_remove}" title="#{sbBundle.common_remove}"/>
</a4j:commandLink>
</a4j:outputPanel>
</a4j:repeat>
</a4j:outputPanel>
</a4j:outputPanel>
<a4j:outputPanel id="employeeInformationPopUp_ID_116" layout="block" styleClass="cleardiv"></a4j:outputPanel>
#{sbBundle.employee_positionType}
<h:selectOneMenu id="employeeInformationPopUp_ID_117" value="" styleClass="popupdropdownbox">
<f:selectItems id="employeeInformationPopUp_ID_118"
value="#{employeeInformationPopupController.positionTypeItems}" />
</h:selectOneMenu>
#{sbBundle.employee_effectiveFrom}
<a4j:outputPanel id="employeeInformationPopUp_ID_119" layout="inline"
styleClass="staffbank_general_calendar">
<rich:calendar id="employeeInformationPopUp_ID_120" value="" verticalOffset="1"
horizontalOffset="26" todayControlMode="select" locale="en" popup="true"
datePattern="MMM d, yyyy" enableManualInput="false"
buttonIcon="../images/icons/calendar.gif" buttonClass="icon"
label="popupeffectiveFrom" inputClass="popupcalendarinput"
showApplyButton="false" cellWidth="24px" cellHeight="10px">
<f:facet name="footer">
<h:panelGrid id="employeeInformationPopUp_ID_121" columns="5" width="100%"
styleClass="richfaces_calendar_footer"
columnClasses="richfaces_calendar_footer_selectedDate, richfaces_calendar_footer_column, richfaces_calendar_footer_separator, richfaces_calendar_footer_today">
<h:outputText id="employeeInformationPopUp_ID_122"
value="{selectedDateControl}" />
<h:outputText id="employeeInformationPopUp_ID_123" value="{cleanControl}" />
<h:graphicImage id="employeeInformationPopUp_ID_124"
value="../images/separator.gif" style="width:1px;" />
<h:outputText id="employeeInformationPopUp_ID_125" value="{todayControl}" />
</h:panelGrid>
</f:facet>
</rich:calendar>
</a4j:outputPanel>
#{sbBundle.employee_primaryPosition}
<h:selectBooleanCheckbox id="employeeInformationPopUp_ID_126"
value="#{employeeInformationPopupController.primaryPosition}"
styleClass="popupcheckbox" />Â
<a4j:outputPanel id="employeeInformationPopUp_ID_127" layout="block" styleClass="cleardiv"></a4j:outputPanel>
#{sbBundle.common_publishImmediately}
<h:selectBooleanCheckbox
value="#{employeeInformationPopupController.publishImmediately}"
styleClass="popupcheckbox" id="publishDate" immediate="true">
<a4j:support id="employeeInformationPopUp_ID_128" event="onclick"
reRender="publish_date_area, time_zone_area" />
</h:selectBooleanCheckbox>
<a4j:outputPanel layout="block" id="time_zone_area">
<a4j:outputPanel layout="block" styleClass="entry" id="publish_date"
rendered="#{employeeInformationPopupController.publishdateDisplay}">
#{sbBundle.common_publishDate}
<a4j:outputPanel id="employeeInformationPopUp_ID_129" layout="inline"
styleClass="staffbank_general_calendar">
<rich:calendar id="employeeInformationPopUp_ID_130" value=""
verticalOffset="1" horizontalOffset="26" todayControlMode="select"
locale="en" popup="true" datePattern="MMM d, yyyy"
enableManualInput="false" buttonIcon="../images/icons/calendar.gif"
buttonClass="icon" label="popupeffectiveFrom"
inputClass="popupcalendarinput" showApplyButton="false" cellWidth="24px"
cellHeight="10px">
<f:facet name="footer">
<h:panelGrid id="employeeInformationPopUp_ID_131" columns="5"
width="100%" styleClass="richfaces_calendar_footer"
columnClasses="richfaces_calendar_footer_selectedDate, richfaces_calendar_footer_column, richfaces_calendar_footer_separator, richfaces_calendar_footer_today">
<h:outputText id="employeeInformationPopUp_ID_132"
value="{selectedDateControl}" />
<h:outputText id="employeeInformationPopUp_ID_133"
value="{cleanControl}" />
<h:graphicImage id="employeeInformationPopUp_ID_134"
value="../images/separator.gif" style="width:1px;" />
<h:outputText id="employeeInformationPopUp_ID_135"
value="{todayControl}" />
</h:panelGrid>
</f:facet>
</rich:calendar>
</a4j:outputPanel>
</a4j:outputPanel>
</a4j:outputPanel> <a4j:outputPanel layout="block" id="publish_date_area">
<a4j:outputPanel layout="block" styleClass="entry" id="time_zone"
rendered="#{employeeInformationPopupController.timezoneDisplay}">
#{sbBundle.common_timeZone}
<h:selectOneMenu id="employeeInformationPopUp_ID_136" value=""
styleClass="popupdropdownbox">
<f:selectItems id="employeeInformationPopUp_ID_137"
value="#{employeeInformationPopupController.timeZoneItems}" />
</h:selectOneMenu>
</a4j:outputPanel>
</a4j:outputPanel>
#{sbBundle.common_emailNotification}
<h:selectBooleanCheckbox id="employeeInformationPopUp_ID_138"
value="#{employeeInformationPopupController.emailNotification}"
styleClass="popupcheckboxlastsmall" /> <a4j:commandLink id="employeeInformationPopUp_ID_139" styleClass="popuphelp"
oncomplete="#{rich:component('helpPanel')}.show();nonModal('helpPanel');"
reRender="helpPanel">
<h:graphicImage id="employeeInformationPopUp_ID_140"
value="../images/icons/help_icon.gif" alt="#{sbBundle.common_help}"
title="#{sbBundle.common_help}" style="border:0px" />
</a4j:commandLink>
<a4j:commandLink id="employeeInformationPopUp_ID_141" styleClass="buttons">
<h:outputText id="employeeInformationPopUp_ID_142"
value="#{sbBundle.common_applyChanges}" styleClass="abuttons_text" />
</a4j:commandLink> <a4j:commandLink id="employeeInformationPopUp_ID_143" styleClass="buttons">
<h:outputText id="employeeInformationPopUp_ID_144" value="#{sbBundle.common_reset}"
styleClass="abuttons_text" />
</a4j:commandLink> <a4j:commandLink styleClass="buttons" action="#{autocomplete.reset_chgPosition_PopUp_department}"
id="employeeInformationPopUp_chgPosition_PopUp_close">
<h:outputText id="employeeInformationPopUp_ID_145" value="#{sbBundle.common_cancel}"
styleClass="abuttons_text" />
</a4j:commandLink> <rich:componentControl id="employeeInformationPopUp_ID_146" for="chgPosition_PopUp"
attachTo="employeeInformationPopUp_chgPosition_PopUp_close" operation="hide"
event="onclick" />
</h:form>
</rich:modalPanel>
The mbean
package com.ottoint.staffbank.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import org.hibernate.Query;
import org.hibernate.Session;
import com.ottoint.staffbank.action.BaseAction;
import com.ottoint.staffbank.business.UICountryCode;
import com.ottoint.staffbank.business.UIEmployeeSimple;
import com.ottoint.staffbank.constant.EmployeeConstants;
import com.ottoint.staffbank.hibernate.vo.Employee;
import com.ottoint.staffbank.hibernate.vo.EmploymentHistory;
import com.ottoint.staffbank.hibernate.vo.StandardDepartmentInfo;
import com.ottoint.staffbank.hibernate.vo.StandardTitleInfo;
import com.ottoint.staffbank.i18n.CountryCodeResourceUtil;
public class AutoComplete extends BaseAction {
private Session session;
private List uiCountryCodeList = new ArrayList();
/*************************************Report To AutoComplete START*************************************/
private String reportToInputText;
private UIEmployeeSimple selectedReportTo;
private UIEmployeeSimple currentRemoveReportTo;
private List selectedReportToList = new ArrayList();
private List uiEmployeeSimpleList = new ArrayList();
private boolean addPositionPopUpReportToLabelShow = false;
private boolean addPositionPopUpReportToInputShow = true;
private boolean chgPositionPopUpReportToLabelShow = false;
private boolean chgPositionPopUpReportToInputShow = true;
private boolean reactEmpPopUpReportToLabelShow = false;
private boolean reactEmpPopUpReportToInputShow = true;
/*************************************Report To AutoComplete END*************************************/
/*************************************Department AutoComplete START*************************************/
private String inputText;
private StandardDepartmentInfo selectedDepartment;
private ListdepartmentList = new ArrayList();
private boolean addPosition_PopUp_department_label_show = false;
private boolean addPosition_PopUp_department_input_show = true;
private boolean chgPosition_PopUp_department_label_show = false;
private boolean chgPosition_PopUp_department_input_show = true;
private boolean reactEmp_PopUp_department_label_show = false;
private boolean reactEmp_PopUp_department_input_show = true;
/*************************************Department AutoComplete END*************************************/
/*************************************JobTitle AutoComplete START*************************************/
private String jobTitleInputText;
private StandardTitleInfo selectedJobTitle;
private ListjobTitleList = new ArrayList();
private boolean addPositionPopUpJobTitleLabelShow = false;
private boolean addPositionPopUpJobTitleInputShow = true;
private boolean chgPositionPopUpJobTitleLabelShow = false;
private boolean chgPositionPopUpJobTitleInputShow = true;
private boolean reactEmpPopUpJobTitleLabelShow = false;
private boolean reactEmpPopUpJobTitleInputShow = true;
/*************************************Job Title AutoComplete END*************************************/
public String getInputText() {
return inputText;
}
public void setInputText(String inputText) {
this.inputText = inputText;
}
public String getJobTitleInputText() {
return jobTitleInputText;
}
public void setJobTitleInputText(String jobTitleInputText) {
this.jobTitleInputText = jobTitleInputText;
}
public void generateCountryCodeList() {
uiCountryCodeList = CountryCodeResourceUtil.getUICountryCodeList();
}
public List countryCodeAutoComplete(Object suggest) {
generateCountryCodeList();
String pref = (String)suggest;
ArrayList result = new ArrayList();
Iterator iterator = uiCountryCodeList.iterator();
while (iterator.hasNext()) {
UICountryCode elem = iterator.next();
StringTokenizer st = new StringTokenizer(elem.getCountryCode()+ " " + elem.getCountryName(), " ");
while (st.hasMoreTokens()) {
String currentTokens = st.nextToken();
if ((currentTokens != null && currentTokens.toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
{
result.add(elem);
break;
}
}
}
return result;
}
/*************************************Report To AutoComplete START*************************************/
public void searchAllEmployee() {
// selectedEmployeeList.clear();
session = uiSession.getSessionFactory().openSession();
Query query = session
.createQuery("select employee from Employee employee where employee.firstName like '%"
+ ""
+ "%' and employee.status.statusName = '"
+ EmployeeConstants.CURRENT_EMPLOYEE
+ "' order by employee.firstName asc");
List employeeList = query.list();
if (employeeList == null) {
return;
} else if (employeeList.size() == 0) {
return;
}
uiEmployeeSimpleList = new ArrayList();
for (Iterator iterator = employeeList.iterator(); iterator
.hasNext();) {
Employee employee = iterator.next();
String firstName = employee.getFirstName();
String lastName = employee.getLastName();
String loginId = employee.getLoginId();
Set empHis = employee.getEmploymentHistories();
for (Iterator iterator2 = empHis.iterator(); iterator2.hasNext();) {
EmploymentHistory history = (EmploymentHistory) iterator2
.next();
if (null == history.getEndDate()) {
UIEmployeeSimple uiEmployeeSimple = new UIEmployeeSimple();
uiEmployeeSimple.setEmployeePositionId(history.getId().getEmployeeId().toString()
+ "_" + history.getId().getPositionId().toString());
uiEmployeeSimple.setFirstName(firstName);
uiEmployeeSimple.setLastName(lastName);
uiEmployeeSimple.setLoginId(loginId);
uiEmployeeSimple.setPosition(history.getJobPosition()
.getStandardTitleInfo().getTitleName());
uiEmployeeSimple.setDepartment(history.getJobPosition().getStandardDepartmentInfo().getDepartmentName());
List reportToList = new ArrayList();
uiEmployeeSimpleList.add(uiEmployeeSimple);
}
}
}
session.close();
}
public List reporttoautocomplete(Object suggest) {
searchAllEmployee();
String pref = (String)suggest;
ArrayList result = new ArrayList();
for (int j=0; j<selectedReportToList.size(); j++) {
UIEmployeeSimple uiEmployeeSimple = selectedReportToList.get(j);
for (int k=0; k<uiEmployeeSimpleList.size(); k++) {
UIEmployeeSimple selectedReportTo = uiEmployeeSimpleList.get(k);
if (selectedReportTo.getEmployeePositionId().equals(uiEmployeeSimple.getEmployeePositionId())) {
uiEmployeeSimpleList.remove(k);
break;
}
}
}
Iterator iterator = uiEmployeeSimpleList.iterator();
while (iterator.hasNext()) {
UIEmployeeSimple elem = iterator.next();
StringTokenizer st = new StringTokenizer(elem.getLoginId(), ".");
while (st.hasMoreTokens()) {
String currentTokens = st.nextToken();
if ((currentTokens != null && currentTokens.toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
{
result.add(elem);
break;
}
}
}
return result;
}
public String getReportToInputText() {
return reportToInputText;
}
public void setReportToInputText(String reportToInputText) {
this.reportToInputText = reportToInputText;
}
public boolean isAddPositionPopUpReportToLabelShow() {
return addPositionPopUpReportToLabelShow;
}
public void setAddPositionPopUpReportToLabelShow(
boolean addPositionPopUpReportToLabelShow) {
this.addPositionPopUpReportToLabelShow = addPositionPopUpReportToLabelShow;
}
public boolean isAddPositionPopUpReportToInputShow() {
return addPositionPopUpReportToInputShow;
}
public void setAddPositionPopUpReportToInputShow(
boolean addPositionPopUpReportToInputShow) {
this.addPositionPopUpReportToInputShow = addPositionPopUpReportToInputShow;
this.reportToInputText = "";
}
public UIEmployeeSimple getSelectedReportTo() {
return selectedReportTo;
}
public void setSelectedReportTo(UIEmployeeSimple selectedReportTo) {
this.selectedReportTo = selectedReportTo;
System.out.println("selectedReportTo.getEmployeePositionId() " + selectedReportTo.getEmployeePositionId() + " " + selectedReportTo.getDepartment());
if (checkSelectedReportToExist(selectedReportTo) == -1) {//only add choice to list if it is not exist
selectedReportToList.add(selectedReportTo);
}
}
public List getSelectedReportToList() {
return selectedReportToList;
}
public void setSelectedReportToList(List selectedReportToList) {
this.selectedReportToList = selectedReportToList;
}
public UIEmployeeSimple getCurrentRemoveReportTo() {
return currentRemoveReportTo;
}
public void setCurrentRemoveReportTo(UIEmployeeSimple currentRemoveReportTo) {
this.currentRemoveReportTo = currentRemoveReportTo;
}
public int checkSelectedReportToExist (UIEmployeeSimple selectedReportTo) {
for (int j=0; j<selectedReportToList.size(); j++) {
UIEmployeeSimple uiEmployeeSimple = selectedReportToList.get(j);
if (uiEmployeeSimple.getEmployeePositionId().equals(selectedReportTo.getEmployeePositionId())) {
return j;
}
/*
if (uiEmployeeSimple.getLoginId().equals(selectedReportTo.getLoginId()) &&
uiEmployeeSimple.getPosition().equals(selectedReportTo.getPosition()) &&
uiEmployeeSimple.getDepartment().equals(selectedReportTo.getDepartment())) {
return j;
}
*/
}
return -1;
}
/*add position popup only*/
public void resetAddPositionPopUpReportTo() {
reportToInputText = "";
selectedReportToList.clear();
addPositionPopUpReportToInputShow = true;
addPositionPopUpReportToLabelShow = false;
}
public void resetChgPositionPopUpReportTo() {
reportToInputText = "";
selectedReportToList.clear();
chgPositionPopUpReportToInputShow = true;
chgPositionPopUpReportToLabelShow = false;
}
public void removeAddPositionPopUpReportTo() {
int selectedReportToListPosition = checkSelectedReportToExist(currentRemoveReportTo);
selectedReportToList.remove(selectedReportToListPosition);
}
public boolean isChgPositionPopUpReportToLabelShow() {
return chgPositionPopUpReportToLabelShow;
}
public void setChgPositionPopUpReportToLabelShow(
boolean chgPositionPopUpReportToLabelShow) {
this.chgPositionPopUpReportToLabelShow = chgPositionPopUpReportToLabelShow;
}
public boolean isChgPositionPopUpReportToInputShow() {
return chgPositionPopUpReportToInputShow;
}
public void setChgPositionPopUpReportToInputShow(
boolean chgPositionPopUpReportToInputShow) {
this.chgPositionPopUpReportToInputShow = chgPositionPopUpReportToInputShow;
this.reportToInputText = "";
}
public boolean isReactEmpPopUpReportToLabelShow() {
return reactEmpPopUpReportToLabelShow;
}
public void setReactEmpPopUpReportToLabelShow(
boolean reactEmpPopUpReportToLabelShow) {
this.reactEmpPopUpReportToLabelShow = reactEmpPopUpReportToLabelShow;
}
public boolean isReactEmpPopUpReportToInputShow() {
return reactEmpPopUpReportToInputShow;
}
public void setReactEmpPopUpReportToInputShow(
boolean reactEmpPopUpReportToInputShow) {
this.reactEmpPopUpReportToInputShow = reactEmpPopUpReportToInputShow;
}
/*************************************Report To AutoComplete END*************************************/
/*************************************Job Title AutoComplete START*************************************/
public void generateJobTitleList() {
session = uiSession.getSessionFactory().openSession();
Query query = session
.createQuery("select standardTitleInfo from StandardTitleInfo standardTitleInfo");
jobTitleList = query.list();
session.close();
}
public List jobTitleAutoComplete(Object suggest) {
generateJobTitleList();
String pref = (String)suggest;
ArrayList result = new ArrayList();
Iterator iterator = jobTitleList.iterator();
while (iterator.hasNext()) {
StandardTitleInfo elem = iterator.next();
StringTokenizer st = new StringTokenizer(elem.getTitleName(), " ");
while (st.hasMoreTokens()) {
String currentTokens = st.nextToken();
if ((currentTokens != null && currentTokens.toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
{
result.add(elem);
break;
}
}
}
return result;
}
public StandardTitleInfo getSelectedJobTitle() {
return selectedJobTitle;
}
public void setSelectedJobTitle(StandardTitleInfo selectedJobTitle) {
this.selectedJobTitle = selectedJobTitle;
}
public boolean isAddPositionPopUpJobTitleLabelShow() {
return addPositionPopUpJobTitleLabelShow;
}
public void setAddPositionPopUpJobTitleLabelShow(
boolean addPositionPopUpJobTitleLabelShow) {
this.addPositionPopUpJobTitleLabelShow = addPositionPopUpJobTitleLabelShow;
}
public boolean isAddPositionPopUpJobTitleInputShow() {
return addPositionPopUpJobTitleInputShow;
}
public void setAddPositionPopUpJobTitleInputShow(
boolean addPositionPopUpJobTitleInputShow) {
this.addPositionPopUpJobTitleInputShow = addPositionPopUpJobTitleInputShow;
}
public boolean isChgPositionPopUpJobTitleLabelShow() {
return chgPositionPopUpJobTitleLabelShow;
}
public void setChgPositionPopUpJobTitleLabelShow(
boolean chgPositionPopUpJobTitleLabelShow) {
this.chgPositionPopUpJobTitleLabelShow = chgPositionPopUpJobTitleLabelShow;
}
public boolean isChgPositionPopUpJobTitleInputShow() {
return chgPositionPopUpJobTitleInputShow;
}
public void setChgPositionPopUpJobTitleInputShow(
boolean chgPositionPopUpJobTitleInput_show) {
this.chgPositionPopUpJobTitleInputShow = chgPositionPopUpJobTitleInput_show;
}
public boolean isReactEmpPopUpJobTitleLabelShow() {
return reactEmpPopUpJobTitleLabelShow;
}
public void setReactEmpPopUpJobTitleLabelShow(
boolean reactEmpPopUpJobTitleLabelShow) {
this.reactEmpPopUpJobTitleLabelShow = reactEmpPopUpJobTitleLabelShow;
}
public boolean isReactEmpPopUpJobTitleInputShow() {
return reactEmpPopUpJobTitleInputShow;
}
public void setReactEmpPopUpJobTitleInputShow(
boolean reactEmpPopUpJobTitleInputShow) {
this.reactEmpPopUpJobTitleInputShow = reactEmpPopUpJobTitleInputShow;
}
/*add position popup only*/
public void resetAddPositionPopUpJobTitle() {
selectedJobTitle = null;
jobTitleInputText = "";
addPositionPopUpJobTitleInputShow = true;
addPositionPopUpJobTitleLabelShow = false;
}
/*chg position popup only*/
public void resetChgPositionPopUpJobTitle() {
selectedJobTitle = null;
jobTitleInputText = "";
chgPositionPopUpJobTitleInputShow = true;
chgPositionPopUpJobTitleLabelShow = false;
}
/*chg position popup only*/
public void resetReactEmpPopUpJobtitle() {
selectedJobTitle = null;
jobTitleInputText = "";
reactEmpPopUpJobTitleInputShow = true;
reactEmpPopUpJobTitleLabelShow = false;
}
/*************************************Job Title AutoComplete END*************************************/
/*************************************Department AutoComplete START*************************************/
public void generateDepartmentList() {
session = uiSession.getSessionFactory().openSession();
Query query = session
.createQuery("select standardDepartmentInfo from StandardDepartmentInfo standardDepartmentInfo");
departmentList = query.list();
session.close();
}
public List departmentautocomplete(Object suggest) {
generateDepartmentList();
String pref = (String)suggest;
ArrayList result = new ArrayList();
Iterator iterator = departmentList.iterator();
while (iterator.hasNext()) {
StandardDepartmentInfo elem = iterator.next();
StringTokenizer st = new StringTokenizer(elem.getDepartmentName(), " ");
while (st.hasMoreTokens()) {
String currentTokens = st.nextToken();
if ((currentTokens != null && currentTokens.toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
{
result.add(elem);
break;
}
}
}
return result;
}
public StandardDepartmentInfo getSelectedDepartment() {
return selectedDepartment;
}
public void setSelectedDepartment(StandardDepartmentInfo selectedDepartment) {
this.selectedDepartment = selectedDepartment;
}
public boolean isAddPosition_PopUp_department_label_show() {
return addPosition_PopUp_department_label_show;
}
public void setAddPosition_PopUp_department_label_show(
boolean addPosition_PopUp_department_label_show) {
this.addPosition_PopUp_department_label_show = addPosition_PopUp_department_label_show;
}
public boolean isAddPosition_PopUp_department_input_show() {
return addPosition_PopUp_department_input_show;
}
public void setAddPosition_PopUp_department_input_show(
boolean addPosition_PopUp_department_input_show) {
this.addPosition_PopUp_department_input_show = addPosition_PopUp_department_input_show;
}
public boolean isChgPosition_PopUp_department_label_show() {
return chgPosition_PopUp_department_label_show;
}
public void setChgPosition_PopUp_department_label_show(
boolean chgPosition_PopUp_department_label_show) {
this.chgPosition_PopUp_department_label_show = chgPosition_PopUp_department_label_show;
}
public boolean isChgPosition_PopUp_department_input_show() {
return chgPosition_PopUp_department_input_show;
}
public void setChgPosition_PopUp_department_input_show(
boolean chgPosition_PopUp_department_input_show) {
this.chgPosition_PopUp_department_input_show = chgPosition_PopUp_department_input_show;
}
public boolean isReactEmp_PopUp_department_input_show() {
return reactEmp_PopUp_department_input_show;
}
public void setReactEmp_PopUp_department_input_show(
boolean reactEmp_PopUp_department_input_show) {
this.reactEmp_PopUp_department_input_show = reactEmp_PopUp_department_input_show;
}
public boolean isReactEmp_PopUp_department_label_show() {
return reactEmp_PopUp_department_label_show;
}
public void setReactEmp_PopUp_department_label_show(
boolean reactEmp_PopUp_department_label_show) {
this.reactEmp_PopUp_department_label_show = reactEmp_PopUp_department_label_show;
}
/*add position popup only*/
public void reset_addPosition_PopUp_department() {
resetAddPositionPopUpJobTitle();
resetAddPositionPopUpReportTo();
selectedDepartment = null;
inputText = "";
addPosition_PopUp_department_input_show = true;
addPosition_PopUp_department_label_show = false;
}
/*chg position popup only*/
public void reset_chgPosition_PopUp_department() {
resetChgPositionPopUpJobTitle();
resetChgPositionPopUpReportTo();
selectedDepartment = null;
inputText = "";
chgPosition_PopUp_department_input_show = true;
chgPosition_PopUp_department_label_show = false;
}
/*chg position popup only*/
public void reset_reactEmp_PopUp_department() {
resetReactEmpPopUpJobtitle();
selectedDepartment = null;
inputText = "";
reactEmp_PopUp_department_input_show = true;
reactEmp_PopUp_department_label_show = false;
}
/*************************************Department AutoComplete END*************************************/
}