Search in sources :

Example 6 with HtmlInputText

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);
    }
}
Also used : UnexpectedReturnValueException(org.apache.empire.exceptions.UnexpectedReturnValueException) UIComponent(javax.faces.component.UIComponent) HtmlInputText(javax.faces.component.html.HtmlInputText)

Example 7 with HtmlInputText

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");
}
Also used : HtmlInputText(javax.faces.component.html.HtmlInputText)

Example 8 with HtmlInputText

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);
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) HtmlInputText(javax.faces.component.html.HtmlInputText)

Example 9 with HtmlInputText

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);
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) HtmlInputText(javax.faces.component.html.HtmlInputText)

Example 10 with HtmlInputText

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);
            }
        }
    }
}
Also used : HtmlInputText(javax.faces.component.html.HtmlInputText) UIInput(javax.faces.component.UIInput) FacesMessage(javax.faces.application.FacesMessage) Date(java.util.Date) LocalDate(java.time.LocalDate)

Aggregations

HtmlInputText (javax.faces.component.html.HtmlInputText)10 UIComponent (javax.faces.component.UIComponent)2 ValidatorException (javax.faces.validator.ValidatorException)2 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1 Application (javax.faces.application.Application)1 FacesMessage (javax.faces.application.FacesMessage)1 UIInput (javax.faces.component.UIInput)1 UISelectItems (javax.faces.component.UISelectItems)1 HtmlInputTextarea (javax.faces.component.html.HtmlInputTextarea)1 HtmlSelectOneMenu (javax.faces.component.html.HtmlSelectOneMenu)1 FacesContext (javax.faces.context.FacesContext)1 MethodBinding (javax.faces.el.MethodBinding)1 ValueBinding (javax.faces.el.ValueBinding)1 InvalidArgumentException (org.apache.empire.exceptions.InvalidArgumentException)1 UnexpectedReturnValueException (org.apache.empire.exceptions.UnexpectedReturnValueException)1 HtmlCalendar (org.santfeliu.faces.component.jqueryui.HtmlCalendar)1