use of org.mifos.framework.exceptions.TableTagParseException 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();
}
use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTagParser method parser.
public Table parser(String filename) throws TableTagParseException {
Table table = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
// Specify our own schema - this overrides the schemaLocation in the
// xml file
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "tabletag.xsd");
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(null);
Document document = builder.parse(MifosResourceUtil.getClassPathResourceAsURIString(filename));
/*
* NodeList tableNodeList =
* document.getElementsByTagName(TableTagConstants.TABLE); table =
* new Table[tableNodeList.getLength()];
*
* for (int i = 0; i < table.length; i++) { table[i] = new Table();
* table[i].setRow(createRow(tableNodeList.item(i))); }
*/
Node tableNode = document.getFirstChild();
table = new Table();
table.setPath(createPath(tableNode));
table.setPageRequirements(createPageRequirements(tableNode));
table.setRow(createRow(tableNode));
} catch (Exception e) {
throw new TableTagParseException(e);
}
return table;
}
use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTagParser method createPath.
protected Path[] createPath(Node table) throws TableTagParseException {
NodeList pathNodeList = ((Element) table).getElementsByTagName(TableTagConstants.PATH);
if (pathNodeList.getLength() == 0) {
throw new TableTagParseException(TableTagConstants.UNEXPECTED_ERROR);
}
Path[] path = new Path[pathNodeList.getLength()];
for (int i = 0; i < pathNodeList.getLength(); i++) {
path[i] = new Path();
path[i].setKey((pathNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.KEY).getNodeValue()));
path[i].setAction((pathNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.PATHACTION).getNodeValue()));
path[i].setForwardkey((pathNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.FORWARDKEY).getNodeValue()));
}
return path;
}
use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTag method doStartTag.
@SuppressWarnings("unchecked")
@Override
public int doStartTag() throws JspException {
try {
table = TableTagParser.getInstance().parser(moduleName + "/" + xmlFileName);
Column[] column = table.getRow().getColumn();
for (int i = 0; i < column.length; ++i) {
if (column[i].getLinkDetails() != null) {
if (randomNUm == null || currentFlowKey == null) {
column[i] = null;
if (i < column.length - 1) {
int j = i;
for (; j < column.length - 1; ++j) {
column[j] = column[j + 1];
}
}
column = Arrays.copyOf(column, column.length - 1);
table.getRow().setColumn(column);
} else {
LinkDetails linkDetails = column[i].getLinkDetails();
for (ActionParam param : linkDetails.getActionParam()) {
if (param.getValueType().equalsIgnoreCase(TableTagConstants.INBUILD)) {
if (param.getName().equalsIgnoreCase("randomNUm")) {
param.setValue(randomNUm);
} else if (param.getName().equalsIgnoreCase("currentFlowKey")) {
param.setValue(currentFlowKey);
} else if (param.getName().equalsIgnoreCase("accountId")) {
param.setValue(accountId);
} else if (param.getName().equalsIgnoreCase("globalAccountNum")) {
param.setValue(globalAccountNum);
}
}
}
}
}
}
tableInfo = new StringBuilder();
if (source == null || scope == null) {
throw new JspException();
}
List obj = null;
if (scope.equalsIgnoreCase("session")) {
obj = (List) pageContext.getSession().getAttribute(source);
} else if (scope.equalsIgnoreCase("request")) {
obj = (List) pageContext.getRequest().getAttribute(source);
}
if (obj == null) {
try {
obj = (List) SessionUtils.getAttribute(source, (HttpServletRequest) pageContext.getRequest());
} catch (PageExpiredException e) {
}
}
if (obj == null || obj.isEmpty()) {
return super.doStartTag();
}
if (passLocale != null && passLocale.equalsIgnoreCase("true")) {
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
populateLocale(userContext);
}
table.getTable(source, tableInfo, obj, locale, mfiLocale, pageContext, getResourcebundleName(), glMode);
} catch (TableTagParseException ex) {
throw new JspException(ex);
}
try {
pageContext.getOut().print(tableInfo.toString());
} catch (IOException e) {
throw new JspException(e);
}
return super.doStartTag();
}
use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTagParser method createHeaderDetails.
protected HeaderDetails createHeaderDetails(Node table) throws TableTagParseException {
NodeList headerNodeList = ((Element) table).getElementsByTagName(TableTagConstants.HEADERDETAILS);
if (headerNodeList.getLength() == 0) {
throw new TableTagParseException(headerNodeList.toString());
}
HeaderDetails headerDetails = new HeaderDetails();
headerDetails.setHeaderStyle(headerNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.HEADERSTYLE).getNodeValue());
return headerDetails;
}
Aggregations