나는 다음과 같은 백업 콩이 있습니다JSF에서 faces 메시지를 추가 할 때 내 작업이 수행되지 않습니까?
@ViewScoped
@ManagedBean
public class WeighFamilyBacking2 implements Serializable {
private static final long serialVersionUID = 1L;
private String[] children = new String[] { "Child1", "Child2", "Child3" };
private HashMap<String, Integer> newWeights;
public WeighFamilyBacking2() {
newWeights = new HashMap<String, Integer>();
for (String s : getChildren())
newWeights.put(s, new Integer(0));
}
public void distributeWeightsWithoutMessage(ActionEvent event) {
for (String s : newWeights.keySet()) {
newWeights.put(s, newWeights.get(s) + 1);
}
}
public void distributeWeights(ActionEvent event) {
for (String s : newWeights.keySet()) {
newWeights.put(s, newWeights.get(s) + 1);
}
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage("Succesful", "Weights redistributed."));
}
public HashMap<String, Integer> getNewWeights() {
return newWeights;
}
public List<String> getChildren() {
return Arrays.asList(children);
}
}
... 그리고 다음 XHTML 페이지 :
<!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:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:body>
<h:form>
<ui:repeat var="child" value="#{weighFamilyBacking2.children}">
<h:outputText value="#{child}" />
<h:outputText value="#{weighFamilyBacking2.newWeights[child]}" /> -
<h:outputText value="#{weighFamilyBacking2.newWeights[child]}" /> -
<h:inputText id="oz" value="#{weighFamilyBacking2.newWeights[child]}" />
<h:inputText id="lbs"
value="#{weighFamilyBacking2.newWeights[child]}" />
<br />
</ui:repeat>
<h:commandButton
actionListener="#{weighFamilyBacking2.distributeWeights}"
value="Redistribute" />
<h:commandButton
actionListener="#{weighFamilyBacking2.distributeWeightsWithoutMessage}"
value="Redistribute Without Message" />
</h:form>
</h:body>
</html>
이 간단한 재현 테스트 케이스입니다. 메시지없이 재분 j을 누르면 예상대로 작동합니다. 재분배 버튼을 클릭하면 성공 메시지가 표시되지만 입력 필드는 업데이트되지 않습니다. 그러나 텍스트 출력 필드는 한 번만 업데이트됩니다.
두 버튼 모두에서 즉치 = 참을 사용하려고 시도했지만이 영향을주지 않습니다. 이것은 매우 간단한 경우입니다. 왜 작동하지 않는지 이해할 수 없습니다.
2.1.3을 포함한 모든 최신 버전의 Mojarra에서 이것을 시도했습니다.
JSF impl/version은 무엇입니까? Mojarra 2.1.1에서이 문제를 재현 할 수 없습니다. – BalusC
2.1.2를 사용하고 있습니다. 나는 또한 richfaces 4를 사용하고 primefaces도 혼합에 있습니다. 그 중 일부를 제거하고 도움이되는지 확인해 보겠습니다. –
Mojarra 2.1.2 (FCS 20110610)와 동일한 결과가 나타납니다. –