i try to define a custom component with jsf2.1. The component must be update after button click. The component have a rendered attribute, default to false, that is update on the button click. This is my code.
<cu:ActionBar id="actionBar" rendered="#{bean.booleanCondition}">
<!-- some code inside !-->
</cu:ActionBar>
The code that trigger the update.
<p:commandButton id="myButton" actionListener="#{bean.foo} update=":actionBar"/>
with this code, bean.booleanCondition is set to true, but actionBar component is never display. If i wrap the component inside a it works.
this is my ActionBar component class :
@FacesComponent(value = "ACTION_BAR")
public class ActionBarComponent extends UIPanel {
@Override
public void encodeBegin(FacesContext ctx) throws IOException {
if (ctx == null) {
throw new NullPointerException();
}
ResponseWriter writer = ctx.getResponseWriter();
writer.startElement("div", this);
if (this.getAttributes().get("id") != null) {
writer.writeAttribute("id", this.getAttributes().get("id"), "id");
}
String styleClass = this.getAttributes().get("styleClass") != null ? "" : " " + this.getAttributes().get("styleClass");
writer.writeAttribute("class", "actionBar" + styleClass, null);
writer.startElement("form", this);
writer.writeAttribute("enctype", "application/x-www-form-urlencoded", null);
writer.writeAttribute("method", "post", null);
writer.writeAttribute("name", "actionBarForm", null);
if (this.getAttributes().get("id") != null) {
writer.writeAttribute("id", this.getAttributes().get("id") + ":" + this.getAttributes().get("id") + "Form", "id");
}
writer.writeAttribute("action", ctx.getExternalContext().getRequestContextPath() + ctx.getExternalContext().getRequestServletPath(), null);
writer.startElement("div", this);
writer.writeAttribute("class", "actionBarGroup", "class");
writer.startElement("span", this);
writer.append("Actions :");
writer.endElement("span");
}
@Override
public void encodeEnd(FacesContext ctx) throws IOException {
if (ctx == null) {
throw new NullPointerException();
}
ResponseWriter writer = ctx.getResponseWriter();
writer.endElement("div");
writer.endElement("form");
writer.endElement("div");
}
}
How could i make it work?