Jsf 2 在JSF中添加faces消息时,我的操作不是';没有表演?

Jsf 2 在JSF中添加faces消息时,我的操作不是';没有表演?,jsf-2,Jsf 2,我有以下支持bean: @ViewScoped @ManagedBean public class WeighFamilyBacking2 implements Serializable { private static final long serialVersionUID = 1L; private String[] children = new String[] { "Child1", "Child2", "Child3" }; private HashMap<String, In

我有以下支持bean:

@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);
}
}
@ViewScoped
@ManagedBean
公共类WeighFamilyBacking2实现可序列化{
私有静态最终长serialVersionUID=1L;
私有字符串[]children=新字符串[]{“Child1”、“Child2”、“Child3”};
私有HashMap新权重;
公共称重家庭备份2(){
newWeights=newhashmap();
对于(字符串s:getChildren())
newWeights.put(s,新整数(0));
}
public void DistributeLightswithoutMessage(ActionEvent事件){
对于(字符串s:newWeights.keySet()){
newWeights.put(s,newWeights.get(s)+1);
}
}
公共无效分发权限(ActionEvent事件){
对于(字符串s:newWeights.keySet()){
newWeights.put(s,newWeights.get(s)+1);
}
FacesContext.getCurrentInstance().addMessage(空,
新面孔信息(“成功”,“权重重新分配”);
}
公共HashMap getNewWeights(){
返回新权重;
}
公共列表getChildren(){
返回数组.asList(子级);
}
}
。。。以及下面的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>

-
- 

这是一个简单的可复制测试用例。当您在没有消息的情况下单击“重新分发”按钮时,一切正常。单击“重新分发”按钮时,会显示成功消息,但输入字段不会更新。但是,文本输出字段仅更新一次

我尝试在两个按钮上都使用immediate=true,但这并不影响这一点。这是一个非常简单的案例,我不明白为什么它不起作用

我在Mojarra的所有最新版本(包括2.1.3)中都尝试过这一点。

这是另一个
异常现象。我还没有确定确切的根本原因,这样我就可以检查是否已经向报告了,如果必要的话,也可以报告它,但是当我用
替换
时,我可以看出它是有效的


-
- 
可能
在语义上不适合您。如果这确实是不需要的,那么您可能希望检查它是否可以在Tomahawk的
、RichFaces的
、PrimeFaces的
等中正常工作,每个都支持在不添加额外标记的情况下呈现子对象


更新:我报告它为。

什么JSF impl/版本?无法使用Mojarra 2.1.1重现此问题。我使用的是2.1.2。我还使用了richfaces 4和primefaces。我将尝试删除其中一些,看看是否有帮助。与Mojarra 2.1.2(FCS 20110610)的结果相同。哎哟。难道你不能把所有不相关的标记和模板定义剪切成一个最小的、自包含的XHTML文件,而这个文件仍然会重现这个问题吗?做一些基本的消除。一步一步地删除尽可能多的组件,当问题不再出现时停止,然后后退一步。BalusC--我已经尽可能地将其简化为一个可重复的测试用例。试试看。。单击按钮应增加文本和输入字段中的所有值+1。我感谢你的帮助!!!谢谢你,谢谢你,巴卢斯克!至少我知道我没有疯。在这里,数据表可能可以正常工作。让我知道我是否应该和JSF的人打开一些报告。这是一个相当容易复制的测试用例。奇怪的是,它只影响repeat中的inputText元素。我在想,这可能与识别repeat中的inputText元素有关?是的,我以前在嵌套的
ui:repeat
中遇到过类似的问题,这些复选框在调用操作期间被更新。但是没有涉及到
FacesMessage
。我很想知道你那篇特别的文章中出现的
FacesMessage
的原因。