如何使用模板

时间:2016-01-15 11:56:23

标签: jsf-2 primefaces omnifaces

我处于continuation of pressing button twice

的相同情况

这是模板

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>SXGA</title>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
</h:head>
<h:body style="zoom: 1;">
    <h:panelGroup layout="block" styleClass="wrapper" id="wrapper">
            <ui:insert name="header">
                <ui:include src="/secured/template/commonHeader.xhtml" />
            </ui:insert>
            <ui:insert name="content">
                <ui:include src="/secured/template/commonContent.xhtml" />
            </ui:insert>
            <ui:insert name="footer">
                <ui:include src="/secured/template/commonFooter.xhtml" />
            </ui:insert>
    </h:panelGroup>
</h:body>
</html>

这是标题

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
<h:head>
<title>commonHeader</title>
<meta http-equiv="Content-Type"
    content="application/xhtml+xml; charset=UTF-8" />
</h:head>
<h:body>
    <ui:insert name="header">




        <ui:include src="/secured/template/commonMenu.xhtml" />
    </ui:insert>
</h:body>
</html>

这是菜单

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>commonMenu</title>
    <meta http-equiv="Content-Type"
        content="application/xhtml+xml; charset=UTF-8" />
</h:head>
<h:body>
    <ui:composition>
        <p:megaMenu orientation="horizontal" style="margin-top:20px">
            <p:submenu label="Gestione Rapporti" icon="ui-icon-check">
                <p:column>
                    <p:submenu label="TV.1">
                        <p:menuitem value="TV.1.1" url="#" />
                        <p:menuitem value="TV.1.2" url="#" />
                    </p:submenu>
                    <p:submenu label="TV.2">
                        <p:menuitem value="TV.2.1" url="#" />
                        <p:menuitem value="TV.2.2" url="#" />
                        <p:menuitem value="TV.2.3" url="#" />
                    </p:submenu>
                </p:column>

            </p:submenu>

            <p:submenu label="Autorizzazione Flussi" icon="ui-icon-document">

                <p:column >
                    <p:submenu label="Sports.1">
                        <p:menuitem value="Sports.1.1" url="#" />
                        <p:menuitem value="Sports.1.2" url="#" />
                    </p:submenu>
                    <p:submenu label="Sports.2">
                        <p:menuitem value="Sports.2.1" url="#" />
                        <p:menuitem value="Sports.2.2" url="#" />
                        <p:menuitem value="Sports.2.3" url="#" />
                    </p:submenu>
                </p:column>


            </p:submenu>

            <!--  <p:menuitem value="Quit" url="http://www.primefaces.org" icon="ui-icon-close" /> -->

            <f:facet name="options">
                <!--
                <h:form>
                    <h:commandLink action="#{loginBean.doLogout}" value="Logout" />
                </h:form>
                <h:form>
                    <h:commandButton value="Avanti" action="#{loginBean.doLogout}" styleClass="btn btn-primary"/>
                </h:form>
                -->
                <h:form>
                    <p:button value="Logout" outcome="#{loginBean.doLogout()}" id="iconOnly" icon="ui-icon-power" title="Icon Only" />
                </h:form>
            </f:facet>

        </p:megaMenu>
    </ui:composition>
</h:body>
</html>

这是典型的页面

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>SXGAWEB</title>
    <meta http-equiv="Content-Type"
        content="application/xhtml+xml; charset=UTF-8" />
</h:head>
<h:body>
    <ui:composition template="/secured/template/commonTemplate.xhtml">
    </ui:composition>
</h:body>

</html>

在我使用之前

<h:form>
    <h:commandLink action="#{loginBean.doLogout}" value="Logout" />
</h:form>

<h:form>
    <h:commandButton value="Avanti" action="#{loginBean.doLogout}" styleClass="btn btn-primary"/>
</h:form>

所有问题都开始使用PrimeFaces。

有了BalusC的建议continuation of pressing button twice我已经或多或少地解决了。

<p:button ... outcome="otherViewId" />

我无法理解真正的问题。与模板有关或一般与JSF的正常使用有关。

https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-790中,可能的解决方案是使用OmniFaces或来自Prime Faces http://showcase.omnifaces.org/scripts/FixViewState的相同脚本

这里提到了一个可能的解决方案 how to fixe twice needed click inside JSF page?

并且

h:commandButton/h:commandLink does not work on first click, works only on second click 解决方案是脚本。

我也读过

commandButton/commandLink/ajax action/listener method not invoked or input value not updated

Which XHTML files do I need to put in /WEB-INF and which not?

0 个答案:

没有答案