is it supposed to be like this? (rich:popupPanel + aj4:outputPanel)
zeppelinux Jun 9, 2012 9:41 PMHi All,
I have a problem using rich:popupPanel with a4j:outputPanel, the @ViewScoped (or @ConversationScoped) bean is instantiated several times.
Here is the bean:
@Named
@ViewScoped
public class TestBean implements Serializable {
private String labelToUpdate;
public void sampleOperation(){
labelToUpdate = "TestBean instance: " + this;
}
public void updateLabel(){
labelToUpdate = "TestBean instance: " + this;
}
public String getLabelToUpdate() {
return labelToUpdate;
}
public void setLabelToUpdate(String labelToUpdate) {
this.labelToUpdate = labelToUpdate;
}
}
page.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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
xml:lang="en" lang="en">
<h:head>
</h:head>
<h:body>
<h:form>
<a4j:commandLink action="#{testBean.sampleOperation}" value="Show PopUp"
oncomplete="#{rich:component('popup')}.show(); return false;"
render="popupPanel"/>
</h:form>
<ui:include src="popup.xhtml"/>
</h:body>
</html>
popup.xhtml
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j">
<a4j:outputPanel id="popupPanel">
<rich:popupPanel id="popup" modal="true" resizeable="false" width="500"
height="300"
onmaskclick="#{rich:component('popup')}.hide()">
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('popup')}.hide(); return false;">X</h:outputLink>
</f:facet>
<h:form>
<a4j:commandButton action="#{testBean.updateLabel}" render="panelToUpdate"/>
</h:form>
<a4j:outputPanel id="panelToUpdate">
<h:outputText value="#{testBean.labelToUpdate}" rendered="#{testBean.labelToUpdate != null}"/>
</a4j:outputPanel>
</rich:popupPanel>
</a4j:outputPanel>
</ui:composition>
When page.xhtml is loaded, click on 'Show PopUp' link, popup will appear with panelToUpdate having some text, for example
TestBean instance: TestBean@9ff296
now click 'Submit' button, text will disappear... click 'Submit' again, label with different instance id will appear:
TestBean instance: TestBean@13d13e3
The current behaviour is strange, and doesn't make any sence to me.
There is small maven project in attachment that has all the sources.
Similar problem was reported 9 months ago:
https://community.jboss.org/thread/167161
bug was created and closed:
https://issues.jboss.org/browse/RF-11389
but I'm still struggling with this in RF 4.2.2.Final, rich:popupPanel is unusable pretty much.
Is there anything wrong with the way it is used?
-
sample.zip 17.5 KB