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);
}
}
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;
}
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);
}
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();
}
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);
}
Aggregations