Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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
Ajax PF SetPropertyActionListener在第一次之后中断_Ajax_Jsf_Primefaces_Actionlistener - Fatal编程技术网

Ajax PF SetPropertyActionListener在第一次之后中断

Ajax PF SetPropertyActionListener在第一次之后中断,ajax,jsf,primefaces,actionlistener,Ajax,Jsf,Primefaces,Actionlistener,我有个问题快把我逼疯了!我有一个组件,它呈现一个在页脚上有链接的面板。这个链接有一个标题和我想显示的HTML内容。基本上,当点击一个链接时,页面的内容通过ajax进行更改,链接的html内容显示出来,页脚保留在页面上。我注意到,第一次点击链接时,内容确实会发生变化,但之后不会发生变化。复合组件中p.commandlinks的setPropertyActionListener在第一次执行后不再执行。我已经解决了这个项目,这似乎是个问题,但我不知道为什么 我的复合组件的一部分。尝试在命令链接上设置o

我有个问题快把我逼疯了!我有一个组件,它呈现一个在页脚上有链接的面板。这个链接有一个标题和我想显示的HTML内容。基本上,当点击一个链接时,页面的内容通过ajax进行更改,链接的html内容显示出来,页脚保留在页面上。我注意到,第一次点击链接时,内容确实会发生变化,但之后不会发生变化。复合组件中p.commandlinks的setPropertyActionListener在第一次执行后不再执行。我已经解决了这个项目,这似乎是个问题,但我不知道为什么

我的复合组件的一部分。尝试在命令链接上设置onstart和oncomplete js函数,这两个函数都会执行,但actionListeners不会

<cc:interface>
    <cc:attribute name="compId"/>
    <cc:attribute name="title"/>
    <cc:attribute name="bean"/>
    ...
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
    <p:panel id="#{cc.attrs.compId}" header="#{cc.attrs.title}" 
             widgetVar="#{cc.attrs.compId}"
             styleClass="#{cc.attrs.styleClass}">  
        <h:form>
            <p:dataList id="datalist-#{cc.attrs.compId}" value="#{cc.attrs.bean.currentList}"
                        type="definition" widgetVar="datalist-#{cc.attrs.compId}"
                        var="items" >

                <p:commandLink action="#{navBean.active}" update="@([id$=content])" styleClass="link"
                               value="#{items.descrInLang}" rendered="#{items.typeUrl eq 0}">
                    <f:setPropertyActionListener value="infoPage" target="#{navBean.selection}"/>
                    <f:setPropertyActionListener value="#{items.descrInLang}" target="#{infoPage.title}" /> 
                    <f:setPropertyActionListener value="#{items.HTMLContent}" target="#{infoPage.HTMLContent}"/> 
                </p:commandLink>
            </p:dataList>
        </h:form>
    </p:panel>
</cc:implementation>
存储要显示的标题和HTML内容的bean。第一次单击链接后,将执行Title和HTML内容的getter,但setter与setPropertyActionListeners中声明的不同

@ManagedBean
@SessionScoped
public class InfoPage implements Serializable {

    private String title;
    private String HTMLContent;

    public InfoPage() {
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getHTMLContent() {
        return HTMLContent;
    }
    public void setHTMLContent(String HTMLContent) {
        this.HTMLContent = HTMLContent;
    }   
    }
模板的内容部分,指示根据NavBean上的所选页面应显示哪些内容。我将HTML内容和infoPage的标题作为参数传递

<h:head> 
    </h:head>    
    <h:body>
        <!-- the all containing file -->
        <ui:composition template="template.xhtml">
            <ui:define name="content">
                <h:panelGroup layout="block" id="content">
                    <h:panelGroup layout="block" rendered="#{navBean.home}">
                        <ui:include src="homecontent.xhtml"/>
                    </h:panelGroup>   
                     ....
                    <h:panelGroup layout="block" rendered="#{navBean.infoPage}">
                        <ui:include src="infoPage.xhtml">
                            <ui:param name="title" value="#{infoPage.title}"/>
                            <ui:param name="infoContent" value="#{infoPage.HTMLContent}"/>
                        </ui:include>
                    </h:panelGroup> 
                </h:panelGroup>
            </ui:define>
        </ui:composition>
    </h:body>
信息页面

<h:form id="infoPageForm">
    <p:panel id="infoPagePanel" header="#{title}">
        <h:panelGrid columns="1" cellpadding="10">
            <h:outputText escape="false" value="#{infoContent}" />
        </h:panelGrid>
    </p:panel>
</h:form> 

谢谢你的时间

您是否可以尝试专门更新所需的组件,从而不使用update=@all?重点是避免h:form的更新。这样做可能会干扰ajax请求。实际上,原始代码是update=@[id$=content],因为我们使用的是模板-唯一更新的是页面的中心内容,其中应该显示链接的信息。
<h:form id="infoPageForm">
    <p:panel id="infoPagePanel" header="#{title}">
        <h:panelGrid columns="1" cellpadding="10">
            <h:outputText escape="false" value="#{infoContent}" />
        </h:panelGrid>
    </p:panel>
</h:form>