Package javax.faces.component

Examples of javax.faces.component.EditableValueHolder


        String id = component.getId();
        component.setId(id); // forces the cilent id to be reset

        if (component instanceof EditableValueHolder)
        {
            EditableValueHolder input = (EditableValueHolder) component;
            String clientId = component.getClientId(context);
            SavedState state = (SavedState) _saved.get(clientId);
            if (state == null)
            {
                state = new SavedState();
            }
            input.setValue(state.getValue());
            input.setValid(state.isValid());
            input.setSubmittedValue(state.getSubmittedValue());
            input.setLocalValueSet(state.isLocalValueSet());
        }

        List kids = component.getChildren();
        for (int i = 0; i < kids.size(); i++)
        {
View Full Code Here


            Object value;

            if(component instanceof EditableValueHolder) {

                EditableValueHolder holder = (EditableValueHolder) component;
               
                if(holder.isLocalValueSet()) {
                    value = holder.getLocalValue();
                } else {
                    value = getValue(component);
                }
            }
            else {
View Full Code Here

    private static void callValidators(FacesContext context, UIComponent input, Object convertedValue)
    {
        if(!(input instanceof EditableValueHolder))
            throw new FacesException("param input not of type EditableValueHolder, but of : "+input.getClass().getName());

        EditableValueHolder holder = (EditableValueHolder) input;

        Validator[] validators = holder.getValidators();
        for (int i = 0; i < validators.length; i++)
        {
            Validator validator = validators[i];
            try
            {
                validator.validate(context, input, convertedValue);
            }
            catch (ValidatorException e)
            {
                holder.setValid(false);
                FacesMessage facesMessage = e.getFacesMessage();
                if (facesMessage != null)
                {
                    facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(input.getClientId(context), facesMessage);
                }
            }
        }

        MethodBinding validatorBinding = holder.getValidator();
        if (validatorBinding != null)
        {
            try
            {
                validatorBinding.invoke(context, new Object[] {context, input, convertedValue});
            }
            catch (EvaluationException e)
            {
                holder.setValid(false);
                Throwable cause = e.getCause();
                if (cause instanceof ValidatorException)
                {
                    FacesMessage facesMessage = ((ValidatorException) cause).getFacesMessage();
                    if (facesMessage != null)
View Full Code Here

        UIComponent foreignComp = uiComponent.getParent().findComponent(_for);
        if(foreignComp==null)
            throw new FacesException("Unable to find component '" + _for + "' (calling findComponent on component '" + uiComponent.getId() + "')");
        if(false == foreignComp instanceof EditableValueHolder)
            throw new FacesException("Component '" + foreignComp.getId() + "' does not implement EditableValueHolder");
        EditableValueHolder foreignEditableValueHolder = (EditableValueHolder) foreignComp;

        if (foreignEditableValueHolder.isRequired() && foreignEditableValueHolder.getValue()== null ) {
            return;
        }

    Object[] args = {value.toString(),(foreignEditableValueHolder.getValue()==null) ? foreignComp.getId():foreignEditableValueHolder.getValue().toString()};

    if(foreignEditableValueHolder.getValue()==null || !foreignEditableValueHolder.getValue().toString().equals(value.toString())  )
        {
            throw new ValidatorException(getFacesMessage(EQUAL_MESSAGE_ID, args));
        }

  }
View Full Code Here

    String id = c.getId();
    c.setId(id);

    // hack
    if (c instanceof EditableValueHolder) {
      EditableValueHolder evh = (EditableValueHolder) c;
      String clientId = c.getClientId(faces);
      SavedState ss = (SavedState) childState.get(clientId);
      if (ss != null) {
        ss.apply(evh);
      } else {
View Full Code Here

   * @return
   */
  public String getValueAsString(FacesContext context, UIComponent component) {
    // First - get submitted value for input components
    if (component instanceof EditableValueHolder) {
      EditableValueHolder input = (EditableValueHolder) component;
      String submittedValue = (String) input.getSubmittedValue();
      if (null != submittedValue) {
        return submittedValue;
      }
    }
    // If no submitted value presented - convert same for UIInput/UIOutput
View Full Code Here

     * ClientBehaviorContext)
     */
    public ConverterDescriptor getConverter(ClientBehaviorContext context) throws ConverterNotFoundException {
        UIComponent component = context.getComponent();
        if (component instanceof EditableValueHolder) {
            EditableValueHolder input = (EditableValueHolder) component;
            FacesContext facesContext = context.getFacesContext();
            Converter converter = input.getConverter();
            if (null == converter) {
                Class<?> valueType;
                ValueExpression valueExpression = component.getValueExpression(VALUE);
                if (null != valueExpression) {
                    valueType = valueExpression.getType(facesContext.getELContext());
View Full Code Here

     */
    public Collection<ValidatorDescriptor> getValidators(ClientBehaviorContext context) {
        UIComponent component = context.getComponent();
        if (component instanceof EditableValueHolder) {
            Collection<ValidatorDescriptor> validators = Lists.newArrayList();
            EditableValueHolder input = (EditableValueHolder) component;
            Validator[] facesValidators = input.getValidators();
            FacesContext facesContext = context.getFacesContext();
            if (facesValidators.length > 0) {
                String validatorMessage = (String) component.getAttributes().get("validatorMessage");
                boolean beanValidatorsProcessed = false;
                FacesValidatorService facesValidatorService = ServiceTracker.getService(facesContext,
View Full Code Here

        super.processEvent(event);

        if (event instanceof PostAddToViewEvent) {
            FacesContext facesContext = FacesContext.getCurrentInstance();

            EditableValueHolder component = (EditableValueHolder) event.getComponent();

            Validator validator = facesContext.getApplication().createValidator(SelectLabelValueValidator.ID);
            component.addValidator(validator);
        }
    }
View Full Code Here

    /** Converts submitted value to Object (local component value) */
    public static Object convertToObject(FacesContext context, UIComponent component){
        if (!(component instanceof EditableValueHolder))
            throw new IllegalArgumentException("Expected component of type EditableValueHolder. Cannot convert submitted value.");
       
        EditableValueHolder holder = (EditableValueHolder)component;
       
        if (!(holder.getSubmittedValue() instanceof String))
            throw new ClassCastException("Submitted value must be a String value.");
       
        String submittedValue = (String)holder.getSubmittedValue();
        Converter conv = holder.getConverter();
       
        // no conversion needed
        if (conv == null) return(submittedValue);
       
        return(conv.getAsObject(context, component, submittedValue));
View Full Code Here

TOP

Related Classes of javax.faces.component.EditableValueHolder

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.