tengo el siguiente bean de respaldo:Cuando agrego un mensaje de rostros en JSF mis acciones no se realizan?
@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);
}
}
... Y la siguiente página 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>
Este es un simple caso de prueba reproducible. Cuando hace clic en la redistribución sin mensaje, las cosas funcionan como se espera. Cuando hace clic en el botón redistribuir, muestra el mensaje de éxito pero los campos de entrada no se actualizan. Sin embargo, el campo de salida de texto se actualiza solo una vez.
He intentado utilizar immediate = true en ambos botones y eso no afecta a esto. Este es un caso muy simple, no puedo entender por qué no funciona.
He intentado esto con todas las versiones recientes de Mojarra incluyendo 2.1.3.
¿Qué JSF impl/versión? No se puede reproducir este problema con Mojarra 2.1.1. – BalusC
Estoy usando 2.1.2. También estoy usando richfaces 4 y Primefaces también en la mezcla. Trataré de eliminar algo de eso y ver si eso ayuda. –
Los mismos resultados con solo Mojarra 2.1.2 (FCS 20110610). –