use of javax.servlet.jsp.JspException in project head by mifos.
the class CustomFieldsListTag method doEndTag.
@Override
public int doEndTag() throws JspException {
try {
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USERCONTEXT);
TagUtils.getInstance().write(pageContext, "");
} catch (Exception e) {
/**
* This turns into a (rather ugly) error 500. TODO: make it more
* reasonable.
*/
throw new JspException(e);
}
return EVAL_PAGE;
}
use of javax.servlet.jsp.JspException in project head by mifos.
the class BulkEntryTag method doStartTag.
@SuppressWarnings("unchecked")
@Override
public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
JspWriter out = pageContext.getOut();
StringBuilder builder = new StringBuilder();
CollectionSheetEntryGridDto bulkEntry = null;
try {
bulkEntry = (CollectionSheetEntryGridDto) SessionUtils.getAttribute(CollectionSheetEntryConstants.BULKENTRY, request);
} catch (PageExpiredException e) {
logger.error("Page expired getting BulkEntryBO.");
}
if (null != bulkEntry) {
List<ProductDto> loanProducts = bulkEntry.getLoanProducts();
List<ProductDto> savingsProducts = bulkEntry.getSavingProducts();
try {
final List<CustomValueListElementDto> custAttTypes = (List<CustomValueListElementDto>) SessionUtils.getAttribute(CollectionSheetEntryConstants.CUSTOMERATTENDANCETYPES, request);
String method = request.getParameter(CollectionSheetEntryConstants.METHOD);
generateTagData(bulkEntry, loanProducts, savingsProducts, custAttTypes, method, builder);
} catch (ApplicationException ae) {
throw new JspException(ae);
} catch (SystemException se) {
throw new JspException(se);
}
}
try {
out.write(builder.toString());
} catch (IOException ioe) {
throw new JspException(ioe);
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspException in project head by mifos.
the class LoanActivityTag method doStartTag.
@Override
public int doStartTag() throws JspException {
XmlBuilder xmlBuilder = new XmlBuilder();
try {
String currentFlowKey = (String) pageContext.getRequest().getAttribute(Constants.CURRENTFLOWKEY);
HttpSession session = pageContext.getSession();
FlowManager flowManager = (FlowManager) session.getAttribute(Constants.FLOWMANAGER);
Object object = flowManager.getFromFlow(currentFlowKey, LoanConstants.LOAN_ALL_ACTIVITY_VIEW);
if (object == null) {
// for spring/ftl
object = pageContext.getRequest().getAttribute(LoanConstants.LOAN_ALL_ACTIVITY_VIEW);
}
if (null != object) {
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
locale = userContext.getPreferredLocale();
xmlBuilder.startTag("table", "width", "100%", "border", "0", "cellspacing", "0", "cellpadding", "0", "id", "accountActivityTable");
xmlBuilder.startTag("tr");
xmlBuilder.startTag("td", "colspan", "8");
//xmlBuilder.nonBreakingSpace();
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "colspan", "4", "class", "drawtablerowboldnoline");
xmlBuilder.text(getLabel("loan.running_bal", locale));
xmlBuilder.endTag("td");
xmlBuilder.endTag("tr");
xmlBuilder.startTag("tr", "class", "drawtablerowbold");
xmlBuilder.startTag("td", "width", "9%", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.date", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "19%", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.activity", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.principal", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.fees", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.penalty", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "6%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.total", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "4", "align", "right", "class", "fontnormalbold");
//xmlBuilder.nonBreakingSpace();
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.principal", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.fees", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "6%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.total", locale));
xmlBuilder.endTag("td");
xmlBuilder.endTag("tr");
List<LoanActivityDto> loanRecentActivityViewSet = (List<LoanActivityDto>) object;
Iterator<LoanActivityDto> it = loanRecentActivityViewSet.iterator();
while (it.hasNext()) {
LoanActivityDto loanActivityDto = it.next();
xmlBuilder.startTag("tr", "valign", "top");
xmlBuilder.append(buildLeftHeaderRows(loanActivityDto));
xmlBuilder.append(buildRightHeaderRows(loanActivityDto));
xmlBuilder.endTag("tr");
}
xmlBuilder.endTag("table");
}
pageContext.getOut().write(xmlBuilder.toString());
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspException in project head by mifos.
the class LoanRepaymentTag method doStartTag.
@Override
public int doStartTag() throws JspException {
boolean twoTables = false;
XmlBuilder html = new XmlBuilder();
LoanBO loanBO = null;
try {
String currentFlowKey = (String) pageContext.getRequest().getAttribute(Constants.CURRENTFLOWKEY);
HttpSession session = pageContext.getSession();
FlowManager flowManager = (FlowManager) session.getAttribute(Constants.FLOWMANAGER);
loanBO = (LoanBO) flowManager.getFromFlow(currentFlowKey, Constants.BUSINESS_KEY);
if (StringUtils.isNotBlank(memberGlobalNum)) {
loanBO = loanBO.findMemberByGlobalNum(memberGlobalNum);
}
Date viewDate = getViewDate(currentFlowKey, flowManager);
Money totalPrincipal = new Money(loanBO.getCurrency(), "0");
Money totalInterest = new Money(loanBO.getCurrency(), "0");
Money totalFees = new Money(loanBO.getCurrency(), "0");
Money totalPenalties = new Money(loanBO.getCurrency(), "0");
/*
* LoanBO loanBO = (LoanBO) pageContext.getRequest().getAttribute( Constants.BUSINESS_KEY);
*/
List<AccountActionDateEntity> list = new ArrayList<AccountActionDateEntity>();
if (isNewGropLoan) {
List<LoanBO> memberAccounts = getMemberScheduleDetails(loanBO.getAccountId());
list.addAll(generateGroupSchedule(memberAccounts, loanBO));
} else {
list.addAll(loanBO.getAccountActionDates());
}
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
locale = userContext.getPreferredLocale();
if (list.size() != 0) {
// topmost table
html.startTag("table", "width", "100%", "border", "0", "cellspacing", "0", "cellpadding", "0");
// Left side header
XmlBuilder htmlHeader1 = new XmlBuilder();
htmlHeader1.startTag("tr");
htmlHeader1.startTag("td", "width", "6%", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.no", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "15%", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.due_date", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "15%", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.date_paid", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "12%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.principal", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "10%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "10%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.fees", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "11%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.penalty", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "11%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.daysLate", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "10%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.total", locale));
htmlHeader1.endTag("td");
htmlHeader1.endTag("tr");
for (AccountActionDateEntity acctDate : list) {
LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) acctDate;
totalPrincipal = totalPrincipal.add(loanScheduleEntity.getPrincipal());
totalInterest = totalInterest.add(loanScheduleEntity.getEffectiveInterest());
totalFees = totalFees.add(loanScheduleEntity.getTotalScheduledFeeAmountWithMiscFee());
totalPenalties = totalPenalties.add(loanScheduleEntity.getTotalPenalty());
}
// check if at least the first installment is paid
LoanScheduleEntity firstInstallment = (LoanScheduleEntity) list.get(0);
XmlBuilder html1 = new XmlBuilder();
XmlBuilder html2 = new XmlBuilder();
XmlBuilder htmlHeader2 = new XmlBuilder();
if (!firstInstallment.getTotalDueWithFees().equals(firstInstallment.getTotalScheduleAmountWithFees())) {
twoTables = true;
// installments paid and running balance table is
// required
htmlHeader2.startTag("tr");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.principal", locale));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.fees", locale));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.penalty", locale));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.total", locale));
htmlHeader2.endTag("td");
htmlHeader2.endTag("tr");
}
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.nonBreakingSpace();
html1.endTag("td");
html1.endTag("tr");
html2.startTag("tr");
html2.startTag("td", "colspan", "5", "class", "drawtablerowbold");
html2.text(getLabel("loan.running_bal", locale));
html2.endTag("td");
html2.endTag("tr");
html1.append(htmlHeader1);
html2.append(htmlHeader2);
if (twoTables) {
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.text(getLabel("loan.instt_paid", locale));
html1.endTag("td");
html1.endTag("tr");
html2.startTag("tr");
html2.startTag("td", "colspan", "5", "class", "drawtablerowbold");
html2.nonBreakingSpace();
html2.endTag("td");
html2.endTag("tr");
}
int index = 0;
boolean toContinue = true;
LoanScheduleEntity installment = (LoanScheduleEntity) list.get(index);
while (index <= list.size() - 1 && toContinue && !installment.getTotalDueWithFees().equals(installment.getTotalScheduleAmountWithFees())) {
html1.append(createInstallmentRow(installment, true, isNewGropLoan));
html2.append(createRunningBalanceRow(installment, totalPrincipal, totalInterest, totalFees, totalPenalties));
totalPrincipal = totalPrincipal.subtract(installment.getPrincipalPaid());
totalInterest = totalInterest.subtract(installment.getEffectiveInterestPaid());
totalFees = totalFees.subtract(installment.getTotalFeeAmountPaidWithMiscFee());
totalPenalties = totalPenalties.subtract(installment.getPenaltyPaid());
if (index != list.size() - 1 && installment.isPaid()) {
index++;
installment = (LoanScheduleEntity) list.get(index);
} else {
toContinue = false;
}
}
boolean dueInstallments = false;
if (!installment.isPaid() && installment.getActionDate().getTime() <= viewDate.getTime()) {
dueInstallments = true;
}
if (dueInstallments) {
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.text(getLabel("loan.instt_due", locale));
html1.endTag("td");
html1.endTag("tr");
while (index < list.size() - 1 && !installment.isPaid() && installment.getActionDate().getTime() <= viewDate.getTime()) {
index++;
html1.append(createInstallmentRow(installment, false, isNewGropLoan));
installment = (LoanScheduleEntity) list.get(index);
}
}
boolean futureInstallments = false;
if (!installment.isPaid() && installment.getActionDate().getTime() > viewDate.getTime()) {
futureInstallments = true;
}
if (futureInstallments) {
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.text(getLabel("loan.future_install", locale));
html1.endTag("td");
html1.endTag("tr");
while (index < list.size() - 1) {
index++;
html1.append(createInstallmentRow(installment, false, isNewGropLoan));
installment = (LoanScheduleEntity) list.get(index);
}
}
// append the last transaction
if (!installment.isPaid()) {
html1.append(createInstallmentRow(installment, false, isNewGropLoan));
}
long totalDaysLate = 0;
for (AccountActionDateEntity accountActionDateEntity : list) {
totalDaysLate += accountActionDateEntity.getDaysLate();
}
XmlBuilder totalDaysLateXmlBuilder = new XmlBuilder();
totalDaysLateXmlBuilder.startTag("tr");
totalDaysLateXmlBuilder.startTag("td", "class", "drawtablerow", "colspan", "8", "align", "right");
totalDaysLateXmlBuilder.text(getLabel("loan.total", locale) + ": " + totalDaysLate);
totalDaysLateXmlBuilder.endTag("td");
totalDaysLateXmlBuilder.startTag("td", "class", "drawtablerow");
totalDaysLateXmlBuilder.nonBreakingSpace();
totalDaysLateXmlBuilder.endTag("td");
totalDaysLateXmlBuilder.endTag("tr");
html1.append(totalDaysLateXmlBuilder);
if (twoTables) {
// add a tr with 2 td for each of the 2 tables
html.startTag("tr");
html.startTag("td", "width", "70%");
html.startTag("table", "width", "95%", "border", "0", "cellspacing", "0", "cellpadding", "5", "id", "repaymentScheduleTable");
html.append(html1);
html.endTag("table");
html.endTag("td");
html.startTag("td", "width", "25%", "valign", "top");
html.startTag("table", "width", "95%", "border", "0", "cellspacing", "0", "cellpadding", "5", "id", "runningBalanceTable");
html.append(html2);
html.endTag("table");
html.endTag("td");
html.endTag("tr");
html.endTag("table");
} else {
html.startTag("tr");
html.startTag("td", "width", "100%");
html.startTag("table", "id", "installments", "width", "95%", "border", "0", "cellspacing", "0", "cellpadding", "5");
html.append(html1);
html.endTag("table");
html.endTag("td");
html.endTag("tr");
html.endTag("table");
}
}
pageContext.getOut().write(html.toString());
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspException in project head by mifos.
the class OfficeListTag method doStartTag.
@Override
public int doStartTag() throws JspException {
try {
String officeListString = "";
OnlyBranchOfficeHierarchyDto officeHierarchyDto = (OnlyBranchOfficeHierarchyDto) pageContext.getAttribute(OnlyBranchOfficeHierarchyDto.IDENTIFIER);
if (officeHierarchyDto != null) {
officeListString = getOfficeList(officeHierarchyDto);
} else {
// FIXME - #00006 - keithw - personnel creation use this still
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USERCONTEXT);
OfficePersistence officePersistence = new OfficePersistence();
OfficeBO officeBO = officePersistence.getOffice(userContext.getBranchId());
List<OfficeDetailsDto> levels = officePersistence.getActiveLevels();
OfficeBO loggedInOffice = officePersistence.getOffice(userContext.getBranchId());
List<OfficeBO> branchParents = officePersistence.getBranchParents(officeBO.getSearchId());
List<OfficeHierarchyDto> officeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
List<OfficeBO> officesTillBranchOffice = officePersistence.getOfficesTillBranchOffice(officeBO.getSearchId());
officeListString = getOfficeList(userContext.getPreferredLocale(), levels, loggedInOffice.getSearchId(), officeHierarchy, officesTillBranchOffice);
}
TagUtils.getInstance().write(pageContext, officeListString);
} catch (Exception e) {
/**
* This turns into a (rather ugly) error 500. TODO: make it more reasonable.
*/
throw new JspException(e);
}
return EVAL_PAGE;
}
Aggregations