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