Package javax.faces.component

Examples of javax.faces.component.UIInput


        // build testValidateBeanDisabledAndEnabled.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanDisabledAndEnabled.xhtml");
       
        // get the component instances
        UIInput input = (UIInput) root.findComponent("form:input");
       
        // the UIInput has to have the BeanValidator installed
        Assert.assertTrue(_hasValidator(input, BeanValidator.class));
    }
View Full Code Here


        // build testValidateBeanNestingAndNested.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanNestingAndNested.xhtml");
       
        // get the component instances
        UIInput nestedinput = (UIInput) root.findComponent("form:nestedinput");
        UIInput nestedinputWithValidator = (UIInput) root.findComponent("form:nestedinputWithValidator");
        UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput");
       
        // no wrapped UIInput has to have the BeanValidator installed,
        // except the one nesting <f:validateBean /> itself.
        Assert.assertFalse(_hasValidator(nestedinput, BeanValidator.class));
        Assert.assertTrue(_hasValidator(nestedinputWithValidator, BeanValidator.class));
View Full Code Here

        // build testValidateBean.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBean.xhtml");
       
        // get the component instances
        UIInput input = (UIInput) root.findComponent("form:input");
       
        // the validationGroups have to match
        Assert.assertEquals(validationGroups, _getValidationGroups(input));
    }
View Full Code Here

        // build testValidateBeanEmptyInput.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanEmptyInput.xhtml");
       
        // get the component instances
        UIInput input = (UIInput) root.findComponent("form:input");
       
        // the validationGroups have to match the Default ones
        Assert.assertEquals(javax.validation.groups.Default.class.getName(),
                _getValidationGroups(input));
    }
View Full Code Here

        // build testValidateBeanNesting.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanNesting.xhtml");
       
        // get the component instances
        UIInput nestedinput = (UIInput) root.findComponent("form:nestedinput");
        UIInput doublenestedinput = (UIInput) root.findComponent("form:doublenestedinput");
        UIInput nestedinput2 = (UIInput) root.findComponent("form:nestedinput2");
        UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput");
       
        // the validationGroups in the wrapped components have to match
        // org.apache.myfaces.beanvalidation.Group1 and the non-nested ones
        // have to match the Default group.
        Assert.assertEquals(validationGroups, _getValidationGroups(nestedinput));
View Full Code Here

        // build testValidateBeanNestingAndNested.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanNestingAndNested.xhtml");
       
        // get the component instances
        UIInput nestedinput = (UIInput) root.findComponent("form:nestedinput");
        UIInput nestedinputWithValidator = (UIInput) root.findComponent("form:nestedinputWithValidator");
        UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput");
       
        // the nested component without a validator must get the wrapping validationGroups,
        // the nested component with the validator must get the validationGroups from the
        // validator and the non-nested component must get the Default validationGroups.
        Assert.assertEquals(wrappingValidationGroups, _getValidationGroups(nestedinput));
View Full Code Here

        // build testValidateBeanDoubleNesting.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanDoubleNesting.xhtml");
       
        // get the component instances
        UIInput nestedinput = (UIInput) root.findComponent("form:nestedinput");
        UIInput doublenestedinput = (UIInput) root.findComponent("form:doublenestedinput");
        UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput");
       
        // the nested component must get the outer wrapping validationGroups,
        // the double-nested component must get the inner wrapping validationGroups
        // and the non-nested component must get the Default validationGroups.
        Assert.assertEquals(validationGroupsOuter, _getValidationGroups(nestedinput));
View Full Code Here

        // build testValidateBeanEmptyInput.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanEmptyInput.xhtml");
       
        // get the component instances
        UIInput input = (UIInput) root.findComponent("form:input");
       
        // the UIInput must not have the BeanValidator installed,
        // because bean validation is not available
        Assert.assertFalse(_hasValidator(input, BeanValidator.class));
    }
View Full Code Here

        // build testValidateBeanDoubleNesting.xhtml
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "testValidateBeanDisableDoubleNesting.xhtml");
       
        // get the component instances
        UIInput nestedinput = (UIInput) root.findComponent("form:nestedinput");
        UIInput doublenestedinput = (UIInput) root.findComponent("form:doublenestedinput");
        UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput");
        UIInput nesteouterdisabledinput = (UIInput) root.findComponent("form:nesteouterdisabledinput");
       
        // the nested component must get the outer wrapping validationGroups,
        // the double-nested component must get the inner wrapping validationGroups
        // and the non-nested component must get the Default validationGroups.
        Assert.assertEquals(validationGroupsOuter, _getValidationGroups(nestedinput));
View Full Code Here

        String string = (String) object;
        return string;
    }

    private static void validateEmptyString(FacesContext context, UIComponent component, String string) {
        UIInput input = (UIInput) component;
        if (input.isValid() && string != null && string.length() == 0) {
            if (input.getValidators() != null) {
                for (Validator validator : input.getValidators()) {
                    try {
                        validator.validate(context, input, string);
                    } catch (ValidatorException ve) {
                        // If the validator throws an exception, we're
                        // invalid, and we need to add a message
                        input.setValid(false);
                        FacesMessage message;
                        String validatorMessageString = input.getValidatorMessage();
                        if (null != validatorMessageString) {
                            message = new FacesMessage(FacesMessage.SEVERITY_ERROR, validatorMessageString,
                                validatorMessageString);
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        } else {
                            message = ve.getFacesMessage();
                        }
                        if (message != null) {
                            context.addMessage(input.getClientId(context), message);
                        }
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of javax.faces.component.UIInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.