Search in sources :

Example 86 with JspException

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;
}
Also used : JspException(javax.servlet.jsp.JspException) UserContext(org.mifos.security.util.UserContext) JspException(javax.servlet.jsp.JspException)

Example 87 with JspException

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;
}
Also used : CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SystemException(org.mifos.framework.exceptions.SystemException) List(java.util.List) ProductDto(org.mifos.application.servicefacade.ProductDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Example 88 with JspException

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;
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager) JspException(javax.servlet.jsp.JspException) LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) HttpSession(javax.servlet.http.HttpSession) UserContext(org.mifos.security.util.UserContext) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) List(java.util.List) JspException(javax.servlet.jsp.JspException)

Example 89 with JspException

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;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) FlowManager(org.mifos.framework.util.helpers.FlowManager) HttpSession(javax.servlet.http.HttpSession) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.util.Date) JspException(javax.servlet.jsp.JspException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) JspException(javax.servlet.jsp.JspException) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder)

Example 90 with JspException

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;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) JspException(javax.servlet.jsp.JspException) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) JspException(javax.servlet.jsp.JspException)

Aggregations

JspException (javax.servlet.jsp.JspException)158 IOException (java.io.IOException)34 Map (java.util.Map)30 HashMap (java.util.HashMap)21 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 JspWriter (javax.servlet.jsp.JspWriter)21 Iterator (java.util.Iterator)20 ActionMessages (org.apache.struts.action.ActionMessages)15 MockFormBean (org.apache.struts.mock.MockFormBean)15 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 ActionMessage (org.apache.struts.action.ActionMessage)11 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 List (java.util.List)7 Locale (java.util.Locale)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 MalformedURLException (java.net.MalformedURLException)5 ModuleConfig (org.apache.struts.config.ModuleConfig)5 UserContext (org.mifos.security.util.UserContext)5 SimpleDateFormat (java.text.SimpleDateFormat)4