gpt4 book ai didi

java - Primefaces 数据表 onrowselect 事件在 IE 8 中不起作用

转载 作者:行者123 更新时间:2023-12-01 11:10:34 24 4
gpt4 key购买 nike

我试图让以下代码在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com