0

我在 jsf 页面上使用内联框架来呈现喜欢各种 commandMenuItem 的不同 jsff 页面,但页面没有正确呈现它给出的消息

此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。

并将页面内容显示为

如何克服这个问题并在内联框架内正确显示页面。当我们在不同的窗口中单独运行 jsff 页面时,我希望该页面在内联框架内显示类似。

4

2 回答 2

2

您不能使用内联框架引用 jsff 页面,您可以通过将 jsff 页面添加到任务流中并将任务流添加为区域来包含 jsff 页面,或者使用 jsp:include 标记

查看本指南http://docs.oracle.com/cd/E23943_01/web.1111/b31973/af_reuse.htm#CACHFJDJ

于 2013-03-20T12:08:42.550 回答
0

由于jsff页面不包含任何css和样式信息..所以它不会在内联框架内正确显示..但是我们可以在内联框架内显示完整的jsf页面..现在在内部显示动态jsf页面从jsf页面单击commandMenuItem上的内联框架......过程如下......

  1. 首先创建一个jsf页面(比如说welcome.jsf)..向它添加commanMenuItem ...
  2. 创建 2 个其他 jsf 页面,其中包含任何内容。
  3. 在第一个 jsf 页面(welcome.jsf)中提到 commandMenuItem 的 id 与创建的 2 个不同页面相同,例如。commandMenuItem 1 id = "first" 和 commandMenuItem2 id = "second" 其他 2 个不同页面的名称必须与 first 和 second 相同。
  4. 现在在 commandMenuItem 上创建一个动作侦听器 bean

    导入 javax.faces.event.ActionEvent;

公共类 PageBean {

String page = "home";//setting default page

public PageBean() {
}

public void getMenu(ActionEvent actionEvent) {
    // Add event code here...

    String id = actionEvent.getComponent().getId();
    System.out.println(" Menu ID : "+id);
    page = id;
    System.out.println("Value assigned to the page from the menu Id is :"+page);
}

public String getPage() {
    return page;
}

public void setPage(String page) {
    this.page = page;
}

}

现在在 secondCommandMeuItem 上也注册了相同的 actionListner bean

包含菜单的主页上的代码...是

<af:panelGroupLayout id="pgl1">
<af:menuBar id="mb1">
<af:menu text="menu 1" id="m1">
<af:commandMenuItem text="commandMenuItem 1" id="page1" actionListener="#{PageBean.getMenu}">
                <a4j:support event="onclick" reRender="if1"/>
            </af:commandMenuItem>
        </af:menu>
        <af:menu text="menu 2" id="m2">
            <af:commandMenuItem text="commandMenuItem 2" id="page2" actionListener="#{PageBean.getMenu}">
                <a4j:support event="onclick" reRender="if1"/>
            </af:commandMenuItem>
        </af:menu>
    </af:menuBar>
    <af:inlineFrame id="if1" source="#{PageBean.page}.jsf" shortDesc="areaMp" partialTriggers="page1 page2"/><!-- getting dynamic page source from the managed bean variable(page) by fetching the menu id which is similar to the corresponding page name
also add the commandMenuId of the menu's in the partial trigger of the inline frame. -->
</af:panelGroupLayout>

您可以在内联框架内包含和显示 jsf 页面,并且可以在 jsf 页面甚至 jsff(页面片段)上使用内联框架。

于 2013-03-22T06:27:10.987 回答