문제

Does anyone know what exactly is Dynamic about Primefaces Extension's Dynaform.There doesn't seem to be anything dynamic about the dynamic form example. As far as I can tell this is just a form with a fixed layout and fixed input components. Not what I expected given the statement on the front page:        

Normally we can build a form quite straightforward by h:panelGrid oder p:panelGrid if the count of rows / columns, positions of elements, etc. are known. That's true for static forms. But it's not possible to use h:panelGrid oder p:panelGrid if a form is described dynamically, at runtime. E.g. if the entire form's definition is placed in a database or a XML file.

DynaForm makes possible to build a dynamic form with labels, inputs, selects and other elements by model. Other enhancements are expandable extended view area (grid), autoSubmit feature, widget's client-side API, various facets. Supported facets

 

도움이 되었습니까?

해결책

One of the Primefaces Extension authors explains it in a bit more detail on his blog : http://ovaraksin.blogspot.hu/2012/06/dynamic-forms-jsf-world-was-long.html .

The important part is:

Child tag pe:dynaFormControl matches created in Java controls by "type" attribute. This is usually a "one to many" relation.

You don't define the layout in the xhtml page, you just create some custom components you reference in your java code.

In the basicUsage example you can see this:

<pe:dynaFormControl type="calendar" for="cal">
    <p:calendar id="cal" value="#{data.value}" />
</pe:dynaFormControl>

This creates a calendar control type, that is implemented using p:calendar. You can reference it in your backing bean:

DynaFormControl control = row.addControl(property, "calendar", 1, 1); 

다른 팁

I'm a creator of this component. Why do you think the layout is fixed? It's not fixed, you define the layout in Java. Mapping between defined in Java controls / labels and form elements occurs by "type" attribute. Sure, all possible form elements should be on page because it's easier to describe them as tags, in XHTML and not to create in Java. Imagine you would create a SelectOneMenu in Java with SelectItems, Ajax behaviors, Action / ActionListener, a lot of other attributes... Easier to specify a 1-N mapping, like in p:treeNode and TreeNode. Here is the same - you have pe:dynaFormControl and DynaFormControl. Explore all code samples please.

Thanks. Oleg.

P.S. My last blog post is about this component.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top