Reputation:
I'm new for Primefaces .Now I'm migrating RichFaces to Primefaces 5.1. In RichFaces every form has binding initForm to bind Page Attributes.In same form binding use PrimeFaces or any other attribute to bind page attributes.
I'm use below code in Richfaces:
<f:subview id="testSubView">
<h:form id="testForm" binding="#{test.initForm}">
........
</h:form>
<f:subview>
Test.java
public HtmlForm initForm()
{
fetchIntialPageAttributes();
return initForm
}
private void fetchIntialPageAttributes()
{
userTextbox="";
messagePanelRender=true;
userCommandButton=true;
userCommanButtonValue="save";
}
Now doubt initially bind when form load same binding attribute use in Primefaces.
Upvotes: 0
Views: 416
Reputation: 1108632
Use <f:event type="postAddToView">
, or perhaps <f:event type="preRenderView">
, instead to trigger a managed bean listener method right after the component was added to view during view build time, or perhaps right before the view render time.
<h:form id="testForm">
<f:event type="postAddToView" listener="#{test.fetchIntialPageAttributes}" />
...
</h:form>
Do note that this all is not specific to PrimeFaces (nor RichFaces), but just to JSF itself. The binding
attribute was during the JSF 1.x era actually a hack/workaround for this. That's one of reasons why JSF 2.0 added those new component system events and the <f:event>
tag. An ideal JSF 2.x page does not use binding
on a backing bean property anywhere.
Upvotes: 1