use of javax.faces.component.html.HtmlInputText in project gdmatrix by gdmatrix.
the class QueryInstanceBean method addParameterComponent.
private void addParameterComponent(Query.Parameter parameter, String expression, HtmlPanelGroup exprPanelGroup) {
FacesContext context = FacesContext.getCurrentInstance();
String sql = parameter.getSql();
if (StringUtils.isBlank(sql)) {
String format = parameter.getFormat();
ValueBinding valueBinding;
if (Query.Parameter.DATE.equals(format)) {
HtmlCalendar calendar = new HtmlCalendar();
calendar.setId("input_" + id);
String expr = "#{queryInstanceBean." + expression + "['" + parameter.getName() + "']}";
valueBinding = context.getApplication().createValueBinding(expr);
calendar.setValueBinding("value", valueBinding);
calendar.setStyleClass("input_value date");
exprPanelGroup.getChildren().add(calendar);
} else {
HtmlInputText inputText = new HtmlInputText();
inputText.setId("input_" + id);
String expr = "#{queryInstanceBean." + expression + "['" + parameter.getName() + "']}";
valueBinding = context.getApplication().createValueBinding(expr);
inputText.setValueBinding("value", valueBinding);
inputText.setStyleClass("input_value");
String title = parameter.getDescription() == null ? parameter.getName() : parameter.getDescription();
inputText.setTitle(title);
inputText.setAlt(title);
inputText.setSize(parameter.getSize());
if (Query.Parameter.NUMBER.equals(format)) {
Application application = context.getApplication();
MethodBinding method = application.createMethodBinding("#{queryInstanceBean.validateNumber}", new Class[] { FacesContext.class, UIComponent.class, Object.class });
inputText.setValidator(method);
}
exprPanelGroup.getChildren().add(inputText);
}
Object value = valueBinding.getValue(context);
if (value == null) {
String defaultValue = parameter.getDefaultValue();
if (!StringUtils.isBlank(defaultValue)) {
valueBinding.setValue(context, String.valueOf(defaultValue));
}
}
} else // selectOneMenu
{
HtmlSelectOneMenu selectOneMenu = new HtmlSelectOneMenu();
selectOneMenu.setId("input_" + id);
String expr = "#{queryInstanceBean." + expression + "['" + parameter.getName() + "']}";
ValueBinding valueBinding = context.getApplication().createValueBinding(expr);
selectOneMenu.setValueBinding("value", valueBinding);
selectOneMenu.setStyleClass("input_value select");
id++;
UISelectItems uiSelectItems = new UISelectItems();
uiSelectItems.setId("items_" + id);
expr = "#{queryInstanceBean.parameterSelectItemsMap['" + parameter.getName() + "']}";
ValueBinding itemsValue = context.getApplication().createValueBinding(expr);
uiSelectItems.setValueBinding("value", itemsValue);
selectOneMenu.getChildren().add(uiSelectItems);
exprPanelGroup.getChildren().add(selectOneMenu);
}
}
use of javax.faces.component.html.HtmlInputText in project gdmatrix by gdmatrix.
the class WidgetTestBean method addInputText.
public String addInputText() {
int size = panel.getChildCount();
HtmlInputText input = new HtmlInputText();
input.setId("input_id_" + size);
input.setValue("child #" + size);
panel.getChildren().add(input);
return null;
}
use of javax.faces.component.html.HtmlInputText in project myfaces-build-tools by apache.
the class PhoneNumberConverterTest method testNumOnly.
public void testNumOnly() throws Exception {
Object obj = phoneNumConverter.getAsObject(facesContext, new HtmlInputText(), "6373824");
assertNotNull(obj);
PhoneNumber phoneNum = (PhoneNumber) obj;
assertEquals(phoneNum.getNumber(), "6373824");
}
use of javax.faces.component.html.HtmlInputText in project liferay-faces-alloy by liferay.
the class OutputRemainingChars method getMaxLength.
@Override
public Integer getMaxLength() {
Integer maxLength = super.getMaxLength();
// try to get the maxlength from the associated input component.
if (maxLength == null) {
String forComponent = getFor();
if (forComponent == null) {
logger.error("getMaxLength: Please specify a 'for' attribute for the outputRemainingChars component.");
} else {
UIComponent inputComponent = findComponent(forComponent);
if (inputComponent != null) {
if (inputComponent instanceof HtmlInputText) {
HtmlInputText htmlInputText = (HtmlInputText) inputComponent;
maxLength = htmlInputText.getMaxlength();
} else if (inputComponent instanceof HtmlInputTextarea) {
HtmlInputTextarea htmlInputTextarea = (HtmlInputTextarea) inputComponent;
Object maxLengthObject = htmlInputTextarea.getAttributes().get("maxlength");
if (maxLengthObject != null) {
maxLength = Integer.parseInt(maxLengthObject.toString());
}
}
}
}
}
return maxLength;
}
use of javax.faces.component.html.HtmlInputText 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());
}
Aggregations