English 中文(简体)
Null
原标题:FaceletContext is Null

我有一个共同基金2.0项目,我无法从中获取一个内容。

这里是我的网站:xml:

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
    <param-value>/index.xhtml</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.application.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

我可以取得“面对面”案文,但不能获得“面对面”案文。 问题在于:

            FacesContext fctx = FacesContext.getCurrentInstance(); //works
    //FaceletContext f2ctx = (FaceletContext) fctx.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
    FaceletContext f2ctx = (FaceletContext) fctx.getELContext().getContext(FaceletContext.class);

Can anyone assist?

最新情况:

以上是我的总体目标中的一个幻灯塔:在需求时装上含有方言的立 face文件,然后添加到父母身上。 下面的法典不完整,但应当解释我正在做什么。 请注意,该信使用总理图书馆,因此是请求查阅。

public void launch() {

    form.getChildren().clear();

    FacesContext fctx = FacesContext.getCurrentInstance();
    for (Object o: fctx.getAttributes().keySet()) {
        System.out.println(o.toString());
    }

    FaceletContext f2ctx = (FaceletContext) fctx.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
    //FaceletContext f2ctx = (FaceletContext) fctx.getELContext().getContext(FaceletContext.class);
    dialog = new Dialog();

    try {
        f2ctx.includeFacelet(dialog, "/WEB-INF/facelets/dialog/manager.xhtml");
        form.getChildren().add(dialog);
    } catch (IOException ex) {
        log.debug(ex.toString());
    }

    RequestContext.getCurrentInstance().update("mainPageCenterForm");
}
问题回答

It will be null when you try to access it before the view is ever been built. For example, during the beforePhase of RESTORE_VIEW phase. Rearrange your code logic. It s not clear what s the functional requirement is and where exactly you re trying to access it, so I can t give a more suited answer.


<> Unrelated to the specific problem, thecode>javax.faces.FUL_STATE_SAVING_VIEW_IDSignored when the part State Save is Disability. 也许这不是你的意图? 另见这一相关答案:。 否





相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签