How to set rendered to PrimeFaces column programmaticaly?

590 Views Asked by At

I have a phaseListener that should set rendered property to primefaces column in dataTable

public class NewFeaturesListener implements PhaseListener {

    @Override
    public void afterPhase(PhaseEvent phaseEvent) {
        // Do nothing here
    }

    @Override
    public void beforePhase(PhaseEvent phaseEvent) {
        process(phaseEvent.getFacesContext().getViewRoot(), "column7WarrantyFix");
    }

    @Override
    public PhaseId getPhaseId() {
        return PhaseId.RENDER_RESPONSE;
    }

    private void process(UIComponent component, String... ids) {
        // Go to every child
        for (UIComponent child : component.getChildren()) {
            // If component has a given ID then check if you can rendered it
            for (String id : ids)
                if (id.equals(child.getId())) {
                    child.setRendered(false);
                }

            // Process next node
            process(child, ids);
        }
    }
}

and this is my column

<p:column id="column7WarrantyFix">
    <f:facet name="header">
        <h:outputText value="#{appMsg.admin_warranty_fix}" />
    </f:facet>
    <h:selectBooleanCheckbox value="#{item.object.isWarrantyFix}">
        <f:ajax value="change" execute="@this" render="@form" 
             listener="#{MyBean.warrantyChanged}"/>
    </h:selectBooleanCheckbox>
</p:column>

but unfortunately nothing happens. this column is shown in the interface. but when I change primefaces p tag to "h:" everything works. Why I can't do the same with primefaces?

1

There are 1 best solutions below

0
slavov On

as I was reinventing the wheel decided to use this logic in a Bean