Package javax.faces.component

Examples of javax.faces.component.UIInput$ValueChangeListenerAdapter


        Facelet at = f.getFacelet("validateLongRange.xml");

        UIViewRoot root = faces.getViewRoot();
        at.apply(faces, root);
       
        UIInput input = (UIInput) root.findComponent("form:input");
       
        assertNotNull("input", input);
       
        assertEquals("input validator", 1, input.getValidators().length);
       
        Validator v = input.getValidators()[0];
       
        v.validate(faces, input, new Long(2000));
    }
View Full Code Here


        Facelet at = f.getFacelet("valueChangeListener.xml");

        UIViewRoot root = faces.getViewRoot();
        at.apply(faces, root);
       
        UIInput input = (UIInput) root.findComponent("form:input");
       
        assertNotNull("input", input);
       
        assertEquals("input listener", 1, input.getValueChangeListeners().length);
    }
View Full Code Here

        if (empty)
        {
            if (uiComponent instanceof UIInput)
            {
                UIInput uiInput = (UIInput) uiComponent;
                if (uiInput.getRequiredMessage() != null)
                {
                    String requiredMessage = uiInput.getRequiredMessage();
                    throw new ValidatorException(new FacesMessage(
                            FacesMessage.SEVERITY_ERROR, requiredMessage,
                            requiredMessage));
                }
            }
View Full Code Here

        }
    }
   
    public void postUpdateModel(UIComponent comp, InputInfo ii, FacesContext fc)
    {
        UIInput input = getInputComponent(comp);
        if (input==null)
            return; /* May want to override this */
        // Clear submitted value
        clearSubmittedValue(input);
    }
View Full Code Here

        clearSubmittedValue(input);
    }
   
    public Object getInputValue(UIComponent comp, InputInfo ii, boolean submitted)
    {
        UIInput input = getInputComponent(comp);
        if (input==null)
            throw new ObjectNotValidException(this);
       
        // Get value from Input
        Object value = (submitted) ? input.getSubmittedValue() : input.getValue();
        /* Patch for MyFaces?
        if (value==null && input.isLocalValueSet())
            value = input.getLocalValue();
        */

        if (submitted)
        {
            if (value!=null) // && (!ObjectUtils.compareEqual(value, input.getLocalValue())
            {
                // Disabled
                if (ii.isDisabled())
                {   // Ignore submitted value
                    log.debug("Ignoring submitted value for disabled field {}.", ii.getColumn().getName());
                    input.setSubmittedValue(null);
                    // throw new FieldIsReadOnlyException(ii.getColumn());
                    return null;
                }   
                // Save submitted value
                FacesContext fc = FacesContext.getCurrentInstance();
                Map<String, Object> reqMap = fc.getExternalContext().getRequestMap();
                // Save submitted value
                String clientId = input.getClientId();
                if (reqMap.containsKey(clientId))
                {
                    log.warn("OOps, what is going on here?");
                }           
                reqMap.put(clientId, value);
View Full Code Here

        // default implementation
        int count = parent.getChildCount();
        if (count<1)
            return null;
        // find the UIInput component (only one allowed)
        UIInput inp = null;
        for (int i=0; i<count; i++)
        {  // check UIInput
          UIComponent comp = parent.getChildren().get(i);
          if (comp instanceof UIInput)
          {  if (inp!=null)
View Full Code Here

    @Override
    public void encodeBegin(FacesContext context)
        throws IOException
    {
        // add label and input components when the view is loaded for the first time
        UIInput inputComponent = null;
        TextResolver textResolver = FacesUtils.getTextResolver(context);
        if (getChildCount() > 0)
        {
            inputComponent = getInputComponent();
            if (inputComponent instanceof HtmlSelectOneMenu)
            {
                SelectInputControl control = (SelectInputControl)InputControlManager.getControl(SelectInputControl.NAME);
                // disabled
                boolean disabled = isDisabled();
                ((HtmlSelectOneMenu)inputComponent).setDisabled(disabled);
                // Options (sync)
                Options options = getOptionList();
                boolean hasEmpty = isAllowNull() && !options.contains("");
                control.syncOptions((HtmlSelectOneMenu)inputComponent, textResolver, options, hasEmpty, getNullText());
                setInputValue((HtmlSelectOneMenu)inputComponent);
            }
            else
            {   // Something's wrong here?
                log.warn("WARN: Unexpected child node for {}! Child item type is {}.", getClass().getName(), inputComponent.getClass().getName());
                inputComponent = null;
            }
        }
        if (inputComponent == null)
        {
            inputComponent = createSelectOneMenu(textResolver);
            this.getChildren().add(0, inputComponent);
        }
        // render components
        inputComponent.encodeAll(context);
        // default
        super.encodeBegin(context);
    }
View Full Code Here

    public void updateModel(FacesContext context)
    {
        // check read only
        if (!isDisabled())
        {
            UIInput inputComponent = getInputComponent();
           
            Object value = inputComponent == null "" :  inputComponent.getValue();
            if (value == null)
                value = "";
            setValue(value);
        }
        super.updateModel(context);
View Full Code Here

    @Override
    public void validate(FacesContext context)
    {
        // nothing submitted (AJAX part request, e.g. calendar component) or readonly (won't be set
        // in updateModel())?
        UIInput inputComponent = getInputComponent();
        if (inputComponent == null)
        {
            return;
        }
        // component itself already checked validity, was it successful?
        if (!inputComponent.isValid() || isDisabled())
        {
            return;
        }
        // nothing to do
        super.validate(context);
View Full Code Here

{
    public String enableValidation()
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();

        UIInput number1 = (UIInput)facesContext.getViewRoot().findComponent("form1:number1");
        Validator[] validators = number1.getValidators();
        if (validators == null || validators.length == 0)
        {
            number1.addValidator(new LongRangeValidator(10, 1));
        }

        UIInput number2 = (UIInput)facesContext.getViewRoot().findComponent("form1:number2");
        validators = number2.getValidators();
        if (validators == null || validators.length == 0)
        {
            number2.addValidator(new LongRangeValidator(50, 20));
        }

        UIInput text = (UIInput)facesContext.getViewRoot().findComponent("form2:text");
        validators = text.getValidators();
        if (validators == null || validators.length == 0)
        {
            text.addValidator(new LengthValidator(7, 3));
        }

        return "ok";
    }
View Full Code Here

TOP

Related Classes of javax.faces.component.UIInput$ValueChangeListenerAdapter

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.