Search in sources :

Example 1 with InvalidArgumentException

use of org.apache.empire.exceptions.InvalidArgumentException in project empire-db by apache.

the class CheckboxInputControl method createInputComponents.

@Override
protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context, List<UIComponent> compList) {
    if (!compList.isEmpty())
        throw new InvalidArgumentException("compList", compList);
    // create
    HtmlSelectBooleanCheckbox input = InputControlManager.createComponent(context, this.inputComponentClass);
    // copy attributes
    copyAttributes(parent, ii, input);
    // add
    compList.add(input);
    // set style and value
    updateInputState(compList, ii, context, context.getCurrentPhaseId());
}
Also used : HtmlSelectBooleanCheckbox(javax.faces.component.html.HtmlSelectBooleanCheckbox) InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException)

Example 2 with InvalidArgumentException

use of org.apache.empire.exceptions.InvalidArgumentException in project empire-db by apache.

the class RadioInputControl method createInputComponents.

@Override
protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context, List<UIComponent> compList) {
    if (!compList.isEmpty())
        throw new InvalidArgumentException("compList", compList);
    // create
    HtmlSelectOneRadio input = InputControlManager.createComponent(context, this.inputComponentClass);
    // setValueExpressionFlag
    Object value = ii.getValue(false);
    input.getAttributes().put(RadioInputControl.VALUE_EXPRESSION_FLAG, (value instanceof ValueExpression));
    // copy Attributes
    copyAttributes(parent, ii, input);
    // disabled
    boolean disabled = ii.isDisabled();
    input.setDisabled(disabled);
    // Options
    Options options = ii.getOptions();
    boolean addEmpty = getEmptyEntryRequired(ii, disabled) && !options.containsNull();
    String nullText = (addEmpty) ? getNullText(ii) : "";
    initOptions(input, ii.getTextResolver(), options, addEmpty, nullText);
    // add
    compList.add(input);
    // style
    addRemoveDisabledStyle(input, disabled);
    addRemoveInvalidStyle(input, ii.hasError());
    // Set Value
    setInputValue(input, ii);
}
Also used : Options(org.apache.empire.commons.Options) InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException) ValueExpression(javax.el.ValueExpression) HtmlSelectOneRadio(javax.faces.component.html.HtmlSelectOneRadio)

Example 3 with InvalidArgumentException

use of org.apache.empire.exceptions.InvalidArgumentException in project empire-db by apache.

the class TextAreaInputControl method createInputComponents.

@Override
protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context, List<UIComponent> compList) {
    // check params
    if (!compList.isEmpty())
        throw new InvalidArgumentException("compList", compList);
    // create
    HtmlInputTextarea input = InputControlManager.createComponent(context, this.inputComponentClass);
    // once
    copyAttributes(parent, ii, input);
    // cols
    int cols = getFormatInteger(ii, FORMAT_COLS, FORMAT_COLS_ATTRIBUTE);
    if (cols > 0)
        input.setCols(cols);
    // rows
    int rows = getFormatInteger(ii, FORMAT_ROWS, FORMAT_ROWS_ATTRIBUTE);
    if (rows > 0)
        input.setRows(rows);
    // add
    compList.add(input);
    // update
    updateInputState(compList, ii, context, context.getCurrentPhaseId());
}
Also used : InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException) HtmlInputTextarea(javax.faces.component.html.HtmlInputTextarea)

Example 4 with InvalidArgumentException

use of org.apache.empire.exceptions.InvalidArgumentException in project empire-db by apache.

the class TextInputControl method createInputComponents.

@Override
protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context, List<UIComponent> compList) {
    // check params
    if (!compList.isEmpty())
        throw new InvalidArgumentException("compList", compList);
    // create
    HtmlInputText input = InputControlManager.createComponent(context, this.inputComponentClass);
    // once
    copyAttributes(parent, ii, input);
    // language
    input.setLang(ii.getLocale().getLanguage());
    // maxlength
    int maxLength = getMaxInputLength(ii);
    if (maxLength > 0) {
        input.setMaxlength(maxLength);
    }
    // add
    compList.add(input);
    // add unit
    String unit = getUnitString(ii);
    if (StringUtils.isNotEmpty(unit)) {
        // add the unit
        compList.add(createUnitLabel("eUnit", ii, unit));
    }
    // add hint
    String hint = StringUtils.toString(ii.getAttribute("hint"));
    if (StringUtils.isNotEmpty(hint) && !ii.isDisabled()) {
        // add the hint (if not an empty string!)
        compList.add(createUnitLabel("eInputHint", ii, hint));
    }
    // update
    updateInputState(compList, ii, context, context.getCurrentPhaseId());
}
Also used : InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException) HtmlInputText(javax.faces.component.html.HtmlInputText)

Example 5 with InvalidArgumentException

use of org.apache.empire.exceptions.InvalidArgumentException in project empire-db by apache.

the class WebApplication method getConnectionForRequest.

/**
 * Obtains a JDBC-Connection for the current request
 * @param fc the FacesContext
 * @param db the DBDatabase for which to obtain a connection
 * @param create if true a Connection will be created if not already present
 */
public Connection getConnectionForRequest(FacesContext fc, DBDatabase db, boolean create) {
    if (fc == null)
        throw new InvalidArgumentException("FacesContext", fc);
    if (db == null)
        throw new InvalidArgumentException("DBDatabase", db);
    // Get the ConnectionContextInfo map
    @SuppressWarnings("unchecked") Map<DBDatabase, Connection> connMap = (Map<DBDatabase, Connection>) FacesUtils.getRequestAttribute(fc, REQUEST_CONNECTION_MAP);
    if (connMap == null && create) {
        connMap = new HashMap<DBDatabase, Connection>(1);
        FacesUtils.setRequestAttribute(fc, REQUEST_CONNECTION_MAP, connMap);
    } else if (connMap == null) {
        // Nothing to do
        return null;
    }
    Connection conn = connMap.get(db);
    if (conn == null && create) {
        // Get Pooled Connection
        conn = getConnection(db);
        if (conn == null)
            throw new UnexpectedReturnValueException(this, "getConnection");
        // Add to map
        connMap.put(db, conn);
    }
    // done
    return conn;
}
Also used : InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException) DBDatabase(org.apache.empire.db.DBDatabase) UnexpectedReturnValueException(org.apache.empire.exceptions.UnexpectedReturnValueException) Connection(java.sql.Connection) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

InvalidArgumentException (org.apache.empire.exceptions.InvalidArgumentException)54 UnexpectedReturnValueException (org.apache.empire.exceptions.UnexpectedReturnValueException)6 NotSupportedException (org.apache.empire.exceptions.NotSupportedException)4 Connection (java.sql.Connection)3 Column (org.apache.empire.data.Column)3 NoPrimaryKeyException (org.apache.empire.db.exceptions.NoPrimaryKeyException)3 DBCompareExpr (org.apache.empire.db.expr.compare.DBCompareExpr)3 DBColumnJoinExpr (org.apache.empire.db.expr.join.DBColumnJoinExpr)3 ObjectNotValidException (org.apache.empire.exceptions.ObjectNotValidException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 ValueExpression (javax.el.ValueExpression)2 DBColumn (org.apache.empire.db.DBColumn)2 DBDatabase (org.apache.empire.db.DBDatabase)2 RecordUpdateFailedException (org.apache.empire.db.exceptions.RecordUpdateFailedException)2 DBDecodeExpr (org.apache.empire.db.expr.column.DBDecodeExpr)2 ItemNotFoundException (org.apache.empire.exceptions.ItemNotFoundException)2 PropertyDescriptor (java.beans.PropertyDescriptor)1