Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created October 19, 2012 16:29
Show Gist options
  • Save dwelch2344/3919180 to your computer and use it in GitHub Desktop.
Save dwelch2344/3919180 to your computer and use it in GitHub Desktop.
java code
private String filterParams(WorkerSearchParamsDto searchParamsDto, Locale locale) {
StringBuilder builder = new StringBuilder();
SimpleDateFormat date = new SimpleDateFormat(getMessage("datePattern", locale));
if(searchParamsDto.getActive() != null && searchParamsDto.getActive()) {
builder.append(TagUtils.concat(getMessage("search.status", locale), getMessage(WorkerStatus.ACTIVE.getLocalKey(), locale), ": "));
} else if(searchParamsDto.getActive() != null && searchParamsDto.getActive()) {
builder.append(TagUtils.concat(getMessage("search.status", locale), getMessage(WorkerStatus.INACTIVE.getLocalKey(), locale), ": "));
}
if(searchParamsDto.hasLeaveFilter()) {
addComma(builder);
builder.append(TagUtils.concat(getMessage(WorkerStatus.ON_LEAVE.getLocalKey(), locale),
TagUtils.concat(date.format(searchParamsDto.getLeaveBeginDate()), date.format(searchParamsDto.getLeaveEndDate()), " - "), ": "));
}
if(searchParamsDto.getGender() != null) {
addComma(builder);
builder.append(TagUtils.concat(getMessage("generic.gender", locale), getMessage(searchParamsDto.getGender().getLocalKey(), locale), ": "));
}
if(searchParamsDto.hasPositionFilters()) {
addComma(builder);
addListOfPositions(builder, searchParamsDto.getPositionIds());
}
return builder.toString();
}
private void addListOfPositions(StringBuilder builder, List<Long> positionIds) {
positionService.findByIds(positionIds);
}
private void addComma(StringBuilder builder) {
if(builder.length() > 0) {
builder.append(", ");
}
}
private String getMessage(String key, Locale locale) {
return messageSource.getMessage(key, null, locale);
}
<body>
<div class="title"><c:out value="${temple.name} - ${reportName}"/></div>
<fmt:message var="dateFormat" key="datePattern"/>
<fmt:formatDate var="printedDate" value="${printDate}" pattern="${dateFormat}"/>
<div id="printDateElement">
<fmt:message key="generic.print.date">
<fmt:param value="${printedDate}" />
</fmt:message>
</div>
<div>
<fmt:message key="search.filtered.by"/>
<c:out value="${filterParams}"/>
</div>
<table class="tp-table repeat-header">
<thead>
<tr>
<th>&#160;</th>
<c:forEach var="column" items="${params.selectedColumns}">
<th><a><spring:message code="${column.localKey}"/></a></th>
</c:forEach>
</tr>
</thead>
<%@include file="search-result-rows.jsp" %>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment