< p:ajax>无法附加< p:ajax>到非ClientBehaviorHolder父级 [英] <p:ajax> Unable to attach <p:ajax> to non-ClientBehaviorHolder parent

查看:89
本文介绍了< p:ajax>无法附加< p:ajax>到非ClientBehaviorHolder父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JSF 2,primefaces 4.0,并且尝试使用DataTable-In-Cell Editing,因为它是在primefaces展示柜中制作的,但我有一个错误,尽管我复制了展示柜中显示的相同示例 错误是

I use JSF 2 , primefaces 4.0 and i try to use DataTable - In-Cell Editing as it's produced in primefaces showcase, but i have an error althought i copied the same example shown in showcase the error is

<p:ajax> Unable to attach <p:ajax> to non-ClientBehaviorHolder parent

这是xhtmlpagecode

this is the xhtmlpagecode

 <rich:panel  style="width : 800px; height : 551px; " > 
     <f:facet name="header" >

<h:outputText value="Tableau des articles" align="center" style="FONT-SIZE: small;"/>
            </f:facet>


    <h:form id="form">

   <p:dataTable id="cars" var="car" value="#{articlesbean.LMatpilotaccess1}" editable="true" editMode="cell" widgetVar="carsTable">  

        <f:facet name="header">  
            Matériel du pilotage et accessoires 
        </f:facet>  
  <p:growl id="messages" showDetail="true"/>  

    <p:contextMenu for="cars" widgetVar="cMenu">     
        <p:menuitem value="Edit Cell" icon="ui-icon-search" onclick="PF('carsTable').showCellEditor();return false;"/>    
        <p:menuitem value="Hide Menu" icon="ui-icon-close" onclick="PF('cMenu').hide()"/>    
    </p:contextMenu>   


        <p:column headerText="Serie" style="width:25%">  
               <p:ajax event="cellEdit" listenner="#{articlesbean.onCellEdit}" update=":form:messages" /> 

               <p:cellEditor>  
                   <f:facet name="output"><h:outputText value="#{car.serie}" /></f:facet>  
                   <f:facet name="input"><p:inputText id="modelInput" value="#{car.serie}" style="width:96%"/></f:facet>  
               </p:cellEditor>  
           </p:column>  



    </p:dataTable>  


    </h:form>




</rich:panel>

这是我的豆子

@ManagedBean(name="articlesbean")

@ViewScoped
public class ArticlesBean implements Serializable{

    @Inject
    private ArticlesDAO articleDAO;
    @Inject
    private Matpilotaccess1 matpilotaccess1;
    @Inject
    private Matpilotaccess2 matpilotaccess2;
    @Inject
    private Poteaux poteaux ;
    @Inject
    private Travgc1 travgc1;
    @Inject
    private Travgc2 travgc2;
    @Inject
    private Travresurbain travresurbain;


    private List LMatpilotaccess1 = new ArrayList();
    private List LMatpilotaccess2 = new ArrayList();
    private List LPoteaux = new ArrayList();
    private List LTravgc1 = new ArrayList();
    private List LTravgc2 = new ArrayList();
    private List LTravresurbain = new ArrayList();




    public void onCellEdit(CellEditEvent event) {  
        Object oldValue = event.getOldValue();  
        Object newValue = event.getNewValue();  

        if(newValue != null && !newValue.equals(oldValue)) {  
            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);  
            FacesContext.getCurrentInstance().addMessage(null, msg);  
        }  
    } 

    //// Getters and setters

推荐答案

您将<p:ajax>嵌套在<p:column>内. <p:ajax>必须嵌套在实现 ClientBehaviorHolder的组件中界面.但是,<p:column>后面的 Column组件类没有实现它. <p:dataTable>后面的 DataTable组件类实现了它.

You nested the <p:ajax> inside a <p:column>. The <p:ajax> requires to be nested in a component implementing the ClientBehaviorHolder interface. However, the Column component class behind <p:column> does not implement it. The DataTable component class behind <p:dataTable> implements it.

您应该将<p:ajax>嵌套在<p:dataTable>内:

<p:dataTable ...>
   <p:ajax ... /> 

   <p:column ...>
       ...
   </p:column>
</p:dataTable>

完全如他们的展示站点所示.换句话说,你的声明

Exactly as demonstrated on their showcase site. In other words, your statement

虽然我复制了展示柜中显示的示例

实际上不是真的.

这篇关于&lt; p:ajax&gt;无法附加&lt; p:ajax&gt;到非ClientBehaviorHolder父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆