我正在尝试使以下代码在IE 8中正常运行,但没有结果(尽管在Google chrome中可以正常运行):
xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form id="form">
<p:dataTable id="eventsDT" var="answer" value="#{verify.answers}" rowKey="#{answer.id}" selectionMode="single" >
<p:ajax event="rowSelect" listener="#{verify.onRowSelectTest}" />
<p:column headerText="Id">
<h:outputText value="#{answer.id}" />
</p:column>
<p:column headerText="Text">
<h:outputText value="#{answer.text}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
Answer.java:
package ru.trust.appVerification;
public class Answer {
private int id;
private String text = "Undefined";
public Answer(int id, String text) {
this.id = id;
this.text = text;
}
public int getId() {
return id;
}
public String getText() {
return text;
}
public void setId(int id) {
this.id = id;
}
public void setText(String text) {
this.text = text;
}
}
验证.java
package ru.trust.appVerification;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.*;
import java.util.stream.*;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;
import org.primefaces.event.SelectEvent;
@ManagedBean
@ViewScoped
public class Verify implements Serializable {
public List<Answer> getAnswers() {
List<Answer> answers = new ArrayList<Answer>();
answers.add(new Answer(1, "Yes"));
answers.add( new Answer(2, "No"));
return answers;
}
public void onRowSelectTest(SelectEvent event) {
Answer answer = (Answer)event.getObject();
}
}
我的代码有什么问题还是Internet Explorer 8根本不支持它?
最佳答案
尝试将其添加到xhtml的顶部:
<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
</f:facet>
// other head code goes here
</h:head>
代替:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
我有一个类似的问题。添加这个对我来说很好。
关于java - Primefaces数据表onrowselect事件在IE 8中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32440708/