The following small example can be used to reproduce the behaviour:
Code: Select all
@Named("testBean")
@SessionScoped
public class TestBean implements Serializable {
private List<Message> message;
private String dialogMessage = "New";
public class Message {
private String text;
public Message(String msg) {
this.text = msg;
}
public String getText() {return text;}
public void setText(String text) {this.text = text;}
}
public String getDialogMessage() {
return dialogMessage;
}
public void settext1() {
dialogMessage = "button1 clicked";
message = new ArrayList<Message>();
message.add(new Message("Button1"));
}
public void settext2() {
dialogMessage = "button2 clicked";
message = new ArrayList<Message>();
message.add(new Message("Button2a"));
message.add(new Message("Button2b"));
}
public List<Message> getMessages() {
return message;
}
}
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<html><h:head/><h:body>
<h:form id="form">
<p:commandButton value="Button1" actionListener="#{testBean.settext1}" oncomplete="dlg.show()"
update="XXX">
</p:commandButton>
<p:commandButton value="Button2" actionListener="#{testBean.settext2}" oncomplete="dlg.show()"
update="XXX">
</p:commandButton>
</h:form>
<h:form id="dlgform">
<p:confirmDialog id="dlg" message="#{testBean.dialogMessage}" widgetVar="dlg">
<p:dataTable id="dt" value="#{testBean.messages}" var="dataItem">
<p:column>
<h:outputText value="#{dataItem.text}"/>
</p:column>
</p:dataTable>
<p:commandButton value="Ok" oncomplete="dlg.hide()"/>
</p:confirmDialog>
</h:form>
</h:body></html>
</f:view>
- update="dt": the message of the dialog should stay the same ("New" - the value on first rendering the page), but the datatable should show one or two rows, depending on which button was clicked. Instead I get an empty datatable, no matter what I click.
- update="dlg": the message should reflect the clicked button and the datatable should show one or two rows of text, instead the message still reads "New" and the datatable is empty - no matter which button and how often I click. That is probably the same problem Ryland has in InputText in dialog not being updated when dialog is shown .
- update="dlgform": the complete form with the confirmDialog should get updated and indeed now I get a dialog with the expected contents, but I get multiple instances (you might need to move the dialog to see the other one behind it). Each click on a button adds one instance. It looks like the old instances don't get removed by primefaces.
Code: Select all
<script>
<!--
function TestDelete() {
for (i = document.getElementsByTagName("div").length - 1; i >= 0; i = i - 1) {
if (document.getElementsByTagName("div").item(i).parentNode.localName == "body") {
alert(i + " " + document.getElementsByTagName("div").item(i).parentNode.localName);
itemParent = document.getElementsByTagName("div").item(i).parentNode;
itemDrop = document.getElementsByTagName("div").item(i);
itemParent.removeChild(itemDrop);
}
}
dlg.show();
}
-->
</script>
Is this really a primefaces error and shall I open a bug report, or is it the fault of some other component, e.g. user error ?
best regards
Andreas