@Override
  public Object getAsObject(FacesContext context, UIComponent component, String value) {

    if (context == null) {
      throw new NullPointerException("context");
    }
    if (component == null) {
      throw new NullPointerException("component");
    }
    FacesContext ctx = FacesContext.getCurrentInstance();
    ValueExpression vex =
        ctx.getApplication()
            .getExpressionFactory()
            .createValueExpression(
                ctx.getELContext(), "#{managedBeanUnidadMedida}", ManagedBeanUnidadMedida.class);
    ManagedBeanUnidadMedida unidades = (ManagedBeanUnidadMedida) vex.getValue(ctx.getELContext());
    UnidadMedida unidad;
    try {
      unidad = unidades.getUnidadMedida(new Integer(value));
    } catch (NumberFormatException e) {
      FacesMessage message =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Valor Desconocido",
              "Este no es un Numero de Unidad de Medida");
      throw new ConverterException(message);
    }
    if (unidad == null) {
      FacesMessage message =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR, "Valor Desconocido", "La Unidad de Medida desconocida");
      throw new ConverterException(message);
    }
    return unidad;
  }
Esempio n. 2
0
  //
  // Event processing: Creates a datatable and adds a component to it.
  //
  @Override
  public void processEvent(SystemEvent event) throws AbortProcessingException {
    FacesContext context = FacesContext.getCurrentInstance();
    if (!context.isPostback()) {
      Application application = context.getApplication();

      HtmlDataTable dataTable = new HtmlDataTable();
      dataTable.setVar("_internal");
      dataTable.setValueExpression(
          "value",
          application
              .getExpressionFactory()
              .createValueExpression(context.getELContext(), "#{addBean.list}", Object.class));
      getChildren().add(dataTable);

      UIColumn column = new UIColumn();
      column.setId(context.getViewRoot().createUniqueId());
      dataTable.getChildren().add(column);

      HtmlOutputText outputText = new HtmlOutputText();
      outputText.setId(context.getViewRoot().createUniqueId());
      outputText.setValueExpression(
          "value",
          application
              .getExpressionFactory()
              .createValueExpression(context.getELContext(), "#{_internal}", Object.class));
      column.getChildren().add(outputText);
    }
  }
  public static UIComponent addPersistent(
      FacesContext context,
      ServletRequest req,
      UIComponent parent,
      ValueExpression binding,
      Class childClass)
      throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    if (parent == null) {
      UIComponentClassicTagBase parentTag =
          (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent");

      parent = parentTag.getComponentInstance();

      BodyContent body = parentTag.getBodyContent();

      addVerbatim(parent, body);
    }

    UIComponent child = null;

    if (binding != null) child = (UIComponent) binding.getValue(context.getELContext());

    if (child == null) {
      child = (UIComponent) childClass.newInstance();

      // jsf/3251
      if (binding != null) binding.setValue(context.getELContext(), child);
    }

    if (parent != null) parent.getChildren().add(child);

    return child;
  }
  public static UIComponent addFacet(
      FacesContext context,
      ServletRequest req,
      UIComponent parent,
      String facetName,
      ValueExpression binding,
      Class childClass)
      throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    if (parent == null) {
      UIComponentClassicTagBase parentTag =
          (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent");

      parent = parentTag.getComponentInstance();
    }

    UIComponent child = null;

    if (binding != null) child = (UIComponent) binding.getValue(context.getELContext());

    if (child == null) child = (UIComponent) childClass.newInstance();

    if (parent != null) parent.getFacets().put(facetName, child);

    if (binding != null) binding.setValue(context.getELContext(), child);

    return child;
  }
Esempio n. 5
0
  @Override
  public Object getAsObject(FacesContext context, UIComponent component, String value) {

    if (context == null) {
      throw new NullPointerException("context");
    }
    if (component == null) {
      throw new NullPointerException("component");
    }
    FacesContext ctx = FacesContext.getCurrentInstance();
    ValueExpression vex =
        ctx.getApplication()
            .getExpressionFactory()
            .createValueExpression(
                ctx.getELContext(), "#{managedBeanDepartamento}", ManagedBeanDepartamento.class);
    ManagedBeanDepartamento managedBean =
        (ManagedBeanDepartamento) vex.getValue(ctx.getELContext());
    Departamento objeto;
    try {
      objeto = managedBean.traerObjeto(value);

    } catch (NumberFormatException e) {
      FacesMessage message =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR, "Valor Desconocido", "NumberFormatException");
      throw new ConverterException(message);
    }
    if (objeto == null) {
      FacesMessage message =
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Valor Desconocido", "Object NULL");
      throw new ConverterException(message);
    }
    return objeto;
  }
    public void processEvent(FacesEvent event) throws AbortProcessingException {

      FacesContext faces = FacesContext.getCurrentInstance();
      if (faces == null) {
        return;
      }

      L instance = null;
      if (this.binding != null) {
        instance = (L) binding.getValue(faces.getELContext());
      }
      if (instance == null && this.type != null) {
        try {
          instance = (L) TagHandlerUtils.loadClass(this.type, Object.class).newInstance();
        } catch (Exception e) {
          throw new AbortProcessingException("Couldn't Lazily instantiate EventListener", e);
        }
        if (this.binding != null) {
          binding.setValue(faces.getELContext(), instance);
        }
      }

      if (instance != null) {
        event.processListener(instance);
      }
    }
Esempio n. 7
0
  /**
   * This method looks up the parent object given a parentObjectExpression (Universal EL expression)
   *
   * @param facesContext
   * @param parentObjectExpression
   * @return
   */
  @DependsOnJSF
  @SuppressWarnings("deprecation")
  protected Object lookupParentObject(FacesContext facesContext) {
    if (parentClassOfTheField == null) {
      if (parentObject != null) {
        return parentObject;
      }
      assert parentObjectExpression != null;
      try {
        parentObject =
            facesContext
                .getApplication()
                .evaluateExpressionGet(facesContext, parentObjectExpression, Object.class);
        // JSF 1.1
        if (parentObject == null) {
          parentObject =
              facesContext
                  .getApplication()
                  .createValueBinding(parentObjectExpression)
                  .getValue(facesContext);
        }
        // JSF 1.2
        if (parentObject == null) {
          parentObject =
              facesContext
                  .getApplication()
                  .getExpressionFactory()
                  .createValueExpression(
                      facesContext.getELContext(), parentObjectExpression, parentClassOfTheField)
                  .getValue(facesContext.getELContext());
        }
        if (parentObject == null) {
          parentObject =
              facesContext
                  .getApplication()
                  .getExpressionFactory()
                  .createValueExpression(
                      facesContext.getELContext(), parentObjectExpression, Object.class)
                  .getValue(facesContext.getELContext());
        }
      } catch (Exception ex) {
        // System.out.println("All attempted methods failed!");
        ex.printStackTrace();
        assert facesContext != null;
        parentObject =
            facesContext
                .getApplication()
                .createValueBinding(parentObjectExpression)
                .getValue(facesContext);
        // System.out.println("Method in catch block = " + (parentObject==null?"failed":"passed"));
        assert parentObject != null;
      }
    }

    if (parentObject != null) {
      this.parentClassOfTheField = parentObject.getClass();
    }
    return parentObject;
  }
Esempio n. 8
0
  private void restoreView(FacesContext context) throws FacesException {
    Application app = context.getApplication();

    if (app instanceof ApplicationImpl) ((ApplicationImpl) app).initRequest();

    ViewHandler view = app.getViewHandler();

    view.initView(context);

    UIViewRoot viewRoot = context.getViewRoot();

    if (viewRoot != null) {
      ExternalContext extContext = context.getExternalContext();

      viewRoot.setLocale(extContext.getRequestLocale());

      doSetBindings(context.getELContext(), viewRoot);

      return;
    }

    String viewId = calculateViewId(context);

    String renderKitId = view.calculateRenderKitId(context);

    RenderKitFactory renderKitFactory =
        (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);

    RenderKit renderKit = renderKitFactory.getRenderKit(context, renderKitId);

    ResponseStateManager stateManager = renderKit.getResponseStateManager();

    if (stateManager.isPostback(context)) {
      viewRoot = view.restoreView(context, viewId);

      if (viewRoot != null) {
        doSetBindings(context.getELContext(), viewRoot);
      } else {
        // XXX: backward compat issues with ViewHandler and StateManager

        // throw new ViewExpiredException(L.l("{0} is an expired view", viewId));

        context.renderResponse();

        viewRoot = view.createView(context, viewId);

        context.setViewRoot(viewRoot);
      }

      context.setViewRoot(viewRoot);
    } else {
      context.renderResponse();

      viewRoot = view.createView(context, viewId);

      context.setViewRoot(viewRoot);
    }
  }
  /**
   * Recuperar informações de outro bean
   *
   * @param nomeDoBean
   * @return
   */
  public Object acessarOutroBean(String nomeDoBean) {

    FacesContext context = FacesContext.getCurrentInstance();

    return context
        .getELContext()
        .getELResolver()
        .getValue(context.getELContext(), null, nomeDoBean);
  }
Esempio n. 10
0
  /**
   * @param expressao
   * @param obj
   * @param clazz
   */
  public void setAtributo(String expressao, Object obj, Class clazz) {

    FacesContext current = FacesContext.getCurrentInstance();

    Application app = current.getApplication();

    ExpressionFactory fac = app.getExpressionFactory();

    ValueExpression ve = fac.createValueExpression(current.getELContext(), expressao, clazz);
    ve.setValue(current.getELContext(), obj);
  }
Esempio n. 11
0
  protected void initMap(Map<Expression, Expression> source, Map target, FacesContext context) {

    for (Map.Entry<Expression, Expression> entry : source.entrySet()) {
      Expression k = entry.getKey();
      Expression v = entry.getValue();
      //noinspection unchecked
      target.put(
          k.evaluate(context.getELContext()),
          (v != null) ? v.evaluate(context.getELContext()) : null);
    }
  }
Esempio n. 12
0
  /**
   * @param hierarchy
   * @return
   */
  protected UIComponent createFilterItem(Hierarchy hierarchy) {
    String id = "filter-item-" + hierarchy.getUniqueName().hashCode();

    HtmlPanelGroup panel = new HtmlPanelGroup();
    panel.setId(id);
    panel.setLayout("block");
    panel.setStyleClass("ui-widget-header filter-item");

    CommandLink link = new CommandLink();
    link.setId(id + "-link");
    link.setValue(hierarchy.getCaption());
    link.setTitle(hierarchy.getUniqueName());

    FacesContext context = FacesContext.getCurrentInstance();
    ExpressionFactory factory = context.getApplication().getExpressionFactory();

    link.setActionExpression(
        factory.createMethodExpression(
            context.getELContext(), "#{filterHandler.show}", Void.class, new Class<?>[0]));
    link.setUpdate(":filter-form");
    link.setOncomplete("PF('filterDialog').show();");

    UIParameter parameter = new UIParameter();
    parameter.setName("hierarchy");
    parameter.setValue(hierarchy.getName());

    link.getChildren().add(parameter);

    panel.getChildren().add(link);

    CommandButton closeButton = new CommandButton();
    closeButton.setId(id + "-button");
    closeButton.setIcon("ui-icon-close");
    closeButton.setActionExpression(
        factory.createMethodExpression(
            context.getELContext(),
            "#{filterHandler.removeHierarchy}",
            Void.class,
            new Class<?>[0]));
    closeButton.setUpdate(
        ":filter-items-form,:source-tree-form,:grid-form,:editor-form:mdx-editor,:editor-form:editor-toolbar");
    closeButton.setOncomplete("onViewChanged()");

    UIParameter parameter2 = new UIParameter();
    parameter2.setName("hierarchy");
    parameter2.setValue(hierarchy.getName());

    closeButton.getChildren().add(parameter2);

    panel.getChildren().add(closeButton);

    return panel;
  }
Esempio n. 13
0
  /**
   * @param exp
   * @param clazz
   * @return
   */
  public Object getAtributo(String exp, Class clazz) {

    FacesContext current = FacesContext.getCurrentInstance();

    Application app = current.getApplication();

    ExpressionFactory fac = app.getExpressionFactory();

    ValueExpression ve = fac.createValueExpression(current.getELContext(), exp, clazz);
    Object resultado = ve.getValue(current.getELContext());

    return resultado;
  }
Esempio n. 14
0
  protected ResourceHolder getResourceHolder() {
    FacesContext facesContext = getFacesContext();
    if (facesContext == null) return null;

    ValueExpression ve =
        facesContext
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                facesContext.getELContext(), "#{primeFacesResourceHolder}", ResourceHolder.class);

    return (ResourceHolder) ve.getValue(facesContext.getELContext());
  }
 /** 初始化页面事,将个人信息初始化显示 */
 public void initPersonInfo() {
   FacesContext tFacesContext = FacesContext.getCurrentInstance();
   ValueExpression tValueExpression =
       tFacesContext
           .getApplication()
           .getExpressionFactory()
           .createValueExpression(
               tFacesContext.getELContext(), "#{webVisitor.user.userCode}", String.class);
   String userCode = (String) tValueExpression.getValue(tFacesContext.getELContext());
   System.out.println("userCode===" + userCode);
   if (canModify(userCode)) {
     find(userCode);
   }
 }
Esempio n. 16
0
  @Override
  public void processUpdates(FacesContext context) {
    super.processUpdates(context);

    if (!isRendered() || !isValid()) {
      return;
    }

    javax.el.ValueExpression ve = getValueExpression(SELECTED_LABEL_ATTR);

    if (ve != null && !ve.isReadOnly(context.getELContext())) {
      ve.setValue(context.getELContext(), getSelectedIndex());
      setSelectedIndex(null);
    }
  }
Esempio n. 17
0
  private static ELContext _getELContext(FacesContext context, ELResolver resolver) {
    // Hopefully, we have a FacesContext.  If not, we're
    // going to have to synthesize one!
    if (context != null) return context.getELContext();

    return new ELContextImpl(resolver);
  }
Esempio n. 18
0
 public static String getArrayValue(String name, Long id, FacesContext fc) {
   if (name.compareTo("Nazioni") == 0) {
     return (String)
         ((PropertiesHandler) JSFUtils.getManagedBean("propertiesHandler"))
             .getNazioni()
             .get(id)
             .getNazione();
   } else if (name.compareTo("Province") == 0) {
     return (String)
         ((PropertiesHandler) JSFUtils.getManagedBean("propertiesHandler"))
             .getProvince()
             .get(id)
             .getProvincia();
   } else if (name.compareTo("Comuni") == 0) {
     return (String)
         ((PropertiesHandler) JSFUtils.getManagedBean("propertiesHandler"))
             .getComuni()
             .get(id)
             .getComune();
   } else {
     ArrayList<Object> array =
         (ArrayList<Object>)
             fc.getApplication().getELResolver().getValue(fc.getELContext(), null, name);
     return (String) array.get(id.intValue());
   }
 }
 private String relatedControllerOutcome() {
   String relatedControllerString = JsfUtil.getRequestParameter("jsfcrud.relatedController");
   String relatedControllerTypeString =
       JsfUtil.getRequestParameter("jsfcrud.relatedControllerType");
   if (relatedControllerString != null && relatedControllerTypeString != null) {
     FacesContext context = FacesContext.getCurrentInstance();
     Object relatedController =
         context
             .getApplication()
             .getELResolver()
             .getValue(context.getELContext(), null, relatedControllerString);
     try {
       Class<?> relatedControllerType = Class.forName(relatedControllerTypeString);
       Method detailSetupMethod = relatedControllerType.getMethod("detailSetup");
       return (String) detailSetupMethod.invoke(relatedController);
     } catch (ClassNotFoundException e) {
       throw new FacesException(e);
     } catch (NoSuchMethodException e) {
       throw new FacesException(e);
     } catch (IllegalAccessException e) {
       throw new FacesException(e);
     } catch (InvocationTargetException e) {
       throw new FacesException(e);
     }
   }
   return null;
 }
Esempio n. 20
0
 public static TimeOffController getController() {
   FacesContext fc = FacesContext.getCurrentInstance();
   return (TimeOffController)
       fc.getApplication()
           .getELResolver()
           .getValue(fc.getELContext(), null, "timeOffController");
 }
Esempio n. 21
0
  public void updateModel(FacesContext facesContext) {
    if (facesContext == null) {
      throw new NullPointerException();
    }

    if (!isValid() || !isLocalValueSet()) {
      return;
    }

    ValueExpression ve = getValueExpression("value");
    if (ve == null) {
      return;
    }

    Throwable caught = null;
    FacesMessage message = null;
    try {
      ve.setValue(facesContext.getELContext(), getLocalValue());
      setValue(null);
      setLocalValueSet(false);
    } catch (ELException e) {
      caught = e;
      String messageStr = e.getMessage();
      Throwable result = e.getCause();
      while (null != result && result.getClass().isAssignableFrom(ELException.class)) {
        messageStr = result.getMessage();
        result = result.getCause();
      }

      if (messageStr == null) {
        message =
            ServiceTracker.getService(MessageFactory.class)
                .createMessage(
                    facesContext,
                    FacesMessage.SEVERITY_ERROR,
                    FacesMessages.UIINPUT_UPDATE,
                    MessageUtil.getLabel(facesContext, this));
      } else {
        message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr);
      }
      setValid(false);
    } catch (Exception e) {
      caught = e;
      // message = MessageFactory.getMessage(facesContext, UPDATE_MESSAGE_ID,
      // MessageFactory.getHeader(facesContext, this));
      setValid(false);
    }

    if (caught != null) {
      assert message != null;

      @SuppressWarnings({"ThrowableInstanceNeverThrown"})
      UpdateModelException toQueue = new UpdateModelException(message, caught);
      ExceptionQueuedEventContext eventContext =
          new ExceptionQueuedEventContext(facesContext, toQueue, this, PhaseId.UPDATE_MODEL_VALUES);
      facesContext
          .getApplication()
          .publishEvent(facesContext, ExceptionQueuedEvent.class, eventContext);
    }
  }
Esempio n. 22
0
 private ValueExpression crearValueExpression(String expresion) {
   FacesContext facesContext = FacesContext.getCurrentInstance();
   return facesContext
       .getApplication()
       .getExpressionFactory()
       .createValueExpression(facesContext.getELContext(), "#{" + expresion + "}", Object.class);
 }
 public static MethodExpression createMethodExpression(
     String el, Class returnType, Class[] paramTypes) {
   FacesContext context = FacesContext.getCurrentInstance();
   ExpressionFactory factory = ExpressionFactory.newInstance();
   return factory.createMethodExpression(
       context.getELContext(), el, null, new Class[] {String.class});
 }
Esempio n. 24
0
  public static Converter getItemConverter(FacesContext facesContext, UIComponent component) {
    Converter converter = null;
    if (component instanceof ValueHolder) {
      // If the component has an attached Converter, use it.
      converter = ((ValueHolder) component).getConverter();
      if (converter != null) {
        return converter;
      }
    }
    // If not, look for a ValueExpression for value (if any). The ValueExpression must point to
    // something that is:
    ValueExpression ve = component.getValueExpression("value");
    if (ve != null) {
      Class<?> valueType = ve.getType(facesContext.getELContext());
      // An array of primitives (such as int[]). Look up the registered by-class Converter for this
      // primitive type.
      // An array of objects (such as Integer[] or String[]). Look up the registered by-class
      // Converter for the underlying element type.
      if (valueType != null && valueType.isArray()) {
        converter = facesContext.getApplication().createConverter(valueType);
      }
      // A java.util.Collection. Do not convert the values.
    }
    if (converter == null) {
      // Spec says "If for any reason a Converter cannot be found, assume the type to be a String
      // array." However
      // if we don't have an explicit converter, see if one is registered for the class of the
      // SelectItem values
      Iterator<SelectItem> selectItems = SelectUtils.getSelectItems(facesContext, component);
      converter = getSelectItemConverter(facesContext.getApplication(), selectItems);
    }

    return converter;
  }
Esempio n. 25
0
 /**
  * Creates value expression from string and stores expression's expected type
  *
  * @param expression string with EL expressions
  * @param expectedType the type expected from expression after evaluation
  * @return value expression from string and stores expression's expected type
  */
 public static ValueExpression createValueExpression(String expression, Class<?> expectedType) {
   FacesContext context = FacesContext.getCurrentInstance();
   return context
       .getApplication()
       .getExpressionFactory()
       .createValueExpression(context.getELContext(), expression, expectedType);
 }
Esempio n. 26
0
  protected Converter createConverter() throws JspException {
    FacesContext context = FacesContext.getCurrentInstance();
    ELContext elctx = context.getELContext();

    if (binding != null) {
      Converter boundConverter = (NumberConverter) binding.getValue(elctx);
      if (boundConverter != null) return boundConverter;
    }

    NumberConverter converter = new NumberConverter();

    if (currencyCode != null) converter.setCurrencyCode((String) currencyCode.getValue(elctx));
    if (currencySymbol != null)
      converter.setCurrencySymbol((String) currencySymbol.getValue(elctx));
    if (groupingUsed != null) converter.setGroupingUsed((Boolean) groupingUsed.getValue(elctx));
    if (integerOnly != null) converter.setIntegerOnly((Boolean) integerOnly.getValue(elctx));
    if (maxFractionDigits != null)
      converter.setMaxFractionDigits((Integer) maxFractionDigits.getValue(elctx));
    if (minFractionDigits != null)
      converter.setMinFractionDigits((Integer) minFractionDigits.getValue(elctx));
    if (minIntegerDigits != null)
      converter.setMinIntegerDigits((Integer) minIntegerDigits.getValue(elctx));
    if (pattern != null) converter.setPattern((String) pattern.getValue(elctx));
    if (type != null) converter.setType((String) type.getValue(elctx));

    Locale loc = null;
    if (locale != null) loc = FacesUtils.getLocaleFromExpression(context, locale);
    if (loc == null) loc = context.getViewRoot().getLocale();
    converter.setLocale(loc);

    if (binding != null) binding.setValue(elctx, converter);
    return converter;
  }
Esempio n. 27
0
      /**
       * Updates the <code>SelectItem</code> properties based on the current value.
       *
       * @param ctx the {@link FacesContext} for the current request
       * @param value the value to build the updated values from
       */
      private void updateItem(FacesContext ctx, Object value) {

        Map<String, Object> reqMap = ctx.getExternalContext().getRequestMap();
        Object oldVarValue = null;
        if (var != null) {
          oldVarValue = reqMap.put(var, value);
        }
        try {
          ELContext elContext = ctx.getELContext();
          setValue(((itemValue != null) ? itemValue.getValue(elContext) : value));
          setLabel(
              ((itemLabel != null) ? (String) itemLabel.getValue(elContext) : value.toString()));
          setDescription(
              ((itemDescription != null) ? (String) itemDescription.getValue(elContext) : null));
          setEscape(((itemEscaped != null) ? (Boolean) itemEscaped.getValue(elContext) : false));
          setDisabled(
              ((itemDisabled != null) ? (Boolean) itemDisabled.getValue(elContext) : false));
          setNoSelectionOption(
              ((noSelectionOption != null)
                  ? (Boolean) noSelectionOption.getValue(elContext)
                  : false));
        } finally {
          if (var != null) {
            if (oldVarValue != null) {
              reqMap.put(var, oldVarValue);
            } else {
              reqMap.remove(var);
            }
          }
        }
      }
Esempio n. 28
0
 public void closeListener(CloseEvent event) {
   FacesContext context = FacesContext.getCurrentInstance();
   MethodExpression ajaxEventListener = (MethodExpression) getAttributes().get("closeListener");
   if (ajaxEventListener != null) {
     ajaxEventListener.invoke(context.getELContext(), new Object[] {event});
   }
 }
Esempio n. 29
0
 private void resolveBindings() {
   FacesContext context = null;
   if (parameters != null) {
     for (int i = 0; i < parameters.length; i++) {
       Object o = parameters[i];
       if (o instanceof ValueBinding) {
         if (context == null) {
           context = FacesContext.getCurrentInstance();
         }
         o = ((ValueBinding) o).getValue(context);
       }
       if (o instanceof ValueExpression) {
         if (context == null) {
           context = FacesContext.getCurrentInstance();
         }
         o = ((ValueExpression) o).getValue(context.getELContext());
       }
       // to avoid 'null' appearing in message
       if (o == null) {
         o = "";
       }
       resolvedParameters[i] = o;
     }
   }
 }
Esempio n. 30
0
  @SuppressWarnings("unchecked")
  private Collection<String> getCollectionValue(
      String propertyName, Collection<String> collection) {
    if (collection != null) {
      return collection;
    }

    Collection<String> result = null;
    ValueExpression expression = getValueExpression(propertyName);

    if (expression != null) {

      FacesContext ctx = FacesContext.getCurrentInstance();
      Object value = expression.getValue(ctx.getELContext());

      if (value != null) {

        if (value instanceof Collection) {
          // Unchecked cast to Collection<String>
          return (Collection<String>) value;
        }

        result = toList(propertyName, expression, value);
      }
    }

    return result == null ? Collections.<String>emptyList() : result;
  }