Search in sources :

Example 1 with XmlBuilder

use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.

the class TableTag method doStartTag.

/**
     * Function to render the tag
     */
@Override
public int doStartTag() throws JspException {
    // call the helper method to display the result.
    try {
        // Value of the list which we are getting from the Cache
        List list = getList();
        if (list == null) {
            return super.doStartTag();
        }
        if (list.size() == 0) {
            JspWriter out = pageContext.getOut();
            XmlBuilder result;
            result = noResults((String) SessionUtils.getAttribute(Constants.OFFICE_NAME, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.BRANCH_ID, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.SEARCH_STRING, (HttpServletRequest) pageContext.getRequest()));
            out.write(result.getOutput());
            return super.doStartTag();
        }
        getTableData(list);
    } catch (TableTagException tte) {
        throw new JspException(tte);
    } catch (TableTagParseException ttpe) {
        throw new JspException(ttpe);
    } catch (TableTagTypeParserException tttpe) {
        throw new JspException(tttpe);
    } catch (IOException ioe) {
        throw new JspException(ioe);
    } catch (HibernateSearchException hse) {
        throw new JspException(hse);
    } catch (PageExpiredException e) {
        throw new JspException(e);
    }
    return super.doStartTag();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TableTagException(org.mifos.framework.exceptions.TableTagException) JspException(javax.servlet.jsp.JspException) TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) TableTagTypeParserException(org.mifos.framework.exceptions.TableTagTypeParserException)

Example 2 with XmlBuilder

use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.

the class OfficeListTag method getLink.

XmlBuilder getLink(Short officeId, String officeName) {
    String urlencodedOfficeName = URLEncoder.encode(officeName);
    XmlBuilder builder = new XmlBuilder();
    String url = (actionName + "?method=" + methodName + "&office.officeId=" + officeId + "&office.officeName=" + urlencodedOfficeName + "&officeId=" + officeId + "&officeName=" + urlencodedOfficeName + "&currentFlowKey=" + flowKey);
    builder.startTag("a", "href", url);
    builder.text(officeName);
    builder.endTag("a");
    return builder;
}
Also used : XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder)

Example 3 with XmlBuilder

use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.

the class OfficeListTag method getOfficeList.

String getOfficeList(Locale preferredUserLocale, List<OfficeDetailsDto> levels, String loggedInOfficeSearchId, List<OfficeHierarchyDto> officeHierarchy, List<OfficeBO> officesTillBranchOffice) {
    String termForBranch = "";
    String regional = "";
    String subregional = "";
    String area = "";
    for (OfficeDetailsDto level : levels) {
        if (level.getLevelId().equals(OfficeLevel.BRANCHOFFICE.getValue())) {
            termForBranch = level.getLevelName();
        } else if (level.getLevelId().equals(OfficeLevel.AREAOFFICE.getValue())) {
            area = level.getLevelName();
        } else if (level.getLevelId().equals(OfficeLevel.REGIONALOFFICE.getValue())) {
            regional = level.getLevelName();
        } else if (level.getLevelId().equals(OfficeLevel.SUBREGIONALOFFICE.getValue())) {
            subregional = level.getLevelName();
        }
    }
    XmlBuilder result = new XmlBuilder();
    if (onlyBranchOffices != null) {
        getBranchOffices(result, officeHierarchy, preferredUserLocale, loggedInOfficeSearchId, termForBranch);
    } else {
        getAboveBranches(result, officesTillBranchOffice, regional, subregional, area);
        getBranchOffices(result, officeHierarchy, preferredUserLocale, loggedInOfficeSearchId, termForBranch);
    }
    return result.getOutput();
}
Also used : XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Example 4 with XmlBuilder

use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.

the class OfficeListTag method getAboveBranches.

void getAboveBranches(XmlBuilder html, List<OfficeBO> officeList, String regional, String subregional, String area) {
    if (null != officeList) {
        XmlBuilder regionalHtml = null;
        XmlBuilder subregionalHtml = null;
        XmlBuilder areaHtml = null;
        for (int i = 0; i < officeList.size(); i++) {
            OfficeBO office = officeList.get(i);
            if (office.getOfficeLevel() == OfficeLevel.HEADOFFICE) {
                html.singleTag("br");
                html.startTag("span", "class", "fontnormalbold");
                html.append(getLink(office.getOfficeId(), office.getOfficeName()));
                html.singleTag("br");
                html.endTag("span");
            } else if (office.getOfficeLevel() == OfficeLevel.REGIONALOFFICE) {
                regionalHtml = processOffice(regionalHtml, office, regional);
            } else if (office.getOfficeLevel() == OfficeLevel.SUBREGIONALOFFICE) {
                subregionalHtml = processOffice(subregionalHtml, office, subregional);
            } else if (office.getOfficeLevel() == OfficeLevel.AREAOFFICE) {
                areaHtml = processOffice(areaHtml, office, area);
            }
        }
        outputLevel(html, regionalHtml);
        outputLevel(html, subregionalHtml);
        outputLevel(html, areaHtml);
    }
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder)

Example 5 with XmlBuilder

use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.

the class Dispatcher method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    XmlBuilder html = new XmlBuilder();
    String pathInfo = request.getPathInfo();
    if (pathInfo == null) {
        redirectTo(response, stringUrlOf(request) + "/");
        return;
    } else if (pathInfo.equals("/")) {
        String contextPath = request.getContextPath();
        developerPage(contextPath, html);
    } else if (isCreateReport(pathInfo)) {
        new CreateReport().createPage(html);
    } else if (pathInfo.startsWith("/reports/")) {
        String reportIdString = pathInfo.substring("/reports/".length());
        try {
            int reportId = Integer.parseInt(reportIdString);
            redirectToReport(response, request, reportId);
        } catch (NumberFormatException notValidNumber) {
            errorPage(html, pathInfo);
            response.setStatus(404);
        }
    } else {
        errorPage(html, pathInfo);
        response.setStatus(404);
    }
    response.getWriter().write(html.getOutput());
}
Also used : XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder)

Aggregations

XmlBuilder (org.mifos.framework.struts.tags.XmlBuilder)20 JspException (javax.servlet.jsp.JspException)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HttpSession (javax.servlet.http.HttpSession)2 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)2 FlowManager (org.mifos.framework.util.helpers.FlowManager)2 UserContext (org.mifos.security.util.UserContext)2 IOException (java.io.IOException)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspWriter (javax.servlet.jsp.JspWriter)1 Before (org.junit.Before)1 Test (org.junit.Test)1 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)1 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)1