Search in sources :

Example 6 with TableTagException

use of org.mifos.framework.exceptions.TableTagException in project head by mifos.

the class Text method getImage.

// to get Image
static String getImage(Object obj, String name, Locale locale) throws TableTagException {
    StringBuilder stringbuilder = new StringBuilder();
    Method method = null;
    Object customerType = null;
    String textValue = null;
    String imagePath = null;
    try {
        method = obj.getClass().getDeclaredMethod("getCustomerType", (Class[]) null);
        customerType = method.invoke(obj, (Object[]) null);
    } catch (NoSuchMethodException nsme) {
        throw new TableTagException(nsme.getMessage());
    } catch (IllegalArgumentException iae) {
        throw new TableTagException(iae);
    } catch (IllegalAccessException iae) {
        throw new TableTagException(iae);
    } catch (InvocationTargetException ite) {
        throw new TableTagException(ite);
    }
    Properties filePaths = getNonLocalizedFileLookupDatabase();
    if (customerType != null && (customerType.toString().equals("4") || customerType.toString().equals("5"))) {
        textValue = MessageLookup.getLocalizedMessage("loanaccount_stateid_" + name);
        imagePath = filePaths.getProperty("loanaccount_imageid_" + name);
    } else if (customerType != null && (customerType.toString().equals("6") || customerType.toString().equals("7") || customerType.toString().equals("8"))) {
        textValue = MessageLookup.getLocalizedMessage("savings_stateid_" + name);
        imagePath = filePaths.getProperty("savings_imageid_" + name);
    } else {
        textValue = MessageLookup.getLocalizedMessage("value_" + name);
        imagePath = filePaths.getProperty("image_" + name);
    }
    stringbuilder.append("<span class=\"fontnormal\">").append("&nbsp;").append("<img src=").append(imagePath).append(" width=\"8\" height=\"9\">").append("</span>").append("<span class=\"fontnormal\">").append("&nbsp;").append(textValue).append("</span>");
    return stringbuilder.toString();
}
Also used : TableTagException(org.mifos.framework.exceptions.TableTagException) Method(java.lang.reflect.Method) Properties(java.util.Properties) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with TableTagException

use of org.mifos.framework.exceptions.TableTagException in project head by mifos.

the class TableTagIntegrationTest method testTableTagException.

@Test
public void testTableTagException() throws Exception {
    try {
        Locale locale = Localization.getInstance().getConfiguredLocale();
        Text.getImage(this, "name", locale);
        Assert.fail();
    } catch (TableTagException tte) {
        Assert.assertEquals("exception.framework.TableTagException", tte.getKey());
    }
}
Also used : Locale(java.util.Locale) TableTagException(org.mifos.framework.exceptions.TableTagException) Test(org.junit.Test)

Aggregations

TableTagException (org.mifos.framework.exceptions.TableTagException)7 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Locale (java.util.Locale)2 Properties (java.util.Properties)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 MissingResourceException (java.util.MissingResourceException)1 JspWriter (javax.servlet.jsp.JspWriter)1 Test (org.junit.Test)1 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1 TableTagParseException (org.mifos.framework.exceptions.TableTagParseException)1 TableTagTypeParserException (org.mifos.framework.exceptions.TableTagTypeParserException)1