Dynamic display of xhtml form

UI Components for JSF
Post Reply
manishgarg
Posts: 9
Joined: 27 Dec 2010, 07:08

01 Mar 2011, 21:50

I have a requirement to show prime-faces form dynamically in a panel. The form contents shall come from database in form of xhtml having reference to actual managed beans as value expressions. I want to know how that form can be rendered on the panel dynamically.

Quick response or suggestions will be appreciated.

dmantil
Posts: 93
Joined: 14 Jul 2010, 22:30

05 Mar 2011, 17:49

I do what you need by creating all forms programmatically using the event PostAddToViewEvent which i found is the
only one is safe to change component tree.

Code: Select all

<h:panelGroup id="mainPanel" binding="#{mainbean.mainPanel}">
                                <f:event  type="javax.faces.event.PostAddToViewEvent"
                                            listener="#{mainbean.panelOnAddToView}"></f:event>
                            </h:panelGroup>
In the listener I add and remove all components i need using the bean property mainPanel
like this:

Code: Select all

mainPanel.getChildren().add( what you need to add )
The only bad thing is it's much harder to create forms programmatically than with tags.

I hope this helps.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests