h:commandLink
은 rich:dataTable
입니다. 명령 링크를 클릭하면 컨텍스트에 FacesMessage를 추가하고 같은 메시지로 리디렉션합니다. 페이지에 h:messages
태그가있어서 얼굴 메시지를 표시합니다. 메시지를 표시 할 수 있지만 다음 경고가 표시되며 메시지가 지워지지 않습니다.경고 JSF1095는 rich : dataTable 내에서 h : commandLink를 사용하는 동안
경고 : JSF1095 : Flash에서 나가는 쿠키를 설정하려고 할 때까지 이미 응답이있었습니다. 플래시에 저장된 모든 값은 다음 요청에서 사용할 수 없습니다.
나는 JSF2.0, RF4.0.0.Final을 사용하고 있습니다. 코드
index.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:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title>DataTable Test</title>
</h:head>
<h:body>
<h:form prependId="false">
<rich:panel header="Data table test">
<br/><br/>
<rich:dataTable id="dTable" value="#{myBean.allInventory}" var="inv" style="margin: auto; width: 100%; min-width: 750px;"
rows="10" onrowmouseover="this.style.backgroundColor='#A0A0A0'"
onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
<rich:column>
<f:facet name="header">
<h:outputText value="Sl No" />
</f:facet>
<h:outputText value="#{inv.slno}" />
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Item 1" />
</f:facet>
<h:commandLink id="docMessage" title="Click for details" action="#{myBean.cLink(inv)}" value="#{inv.item1}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Item 2" />
</f:facet>
<h:outputText value="#{inv.item2}" />
</rich:column>
<f:facet name="footer">
<rich:dataScroller id="dataScroll" for="dTable"/>
</f:facet>
</rich:dataTable>
<h:messages id="messages" globalOnly="true" layout="table" ></h:messages>
</rich:panel>
</h:form>
</h:body>
MyBean.java
package com.mypkg;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
@Named
@SessionScoped
public class MyBean implements Serializable {
private List<Inventory> allInventory = null;
/**
* @return the allInventory
*/
public List<Inventory> getAllInventory() {
if (allInventory == null) {
allInventory = new ArrayList<Inventory>();
for (int i = 0; i < 100; i++) {
Inventory e = new Inventory();
e.setSlno(i + 1);
e.setItem1("Item1" + Math.random());
e.setItem2("Item2" + Math.random());
allInventory.add(e);
}
}
return allInventory;
}
public String cLink(Inventory inv) {
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Sample Error Message", "Sample Error Message"));
return "index?faces-redirect=true";
}
/**
* @param allInventory the allInventory to set
*/
public void setAllInventory(List<Inventory> allInventory) {
this.allInventory = allInventory;
}
}
Inventory.java
/*입니다 다음*이 템플릿을 변경하려면 도구 | 템플릿 *을 선택하고 편집기에서 템플릿을 엽니 다. */
package com.mypkg;
public class Inventory {
private int slno;
private String item1;
private String item2;
/**
* @return the slno
*/
public int getSlno() {
return slno;
}
/**
* @param slno the slno to set
*/
public void setSlno(int slno) {
this.slno = slno;
}
/**
* @return the item1
*/
public String getItem1() {
return item1;
}
/**
* @param item1 the item1 to set
*/
public void setItem1(String item1) {
this.item1 = item1;
}
/**
* @return the item2
*/
public String getItem2() {
return item2;
}
/**
* @param item2 the item2 to set
*/
public void setItem2(String item2) {
this.item2 = item2;
}
}
무엇 JSF의 IMPL/버전 접견? 나에게 벌레 같아. 최신 버전으로 업그레이드하거나 impl을 교체하십시오. 그건 그렇고, 당신은 'rich : dataTable'에서만 실패한다는 것을 조금씩 암시하고 있습니다. 이것을 확인할 수 있습니까? 나는. 커맨드 링크가'rich : dataTable' 밖에있을 때 완벽하게 작동합니까? – BalusC
@BalusC JSF 2.0, JSTL 1.1 (NetBeans 6.9.1과 함께 제공되는 프레임 워크)을 사용하고 있습니다. 'rich : dataTable' 외부에 명령 링크를 배치하면 경고 메시지가 표시되지 않습니다. 나는 이것을' '와 같이 추가했으며'MyBean.java'에서는 같은 body를 갖는'linkTest()'메서드를 추가했다. 메소드'cLink (Inventory inv) ' –
Praneeth
"JSF 2.0"은 스펙 버전 일뿐입니다. 어떤 impl/version을 사용하고 있습니까? 예를 들어, Mojarra 2.0.6? 서버 시작 로그에 표시되거나 그렇지 않으면 JAR을 추출하고 매니페스트 파일을 읽어야합니다. 문제에 관해서, 그것은 흥미 롭습니다.'rich : xxx' 대신'h : dataTable' /'h : column'을 사용할 수 있습니까? 이렇게하면 표준 JSF 또는 RichFaces가 의심 스럽다는 것을 제외 할 수 있습니다. – BalusC