我正在尝试将h:panelGroup绑定到UIComponent(HtmlPanelGroup)代码,如:
p.s我正在使用faces-config.xml
import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import javax.faces.component.html.HtmlOutputLabel;
import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.event.ActionEvent;
@ViewScoped
public class PanelGroupUpdater1 {
private HtmlPanelGroup hpg0;
@PostConstruct
public void init(){
hpg0=new HtmlPanelGroup();
hpg0.setLayout("block");
hpg0.setStyleClass("myBindedPanelGroup0");
HtmlOutputLabel l = new HtmlOutputLabel();
//l.setValue("Synched binded panel group : ");
hpg0.getChildren().add(l);
}
int h;
public void addLabelBindedSynched(ActionEvent event) {
//update panelgroup by its binding
HtmlOutputLabel l = new HtmlOutputLabel();
l.setValue("added:"+(++h)+";");
this.hpg0.getChildren().add(l);
}
}
和WebContent / test / bindingtest.xhtml
<h:body>
<f:view>
Binded panel group (hpg0) : <br/>
<h:panelGroup id="myBindedPanelGroup0" binding="#{panelGroupUpdaterBean1.hpg0}" layout="block">
</h:panelGroup>
<h:form>
<h:commandButton value="Add Label (binded)" actionListener="#{panelGroupUpdaterBean1.addLabelBindedSynched}" update=":myBindedPanelGroup0" />
</h:form>
</f:view>
</h:body>
问题是我可以只向panelgroup添加一次标签,但是所有下一次添加尝试我都会得到此异常java.lang.IllegalStateException: CDATA tags may not nest
。
所以我的问题是......导致问题的原因以及如何解决这个问题?
由于