вторник, 17 декабря 2013 г.

Как добраться до свойства определенного в бине


Можно через функцию  JSFUtils.resolveExpression() например так:


RichCommandLink link = (RichCommandLink)JSFUtils.resolveExpression(
            "#{viewScope.ContractsTableBean.warningLink}");




Сама функция(метод JSFUtils) определена так:

/**
      * Method for taking a reference to a JSF binding expression and returning
      * the matching object (or creating it).
      * @param expression EL expression
      * @return Managed object
      */
     public static Object resolveExpression(String expression)
     {
       FacesContext facesContext = getFacesContext();
       Application app = facesContext.getApplication();
       ExpressionFactory elFactory = app.getExpressionFactory();
       ELContext elContext = facesContext.getELContext();
       ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
       return valueExp.getValue(elContext);
     }

Комментариев нет:

Отправить комментарий