use of javax.faces.component.html.HtmlInputText in project empire-db by apache.
the class TextInputControl method updateInputState.
@Override
protected void updateInputState(List<UIComponent> compList, InputInfo ii, FacesContext context, PhaseId phaseId) {
UIComponent comp = compList.get(0);
if (!(comp instanceof HtmlInputText)) {
throw new UnexpectedReturnValueException(comp.getClass().getName(), "compList.get(0)");
}
HtmlInputText input = (HtmlInputText) comp;
if (ii.isInsideUIData()) {
// always reset the style class inside UIData
String tagStyle = StringUtils.toString(ii.getAttribute("styleClass"), null);
String cssStyle = getInputStyleClass(ii, tagStyle);
input.setStyleClass(cssStyle);
/*
String curStyle = input.getStyleClass();
if (curStyle==null || !curStyle.equals(cssStyle))
{ // log.info("{} -> {} vs '{}'", ii.getColumn().getName(), inpStyle, reqStyle);
input.setStyleClass(cssStyle);
}
*/
}
// required
addRemoveStyle(input, InputControl.STYLECLASS_REQUIRED, ii.isRequired());
// modified
addRemoveStyle(input, InputControl.STYLECLASS_MODIFIED, ii.isModified());
// disabled
DisabledType disabled = ii.getDisabled();
if (disabled != null) {
input.setReadonly((disabled == DisabledType.READONLY));
input.setDisabled((disabled == DisabledType.DISABLED));
}
// set value
if (phaseId == PhaseId.RENDER_RESPONSE) {
// style
addRemoveDisabledStyle(input, (disabled != null && disabled != DisabledType.NO));
addRemoveInvalidStyle(input, ii.hasError());
// set value
setInputValue(input, ii);
}
}
use of javax.faces.component.html.HtmlInputText in project myfaces-build-tools by apache.
the class PhoneNumberConverterTest method testAreaCodeNum.
public void testAreaCodeNum() throws Exception {
Object obj = phoneNumConverter.getAsObject(facesContext, new HtmlInputText(), "09-6373824");
assertNotNull(obj);
PhoneNumber phoneNum = (PhoneNumber) obj;
assertEquals(phoneNum.getAreaCode(), "09");
assertEquals(phoneNum.getNumber(), "6373824");
}
use of javax.faces.component.html.HtmlInputText in project myfaces-build-tools by apache.
the class OddNumberValidatorTest method testOddNumInput.
public void testOddNumInput() throws Exception {
boolean noExceptionsThrown = true;
try {
oddNumValidator.validate(facesContext, new HtmlInputText(), new Integer(3));
} catch (ValidatorException ve) {
noExceptionsThrown = false;
}
assertTrue(noExceptionsThrown);
}
use of javax.faces.component.html.HtmlInputText in project myfaces-build-tools by apache.
the class OddNumberValidatorTest method testEvenNumInput.
public void testEvenNumInput() throws Exception {
boolean noExceptionsThrown = true;
try {
oddNumValidator.validate(facesContext, new HtmlInputText(), new Integer(8));
} catch (ValidatorException ve) {
noExceptionsThrown = false;
}
assertFalse(noExceptionsThrown);
}
use of javax.faces.component.html.HtmlInputText in project TNTConcept by autentia.
the class ActivityBean method validateHoursGeneric.
public void validateHoursGeneric(FacesContext context, UIComponent toValidate, Object value, String tabName) {
HtmlInputText startTimeHour = (HtmlInputText) FacesUtils.getComponent("activity").findComponent(tabName).findComponent("startTimeHour");
HtmlInputText startTimeMinute = (HtmlInputText) FacesUtils.getComponent("activity").findComponent(tabName).findComponent("startTimeMinute");
HtmlInputText endTimeHour = (HtmlInputText) FacesUtils.getComponent("activity").findComponent(tabName).findComponent("endTimeHour");
HtmlInputText endTimeMinute = (HtmlInputText) FacesUtils.getComponent("activity").findComponent(tabName).findComponent("endTimeMinute");
HtmlInputText duration = (HtmlInputText) FacesUtils.getComponent("activity").findComponent(tabName).findComponent("duration");
if (startTimeHour.getSubmittedValue() != null && startTimeMinute.getSubmittedValue() != null && endTimeHour.getSubmittedValue() != null && endTimeMinute.getSubmittedValue() != null) {
Date startTime = DateUtils.timeToDate(Integer.valueOf(startTimeHour.getSubmittedValue().toString()).intValue(), Integer.valueOf(startTimeMinute.getSubmittedValue().toString()).intValue());
Date endTime = DateUtils.timeToDate(Integer.valueOf(endTimeHour.getSubmittedValue().toString()).intValue(), Integer.valueOf(endTimeMinute.getSubmittedValue().toString()).intValue());
if (toValidate.equals(startTimeHour) || toValidate.equals(startTimeMinute)) {
if (startTime.after(endTime)) {
((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage("La hora de inicio no puede ser posterior a la hora de fin");
context.addMessage(toValidate.getClientId(context), message);
}
}
if (toValidate.equals(endTimeHour) || toValidate.equals(endTimeMinute)) {
if (startTime.before(endTime)) {
((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage("La hora de fin no puede ser anterior a la hora inicial");
context.addMessage(toValidate.getClientId(context), message);
}
}
if (toValidate.equals(duration)) {
if (Integer.valueOf(duration.getSubmittedValue().toString()).intValue() < 0) {
((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage("La duracion no puede ser negativa");
context.addMessage(toValidate.getClientId(context), message);
}
}
}
}
Aggregations