FacesContext defaultFacesContext null при отображении пользовательского компонента - PullRequest
0 голосов
/ 14 января 2019

У нас есть шаблонное содержимое заголовка, в котором используется пользовательский компонент JSF, который не может перейти к EL, поскольку он не может получить атрибуты контекста лиц.

Я преобразовал некоторые старые POJO, которые расширяют класс SimpleFormController в Spring 3.0 для Spring 4.3, следующие аннотации:

Ссылка на пример преобразования Spring Simple Form Controller

Я отладил класс FacesContext, чтобы понять, почему, а класс jsf-api 2.0 использует defaultFacesContext для получения атрибутов, но его значение равно NULL. До обновления это была библиотека jsf-api 1.2_15

AppConfig.java


@Configuration
public class ApplicationConfig {

    @Bean
    public UrlBasedViewResolver urlBasedViewResolver()
    {

    UrlBasedViewResolver res = new UrlBasedViewResolver();
    res.setViewClass(JsfView.class);
    res.setPrefix("/WEB-INF/pages/");
    res.setSuffix(".xhtml");

    return res;
}


 FacesContext.java

/**
 * <p class="changed_added_2_0">Return a mutable <code>Map</code> 
 * representing the attributes associated wth this
 * <code>FacesContext</code> instance.  This <code>Map</code> is 
 * useful to store attributes that you want to go out of scope when the
 * Faces lifecycle for the current request ends, which is not always the same 
 * as the request ending, especially in the case of Servlet filters
 * that are invoked <strong>after</strong> the Faces lifecycle for this
 * request completes.  Accessing this <code>Map</code> does not cause any 
 * events to fire, as is the case with the other maps: for request, session, and 
 * application scope.  When {@link #release()} is invoked, the attributes
 * must be cleared.</p>
 * 
 * <div class="changed_added_2_0">
 * 
 * <p>The <code>Map</code> returned by this method is not associated with
 * the request.  If you would like to get or set request attributes,
 * see {@link ExternalContext#getRequestMap}.  
 * 
 * <p>The default implementation throws
 * <code>UnsupportedOperationException</code> and is provided
 * for the sole purpose of not breaking existing applications that extend
 * this class.</p>
 *
 * </div>
 * 
 * @throws IllegalStateException if this method is called after
 *  this instance has been released
 *
 * @since 2.0
 */
public Map<Object, Object> getAttributes() {

    if (defaultFacesContext != null) {
        return defaultFacesContext.getAttributes();
    }
    throw new UnsupportedOperationException();

}

.... получение ОШИБКИ:

    java.lang.UnsupportedOperationException
    at 
    javax.faces.context.FacesContext.getAttributes(FacesContext.java:141)
    at 

  javax.faces.component.UIComponent.popComponentFromEL(UIComponent.java:1722)
    at 

  javax.faces.component.UIComponentBase.publishAfterViewEvents(UIComponentBase.java:2022)
    at 

  javax.faces.component.UIComponentBase.doPostAddProcessing(UIComponentBase.java:1691)
    at 

  javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:403)

Мы бы хотели, чтобы компонент регистрировался и отображался в браузере.
Есть ли изменения в способе настройки обработчика jsf veiw с помощью jsf-api 2.0?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...