Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Hashmap (entering timesheet of an employee)  RSS feed

 
nagaraju RamaKrishna
Greenhorn
Posts: 2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Jsp page am using the below code:

<h:form id="employeeTimesheetForm">
<h:panelGroup id="errorPanel">
<autputPanel ajaxRendered="true">
<div style="display: none;">
<h:messages id="error"></h:messages>
</div>
</autputPanel>
</h:panelGroup>
<h:panelGroup id="timesheetPanel">
<s:validateAll>
<table>
<tr>
<td class="required-field">Week No:</td>
<td>
<s:decorate id="weekId">
<table cellspacing="0" cellpadding="0">
<tr><td class="required-field">
<hutputText value="#{recruitmentsAction.getWeek(recruitmentsAction.todaysDate) }" /></td>
</tr>
<tr><td>
<s:message errorClass="error"/>
</td></tr>
</table>
</s:decorate>
</td>
</tr>
<tr>
<td class="required-field">Employee Code:</td>
<td>
<s:decorate id="empCodeId">
<table cellspacing="0" cellpadding="0">
<tr><td>
<h:selectOneMenu value="#{recruitmentsAction.hrEmployee}" layout="pageDirection" class="comboStandard" required="true" label="Employee Code">
<s:selectItems value="#{recruitmentsAction.getEmployeeList()}" var="employee" label="#{employee.empCode}" noSelectionLabel="-Select-"/>
<s:convertEntity/>
<a:support event="onchange" ajaxSingle="true" reRender="dayslist,employeeTimesheetForm"/>
</h:selectOneMenu>
</td>
</tr>
<tr><td>
<s:message errorClass="error"/>
</td></tr>
</table>
</s:decorate>
</td>
</tr>
</table>
</s:validateAll> <br />
<rich:dataTable id="dayslist" var="days" value="#{recruitmentsAction.daysBetween()}" width="100%">
<f:facet name="header">
<rich:columnGroup>
<rich:column width="120" ><hutputText value="Date"/></rich:column>
<rich:column width="120" ><hutputText value="No. Of Hrs"/></rich:column>

<rich:column width="120" ><hutputText value="Over Time Hrs"/></rich:column>
</rich:columnGroup>
</f:facet>
<rich:column width="10" rendered="#{!(days.getDay()==0)}">
<hutputText value="#{systemUtils.formatDate(days, selectedInstance.dateFormat.businessValue)}" />
</rich:column>

<rich:column rendered="#{!(days.getDay()==0)}">
<h:inputText maxlength="2" value="#{recruitmentsAction.daysForRegular[days]}"
disabled="#{recruitmentsAction.isExists(days) }"> <f:convertNumber integerOnly="true"/>
</h:inputText>
</rich:column>
<rich:column rendered="#{!(days.getDay()==0)}">
<h:inputText maxlength="2" value="#{recruitmentsAction.daysForOvertime[days]}"
disabled="#{recruitmentsAction.isExists(days) }"> <f:convertNumber integerOnly="true"/>
</h:inputText>
</rich:column>
</rich:dataTable>
</h:panelGroup>
<br />
<h:panelGroup>
<a:commandButton value="#{messages['button.confirm']}" title="#{messages['button.confirm']}"
action="#{recruitmentsAction.confirmEmployeeTimesheet() }" oncomplete="closeTimesheetDlg();" reRender="timesheetlist"/>
<h:commandButton action="#{systemUtils.cancel()}" immediate="true" value="#{messages['button.cancel']}" title="#{messages['button.cancel']}"/>
</h:panelGroup>

</h:form>


The above code will look like below (user view output) :

22-04-2011 input text box1 input text box2
21-04-2011 input text box1 input text box2
20-04-2011 input text box1 input text box2
19-04-2011 input text box1 input text box2
18-04-2011 input text box1 input text box2
16-04-2011 input text box1 input text box2
15-04-2011 input text box1 input text box2
.
.
.....
.
.
1-04-2011 input text box1 input text box2


The user will enter the values in input text boxes and clicks on confirm method. My Confirm method is as follows:



daysBetween method as follows:



And i used hashmaps as below:

private HashMap<Date, Long> daysForRegular=new HashMap<Date, Long>(); //getter is there for this
private HashMap<Date, Long> daysForOvertime=new HashMap<Date, Long>(); //getter is there for this


Now my problem is if am trying to persist the details entered in input text box 1 and input text box 2 for weekly(from 22-04-2011 to 18-04-2011) then they are persisting correctly. (Entered values are passing to map)
But if i try to persist the details entered in input text box 1 and input text box 2 for monthly(from 22-04-2011 to 01-04-2011) then they are not persisting correctly. (Null values are passing into map)


Can anyone help me to solve the above issue. Am struggling lot for this issue. I tried almost all ways that i know. If anyone knows the problem please give solution for this issue.

[JB: added code tags and tt (fixed width font) tags]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!