Dyna Form

Community Driven Extensions Project
kdhrubo
Posts: 58
Joined: 26 Sep 2010, 06:52
Location: Kolkata, India
Contact:

21 Jun 2012, 15:27

Oleg wrote:@To your last post, creating whole form by model. I think you haven't understood this component ;) How do you want to create 100+ components with 1000+ attributes in Java? Form can contain almost every component inside. If you want to create everything in Java, you can use "binding" attribute. But binding is not ideal and have limitations (can be only used with request scoped beans).

Think on Tree please. You create there TreeNodes and map them to p:treeNode tag. p:treeNode can contain everything inside, but you don't create everything in Java. Right? DynaForm follows the same approach.
Yes you are right when you say that I am yet to phathom and fully understand this component. I have no problem in admitting that :mrgreen:
I did not mean that I will create 100+ component from 1000+ attributes. OK let us take a situation ----
I have a form with 20 fields and I have them configured them in my own way in some repository. Now I can create a dynaform model with 20 controls and supply that information. You know the type you know the data value you may even know a list if its a select. So whats stopping you from iterating over this 20 controls and spitting out the form?
I am not able to understand why we again repeat the controls we need in xhtml.
Please help me in understanding even if my question may sound stupid for you.

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

21 Jun 2012, 16:08

Assume, you have tell your Java model "use p:inputText with attributes so and so". Say me now please, how should we reuse PrimeFaces components? How should I render p:inputText without you write explicitly p:inputText on page? Should I copy all code from InputTextRenderer and paste it into DynaFormRenderer? Should I also copy codes from SelectOneMenuRenderer, etc. etc. and paste all into DynaFormRenderer? :shock:

Did you understand the problem?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

raziel
Posts: 48
Joined: 11 Feb 2010, 20:45

21 Jun 2012, 20:04

I think kdhrubo wants to update the database(or else where the resource that represennts dyna model is stored) and his applications updates as well without changing the code, that would be awesome but as Oleg pointed it is not easy(or even possible)...

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

21 Jun 2012, 20:56

This is possible. This is my case too. Just define the max. possible types of component tags in the form. See the last use case "Yet another form" http://fractalsoft.net/primeext-showcas ... rForms.jsf
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

kdhrubo
Posts: 58
Joined: 26 Sep 2010, 06:52
Location: Kolkata, India
Contact:

21 Jun 2012, 22:13

OK. Thats a good clever way. I now fully understand the problem and your solution. Well done.
I was thinking if we can minimize repeating this form description in each create and edit page.
We can possibly do this
1> Create a generic xhtml page with form including all the possible controls
2> Include it in each create and edit page ui:include and pass the model as parameter
3> Finally one day create a composite component - easyDynaForm :lol:

I see one problem with this approach - the button bar. They are different set for each of the page. So I need to come out with some kind of way to create dynamic command buttons in your button bar. I think PF needs to provide a support for dynamic toolbar. I will check your blog post about the programatic action listener. I tried once but did not work for ajax button.

kdhrubo
Posts: 58
Joined: 26 Sep 2010, 06:52
Location: Kolkata, India
Contact:

21 Jun 2012, 22:27

raziel wrote:I think kdhrubo wants to update the database(or else where the resource that represennts dyna model is stored) and his applications updates as well without changing the code, that would be awesome but as Oleg pointed it is not easy(or even possible)...
Yes you are right.
I have a big application. I need to give system integrators option to customize it without touching the system code as far as possible. Idea is from Open Close principle. So they will either use configuration to customize or extend the application. This is what I do
I have created a custom XML configuration for the form elements. Once the product is installed this form definitions in this xmls are in a configurable location outside the application. People who will customize will alter form controls in the configuration file. So far so good. My application reads from this form configs (being outside classpath I can load this file and changed ones without restarting the app) during development and customization phase. I resolve the requested page and form config, load the file and create the dyna form model.

Finally the form is rendered, users fill values and I unwind to populate the my entity object via reflection (see my earlier discussion on this) and save it in database.
Now you see that my source of meta data now is xml. So these form fields map to some columns in database. so if you change the form I need to address that back with my entity. So I use the dynamic entity support of EclipseLink and register the changes at runtime.

Well these customization of form and entity are possible only during customization phase and you are not allowed to do it in production :)
In future I intend to do this directly by UI without the xml config.

kdhrubo
Posts: 58
Joined: 26 Sep 2010, 06:52
Location: Kolkata, India
Contact:

23 Jun 2012, 21:27

Oleg wrote:@To you first post.

Code: Select all

<p:commandButton value="Submit" action="#{targetCreateForm.save}" process="dynaForm" />
And where is update=":dynaFormGroup" or at least update=":messages"? You nothing update because default of "update" it @none. Be also aware, that DynaForm is a NamingContainer!
OK its working as I have traced it from the :mainform:adminpanel .........!!!!!

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests