0

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.

Barney
  • 2,355
  • 3
  • 22
  • 37

1 Answers1

1

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.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I try f:event but it not binding value to postAddToView and preRenderView.When I try same f:event type="preRenderComponent" before use of form it work fine.It's correct? –  May 27 '15 at 07:43
  • I have no idea what you said there. "... it not binding value to ..." ??? Do you mean to say that the listener method is not invoked? Or do you mean to say that the desired functional result is not achieved? What exactly is the concrete functional requirement? – BalusC May 27 '15 at 07:49