}
}
}
private UIInput createInputComponentForCol() {
DBTableColumn col = getColumn();
String controlType = col.getControlType();
// registerControl("text", new TextInputControl());
// registerControl("select", new SelectInputControl());
// registerControl("checkbox", new CheckboxInputControl());
// registerControl("phone", new PhoneInputControl());
// registerControl("radio", new RadioInputControl());
// registerControl("textarea", new TextAreaInputControl());
// registerControl("email", new EMailInputControl());
// registerControl("hlink", new HLinkInputControl());
// registerControl("password", new PasswordInputControl());
UIInput input = null;
if (controlType.equals("text")) {
// DATE_TIME
if (col.getDataType().equals(DataType.DATETIME))
{
HtmlInputText inputText = new HtmlInputText();
inputText.setReadonly(isReadOnly() || col.isAutoGenerated());
inputText.setLabel(getLabelString());
input = inputText;
}
// AUTOINC
else if (col.getDataType().equals(DataType.AUTOINC))
{
HtmlInputText inputText = new HtmlInputText();
inputText.setReadonly(true);
inputText.setLabel(getLabelString());
input = inputText;
}
// INTEGER
else if (col.getDataType().equals(DataType.INTEGER))
{
HtmlInputText inputText = new HtmlInputText();
inputText.setReadonly(isReadOnly() || col.isAutoGenerated());
inputText.setLabel(getLabelString());
input = inputText;
}
// DATE
else if (col.getDataType().equals(DataType.TEXT) || col.getDataType().equals(DataType.DATE)) {
HtmlInputText inputText = new HtmlInputText();
inputText.setReadonly(isReadOnly() || col.isAutoGenerated());
inputText.setLabel(getLabelString());
input = inputText;
}
// TEXT
else if (col.getDataType().equals(DataType.TEXT) || col.getDataType().equals(DataType.DATE)) {
HtmlInputText inputText = new HtmlInputText();
inputText.setReadonly(isReadOnly() || col.isAutoGenerated());
inputText.setLabel(getLabelString());
inputText.setMaxlength((int) Math.round(col.getSize()));
input = inputText;
}
}
else if (controlType.equals("textarea")) {
HtmlSelectBooleanCheckbox inputSelectBooleanCheckbox = new HtmlSelectBooleanCheckbox();
inputSelectBooleanCheckbox.setReadonly(isReadOnly() || col.isAutoGenerated());
inputSelectBooleanCheckbox.setLabel(getLabelString());
input = inputSelectBooleanCheckbox;
} else if (controlType.equals("password")) {
HtmlSelectBooleanCheckbox inputSelectBooleanCheckbox = new HtmlSelectBooleanCheckbox();
inputSelectBooleanCheckbox.setReadonly(isReadOnly() || col.isAutoGenerated());
inputSelectBooleanCheckbox.setLabel(getLabelString());
input = inputSelectBooleanCheckbox;
} else if (controlType.equals("select")) {
HtmlSelectOneMenu inputSelectOneMenu = new HtmlSelectOneMenu();
inputSelectOneMenu.setReadonly(isReadOnly() || col.isAutoGenerated());
addSelectItems(inputSelectOneMenu);
inputSelectOneMenu.setLabel(getLabelString());
input = inputSelectOneMenu;
} else if (controlType.equals("checkbox")) {
HtmlSelectBooleanCheckbox inputSelectBooleanCheckbox = new HtmlSelectBooleanCheckbox();
inputSelectBooleanCheckbox.setReadonly(isReadOnly() || col.isAutoGenerated());
inputSelectBooleanCheckbox.setLabel(getLabelString());
input = inputSelectBooleanCheckbox;
}
else if (controlType.equals("phone")) {
HtmlInputText inputText = new HtmlInputText();
inputText.setReadonly(isReadOnly() || col.isAutoGenerated());
inputText.setLabel(getLabelString());
inputText.setMaxlength((int) Math.round(col.getSize()));
input = inputText;
}
// For testing purposes only
if (input == null) {
log.error("No matching control found for column "
+ col.getFullName());
input = new HtmlInputText();
}
// JSF2 Validator
switch (col.getDataType()) {
case TEXT: {
input.addValidator(new LengthValidator((int) Math.round(col
.getSize())));
break;
}
}
input.setRequired(col.isRequired() && !col.isAutoGenerated());
input.setId(this.getId() + INPUT_SUFFIX);
input.setValue(getRecord().getValue(col));
return input;
}