Search in sources :

Example 6 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class HttpGetWithBody method setTimeout.

/**
 * set the value timeout
 *
 * @param timeout
 *            value to set
 * @throws ExpressionException
 */
public void setTimeout(Object timeout) throws PageException {
    if (timeout instanceof TimeSpan)
        this.timeout = (TimeSpan) timeout;
    else // seconds
    {
        int i = Caster.toIntValue(timeout);
        if (i < 0)
            throw new ApplicationException("invalid value [" + i + "] for attribute timeout, value must be a positive integer greater or equal than 0");
        this.timeout = new TimeSpanImpl(0, 0, 0, i);
    }
}
Also used : TimeSpan(lucee.runtime.type.dt.TimeSpan) ApplicationException(lucee.runtime.exp.ApplicationException) TimeSpanImpl(lucee.runtime.type.dt.TimeSpanImpl)

Example 7 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Input method setDaynames.

/**
 * @param daynames The daynames to set.
 * @throws ApplicationException
 */
public void setDaynames(String listDaynames) throws ApplicationException {
    String[] arr = ListUtil.listToStringArray(listDaynames, ',');
    if (arr.length != 7)
        throw new ApplicationException("value of attribute [daynames] must contain a string list with 7 values, now there are " + arr.length + " values");
    this.daynames = arr;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException)

Example 8 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Input method setRange.

/**
 * @param range The range to set.
 * @throws PageException
 */
public void setRange(String range) throws PageException {
    String errMessage = "attribute range has an invalid value [" + range + "], must be string list with numbers";
    String errDetail = "Example: [number_from,number_to], [number_from], [number_from,], [,number_to]";
    Array arr = ListUtil.listToArray(range, ',');
    if (arr.size() == 1) {
        double from = Caster.toDoubleValue(arr.get(1, null), true, Double.NaN);
        if (!Decision.isValid(from))
            throw new ApplicationException(errMessage, errDetail);
        input.setRangeMin(from);
        input.setRangeMax(Double.NaN);
    } else if (arr.size() == 2) {
        String strFrom = arr.get(1, "").toString().trim();
        double from = Caster.toDoubleValue(strFrom, Double.NaN);
        if (!Decision.isValid(from) && strFrom.length() > 0) {
            throw new ApplicationException(errMessage, errDetail);
        }
        input.setRangeMin(from);
        String strTo = arr.get(2, "").toString().trim();
        double to = Caster.toDoubleValue(strTo, Double.NaN);
        if (!Decision.isValid(to) && strTo.length() > 0) {
            throw new ApplicationException(errMessage, errDetail);
        }
        input.setRangeMax(to);
    } else
        throw new ApplicationException(errMessage, errDetail);
}
Also used : Array(lucee.runtime.type.Array) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 9 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Input method _doEndTag.

private void _doEndTag() throws PageException, IOException {
    // check attributes
    if (input.getValidate() == VALIDATE_REGULAR_EXPRESSION && input.getPattern() == null) {
        throw new ApplicationException("when validation type regular_expression is seleted, the pattern attribute is required");
    }
    Tag parent = getParent();
    while (parent != null && !(parent instanceof Form)) {
        parent = parent.getParent();
    }
    if (parent instanceof Form) {
        Form form = (Form) parent;
        form.setInput(input);
        if (input.getType() == TYPE_DATEFIELD && form.getFormat() != Form.FORMAT_FLASH)
            throw new ApplicationException("type [datefield] is only allowed if form format is flash");
    } else {
        throw new ApplicationException("Tag must be inside a form tag");
    }
    draw();
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) Tag(javax.servlet.jsp.tagext.Tag)

Example 10 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Input method setType.

/**
 * @param type The type to set.
 * @throws ApplicationException
 */
public void setType(String type) throws ApplicationException {
    type = type.toLowerCase().trim();
    if ("checkbox".equals(type))
        input.setType(TYPE_CHECKBOX);
    else if ("password".equals(type))
        input.setType(TYPE_PASSWORD);
    else if ("text".equals(type))
        input.setType(TYPE_TEXT);
    else if ("radio".equals(type))
        input.setType(TYPE_RADIO);
    else if ("button".equals(type))
        input.setType(TYPE_BUTTON);
    else if ("file".equals(type))
        input.setType(TYPE_FILE);
    else if ("hidden".equals(type))
        input.setType(TYPE_HIDDEN);
    else if ("image".equals(type))
        input.setType(TYPE_IMAGE);
    else if ("reset".equals(type))
        input.setType(TYPE_RESET);
    else if ("submit".equals(type))
        input.setType(TYPE_SUBMIT);
    else if ("datefield".equals(type))
        input.setType(TYPE_DATEFIELD);
    else
        throw new ApplicationException("attribute type has an invalid value [" + type + "]", "valid values for attribute type are " + "[checkbox, password, text, radio, button, file, hidden, image, reset, submit, datefield]");
    attributes.setEL("type", type);
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException)

Aggregations

ApplicationException (lucee.runtime.exp.ApplicationException)173 IOException (java.io.IOException)41 Resource (lucee.commons.io.res.Resource)36 PageException (lucee.runtime.exp.PageException)30 Struct (lucee.runtime.type.Struct)25 SecurityException (lucee.runtime.exp.SecurityException)17 BundleException (org.osgi.framework.BundleException)16 StructImpl (lucee.runtime.type.StructImpl)15 MalformedURLException (java.net.MalformedURLException)13 Element (org.w3c.dom.Element)13 Array (lucee.runtime.type.Array)12 Key (lucee.runtime.type.Collection.Key)12 Iterator (java.util.Iterator)11 InputStream (java.io.InputStream)10 Query (lucee.runtime.type.Query)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ExpressionException (lucee.runtime.exp.ExpressionException)9 Entry (java.util.Map.Entry)8 PageContextImpl (lucee.runtime.PageContextImpl)8 ClassDefinition (lucee.runtime.db.ClassDefinition)8