我有一些问题,数据表的即时行选择,完全<电话号码:AJAX />
。它给我这个错误:
I'm having some problems with datatable's instant row selection, exactly <p:ajax/>
. It's giving me this error:
<p:ajax> Parent not an instance of ClientBehaviorHolder:
org.primefaces.component.datatable.DataTable
所以,我做了一些研究,我认为这是一个老版本的一个问题,所以我已经更新了我的版本3.0.M3-快照,但我还是同样的错误,我不知道为什么! 这里是我的网页code:
So I did some research and I think it's a problem with an old version, so I've updated my version to 3.0.M3-SNAPSHOT but I have still the same error and I wonder why! Here is my page code:
<p:dataTable id="projets" var="p" value="#{projet.init()}" selection="#{projet.currentChangerStatus}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{projet.redirection}" update="formEquipe" oncomplete="projetDialog.show()" />
<f:facet name="header">
Select a row to display a message
</f:facet>
<p:column headerText="Code" sortBy="#{p.projets.codeProjet}" filterBy="#{p.projets.codeProjet}">
<h:outputText value="#{p.projets.codeProjet}" />
</p:column>
<p:column headerText="Intitulé">
<h:outputText value="#{p.projets.libelle}" />
</p:column>
<p:column headerText="Dérnier Etat">
<h:commandLink id="link1" action="goto5">
<h:outputText value="#{p.etats.libelleEtat}" />
</h:commandLink>
</p:column>
<p:column headerText="Etat Changé Au Niveau">
<h:outputText value="xxxx" />
</p:column>
<p:column headerText="Date Dérnier Etat">
<h:outputText value="#{p.dateTache}" />
</p:column>
<p:column headerText="Responsable Etat">
<h:outputText value="#{p.acteurs.nomActeur}" />
</p:column>
<p:column headerText="Objets | Application">
<h:commandLink id="link2" action="goto4">
<h:outputText value="xxxx" />
</h:commandLink>
</p:column>
<p:column headerText="Domaine">
<h:outputText value="#{p.projets.domaines.libelleDomaine}" />
</p:column>
<p:column headerText="Type">
<h:outputText value="#{p.projets.typeProjets.libelleTypeProjet}" />
</p:column>
<p:column headerText="CP">
<h:commandLink id="link3" action="goto3">
<h:outputText value="xxxx" />
</h:commandLink>
</p:column>
<p:column headerText="Plan Int.">
<h:commandLink id="link4" action="goto2">
<h:outputText value="xxxx" />
</h:commandLink>
</p:column>
<p:column headerText="Doc Principal">
<h:commandLink id="link5" action="goto1">
<h:outputText value="xxxx" />
</h:commandLink>
</p:column>
<p:column headerText="Dérnier Motif">
<h:outputText value="xxxx" />
</p:column>
<p:column headerText="Auteur">
<h:outputText value="xxxx" />
</p:column>
<p:column style="width:80px">
<h:panelGrid columns="3" styleClass="actions" cellpadding="2">
<p:commandButton update=":form:display" oncomplete="carDialog.show()"
actionListener="#{projet.redirection}" image="ui-icon ui-icon-search" title="View">
<f:setPropertyActionListener value="xxxx" target="xxxx" />
<f:setPropertyActionListener value="xxxx" target="xxxx" />
</p:commandButton>
<p:commandButton update=":form:display" oncomplete="carDialog.show()"
image="ui-icon ui-icon-pencil" title="Edit">
<f:setPropertyActionListener value="xxxx" target="xxxx" />
<f:setPropertyActionListener value="xxxx" target="xxxx" />
</p:commandButton>
<p:commandButton update=":form:display" oncomplete="confirmation.show()"
image="ui-icon ui-icon-close" title="Delete">
<f:setPropertyActionListener value="xxxx" target="xxxx" />
</p:commandButton>
</h:panelGrid>
</p:column>
</p:dataTable>
<p:dialog header="Car Detail" widgetVar="projetDialog" resizable="false" width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/cars/xxxx.jpg"/>
</f:facet>
<h:outputText value="Etat:" />
<h:outputText value="#{projet.currentChangerStatus.etats.libelleEtat}" />
<h:outputText value="Date Reception:" />
<h:outputText value="#{projet.currentChangerStatus.projets.dateReceptionProjet}" />
<h:outputText value="Libelle" />
<h:outputText value="xxxx" />
<h:outputText value="Acteur:" />
<h:outputText value="xxxx" />
</h:panelGrid>
</p:dialog>
下面是我的函数的code:
Here is my function's code:
public void redirection(SelectEvent event) throws Exception {
System.out.println("some message: " );
currentChangerStatus=(ChangerStatus)event.getObject();
currentProjet=currentChangerStatus.getProjets();
System.out.println("le projet est : " +currentProjet.getLibelle());
FacesContext.getCurrentInstance().getExternalContext().redirect("infoprojet.xhtml");
}
也许我并没有集成在Primefaces罐子正确的,所以这里是我的 POM
(Maven的):
Maybe I didn't integrated the Primefaces jar correctly, so here is my POM
(maven):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>Gpsi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Gpsi Web App</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.deploy.server>Tomcat70</netbeans.hint.deploy.server>
</properties>
<dependencies>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.5.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
<!-- Hibernate query library dependecy start -->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.6</version>
</dependency>
<!--ASM-->
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>javax.sql</groupId>
<artifactId>jdbc-stdext</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.0.1B</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>ojdbc14</artifactId>
<version>SNAPSHOT</version>
</dependency>
<!--Primefaces-->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.0.M3-SNAPSHOT</version>
</dependency>
<!--End Primefaces-->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>2.5.6</version>
</dependency>
<!-- Apach commons -->
<!-- dbcp pour la data source -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<!-- Themes -->
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>aristo</artifactId>
<version>1.0.1</version>
</dependency>
<!-- FIN Themes -->
<!-- Upload library -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<!-- Fin Upload library -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<!-- iText-->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>Gpsi</finalName>
</build>
<repositories>
<repository>
<url>http://download.java.net/maven/2/</url>
<id>jsf20</id>
<layout>default</layout>
<name>Repository for library Library[jsf20]</name>
</repository>
<repository>
<url>http://repository.prime.com.tr/</url>
<id>primefaces</id>
<layout>default</layout>
<name>Repository for library Library[primefaces]</name>
</repository>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
<repository>
<id>itextpdf.com</id>
<name>Maven Repository for iText</name>
<url>http://maven.itextpdf.com/</url>
</repository>
</repositories>
不要试图把&LT;电话号码:AJAX&GT;
中的&LT;电话号码:dataTable的&GT; 。这是PrimeFaces组件,您声明Ajax相关的属性,就在组件本身之一。
Don't try to put a <p:ajax>
inside the the <p:dataTable>
. This is one of the PrimeFaces components where you declare the Ajax-related attributes right in the component itself.
下面是从PrimeFaces文档的例子:
Here is an example from the PrimeFaces documentation:
<p:dataTable
var="car"
value="#{carBean.cars}"
selectionMode="single"
selection="#{carBean.selectedCar}"
onRowSelectUpdate="carListForm:dialogContent"
rowSelectListener="#{carBean.onCarSelect}">
...columns
</p:dataTable>
请参阅如何使用 rowSelectListener
属性声明的权利在&LT;电话号码:?dataTable的&GT;
See how the rowSelectListener
attribute is declared right inside the <p:dataTable>
?
您是正的错误: ClientBehaviorHolder的父母不是一个实例的
这意味着父标签不能包含一个Ajax标签。上面的例子是从PrimeFaces 2.2的文档,但我相信3.0是相似的。
This means that the parent tag cannot contain an Ajax tag. The example above is from the PrimeFaces 2.2 documentation, but I believe 3.0 is similar.
编辑:
我的错误!我从家里说,并没有访问我的使用PrimeFaces 3.0 code。在PF 3.0(不像PF 2.2),你可以嵌入&LT;电话号码:AJAX&GT;
元素。这里是一个code样对我的作品:
My mistake! I replied from home and didn't have access to my code that uses PrimeFaces 3.0. In PF 3.0 (unlike PF 2.2) you can embed the <p:ajax>
element. Here is a code sample that works for me:
<p:dataTable
id="myDataTable"
value="#{myBean.rowObjectList}
var="rowObject"
selection="#{myBean.selectedRowObject}"
selectionMode="single">
<p:ajax
event="rowSelect"
listener="#{myBean.onRowSelect}"
update="someElement" />
<p:ajax
event="rowUnselect"
listener="#{myBean.onRowUnselect}"
update="someElement" />
</p:dataTable>
下面是我的监听器方法签名:
Here are my listener methods signatures:
public void onRowSelect(SelectEvent event) {
// your code here...
}
public void onRowUnselect(UnselectEvent event) {
// your code here...
}
我不知道足够了解你的Web应用程序,以了解您的重定向是如何为了工作,但我也会给你的用户之后,我使用我的webapp一个code样品点击一个退出按钮和我重定向到一个您已注销页面。这code是从操作方法中调用。
I don't know enough about your webapp to understand how your redirect is meant to work, but I will also give you a code sample that I'm using in my webapp after the user clicks a Logout button and I redirect them to a "you are logged out" page. This code is called from an action method.
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext ectx = ctx.getExternalContext();
ServletContext sc = (ServletContext) ectx.getContext();
ectx.redirect("http://somedomain.org/somepage.html");