Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过ajax将PrimeFaces调度JSF页面加载到另一个JSF页面_Javascript_Ajax_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Javascript 通过ajax将PrimeFaces调度JSF页面加载到另一个JSF页面

Javascript 通过ajax将PrimeFaces调度JSF页面加载到另一个JSF页面,javascript,ajax,jsf,jsf-2,primefaces,Javascript,Ajax,Jsf,Jsf 2,Primefaces,当我将prime faces Scheduler组件作为一个普通的xhtml页面运行时,一切正常,但当我尝试通过AJAX将schedule.xhtml页面加载到另一个xhtml页面时,我会出现以下意外行为: schedule.xhtml页面没有加载其Java类附带的默认事件—这些事件是示例事件。 没有像addEvent、onEventSelect、onDateSelect、onEventMove和onEventResize那样触发事件 我正在运行JSF2.2Mojarra2.2.0 素数面5.0

当我将prime faces Scheduler组件作为一个普通的xhtml页面运行时,一切正常,但当我尝试通过AJAX将schedule.xhtml页面加载到另一个xhtml页面时,我会出现以下意外行为:

schedule.xhtml页面没有加载其Java类附带的默认事件—这些事件是示例事件。 没有像addEvent、onEventSelect、onDateSelect、onEventMove和onEventResize那样触发事件 我正在运行JSF2.2Mojarra2.2.0 素数面5.0

下面是我的xhtml主页

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 

<h:head>
<h:outputStylesheet library="css" name="default.css"  />
</h:head> 
    <body> 

<p:layout fullPage="true" >
    <p:layoutUnit position="north" size="185"  resizable="false" closable="false" collapsible="false" >     
        <div align="center" id="header">
         <h:graphicImage url="images/layout/banner.png" ></h:graphicImage>
        </div>
    </p:layoutUnit>

    <p:layoutUnit position="west" size="210" header="Booking System" resizable="true" closable="false" collapsible="true" >
        <h:form>                
            <p:growl autoUpdate="false"/>
            <p:growl id="growl" life="2000" />

            <p:panelMenu  style="width:200px" >
                <p:separator />
                <p:submenu label="Navigations" ajax="false" >

                     <p:menuitem ajax="false" value="Book Meeting"  action="#{menuView.setMyPage}"  icon="ui-icon-calendar"  update=":formCenter:content">
                        <f:param name="page" value="scheduler" />
                     </p:menuitem>                                      
                 </p:submenu>
            </p:panelMenu>                                  
        </h:form>       
    </p:layoutUnit>

    <p:layoutUnit position="center" >   
        <h:form id="formCenter"  >

        <p:outputPanel autoUpdate="false">
            <h:panelGroup id="content" layout="block"  > 
                 <ui:include  src="#{menuView.page}.xhtml" />
            </h:panelGroup>
        </p:outputPanel>                   
         </h:form> 
    </p:layoutUnit>  
</p:layout>

</body> 
</html>
调度器xhtml页面如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 

<h:head>

<style type="text/css">
    .value {
        width: 1000px;
    }
</style>

</h:head> 
<body> 

<h:form>
    <p:growl id="messages" showDetail="true" />

    <h:panelGrid columnClasses="value">
        <h3 style="margin-top: 0">Editable Schedule</h3>
        <p:schedule id="schedule" value="#{scheduleView.eventModel}" widgetVar="myschedule" timeZone="GMT+2">

            <p:ajax event="dateSelect" listener="#{scheduleView.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
            <p:ajax event="eventSelect" listener="#{scheduleView.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
            <p:ajax event="eventMove" listener="#{scheduleView.onEventMove}" update="messages" />
            <p:ajax event="eventResize" listener="#{scheduleView.onEventResize}" update="messages" />

        </p:schedule>

        <h3>Locale Support ( Example: Turkish )</h3>
        <p:schedule id="scheduleLocale" value="#{scheduleView.eventModel}" locale="tr" />

        <h3>Lazy Schedule</h3>
        <p:schedule value="#{scheduleView.lazyEventModel}" />
    </h:panelGrid>

    <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
        <h:panelGrid id="eventDetails" columns="2">
            <h:outputLabel for="title" value="Title:" />
            <p:inputText id="title" value="#{scheduleView.event.title}" required="true" />

            <h:outputLabel for="from" value="From:" />
            <p:inputMask id="from" value="#{scheduleView.event.startDate}" mask="99/99/9999">
                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+2"/>
            </p:inputMask>

            <h:outputLabel for="to" value="To:" />
            <p:inputMask id="to" value="#{scheduleView.event.endDate}" mask="99/99/9999">
                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+2"/>
            </p:inputMask>

            <h:outputLabel for="allDay" value="All Day:" />
            <h:selectBooleanCheckbox id="allDay" value="#{scheduleView.event.allDay}" />

            <p:commandButton type="reset" value="Reset" />
            <p:commandButton id="addButton" value="Save" actionListener="#{scheduleView.addEvent}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();" />
        </h:panelGrid>
    </p:dialog>    
</h:form>

<script type="text/javascript">
    PrimeFaces.locales['tr'] = {
        closeText: 'kapat',
        prevText: 'geri',
        nextText: 'ileri',
        currentText: 'bugün',
        monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran',
            'Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
        monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz',
            'Tem','Ağu','Eyl','Eki','Kas','Ara'],
        dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
        dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
        dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
        weekHeader: 'Hf',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: '',
        month: 'Ay',
        week: 'Hafta',
        day: 'Gün',
        allDayText : 'Tüm Gün'
    };
</script>


</body> 
</html>
有什么建议吗? 谢谢。

问题解决了

在schedule.xhtml中,我用如下所示的标记替换了h:head和body:

         <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                        xmlns:h="http://java.sun.com/jsf/html"
                        xmlns:f="http://java.sun.com/jsf/core"
                        xmlns:p="http://primefaces.org/ui"
                        xmlns:ui="http://java.sun.com/jsf/facelets">

   <h:form>
    <p:growl id="messages" showDetail="true" />

    <h:panelGrid columnClasses="value">
        <h3 style="margin-top: 0">Editable Schedule</h3>
        <p:schedule id="schedule" value="#{scheduleView.eventModel}" widgetVar="myschedule" timeZone="GMT+2">

            <p:ajax event="dateSelect" listener="#{scheduleView.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
            <p:ajax event="eventSelect" listener="#{scheduleView.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
            <p:ajax event="eventMove" listener="#{scheduleView.onEventMove}" update="messages" />
            <p:ajax event="eventResize" listener="#{scheduleView.onEventResize}" update="messages" />

        </p:schedule>

        <h3>Locale Support ( Example: Turkish )</h3>
        <p:schedule id="scheduleLocale" value="#{scheduleView.eventModel}" locale="tr" />

        <h3>Lazy Schedule</h3>
        <p:schedule value="#{scheduleView.lazyEventModel}" />
    </h:panelGrid>

    <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
        <h:panelGrid id="eventDetails" columns="2">
            <h:outputLabel for="title" value="Title:" />
            <p:inputText id="title" value="#{scheduleView.event.title}" required="true" />

            <h:outputLabel for="from" value="From:" />
            <p:inputMask id="from" value="#{scheduleView.event.startDate}" mask="99/99/9999">
                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+2"/>
            </p:inputMask>

            <h:outputLabel for="to" value="To:" />
            <p:inputMask id="to" value="#{scheduleView.event.endDate}" mask="99/99/9999">
                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+2"/>
            </p:inputMask>

            <h:outputLabel for="allDay" value="All Day:" />
            <h:selectBooleanCheckbox id="allDay" value="#{scheduleView.event.allDay}" />

            <p:commandButton type="reset" value="Reset" />
            <p:commandButton id="addButton" value="Save" actionListener="#{scheduleView.addEvent}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();" />
        </h:panelGrid>
    </p:dialog>    
</h:form>


    </ui:composition>

这解决了我的问题,它按预期加载,所有事件都被触发。

有javascript错误吗?并删除include文件中的h:head和body。。。可能会引起奇怪的行为谢谢你的重播。没有JavaScript错误,而且在删除h:head和body之后,它也无法工作。如果第一个和默认包含的页面是计划页面,我可以解决问题并使其工作,但是如果我有一个包含更多项的菜单,而第一个包含的项不是计划页面,当我单击菜单项以显示计划时,问题就发生了。我需要理解为什么会发生这种行为!如果删除面板上的“自动更新”,该怎么办?我想我在某个地方读到过,错误或缺席并不会导致同样的行为。你能为这种情况试用更新版本的PF吗?或者看看这个,给这个菜单项一个ajax=false,然后重新加载整个页面。看看这是否有效,您已经使用了ajax=false。那么不需要更新属性。。。这可能会引起问题吗?这就是为什么我想知道!您发布的链接几乎与我遇到的问题相同,他通过禁用ajax修复了我正在做的!。但我的问题仍然存在!