Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dynamic Form in JSF

843844Jun 12 2008 — edited Jun 12 2008
Hi ! I'm working with seam and facelets trying to build a new application. My main trouble is that in our previous app (built with a proprietary (and really nasty) techno) I was able to do dynamic forms.

By dynamic I mean that the form at the begining is really quite just a blank file. the items (input text; radio btns or checkboxes; drop-down etc..) are added in the page dynamically during the rendering based on some configuration computed from the database . Then with the help of some convention regarding the id s of my widget I was able to have a method dealing with all that

Nowadays , at last , after years of me beggin' the boss to face Java , Jee etc... we are out of this ancient proprietary and are in the world of jboss, jsf and seam. ! (In fact my app is built with seam and use JSF and/or Facelets )

How can I achieve the same kind of feature wich is mandatory in my case ?


I was thinking about this : Imagine I got my
* list of fields in some array with them types and parameters

* In my code i know that for this type of field i want to show an input field for example.

* I put fragments/templates for each kind of widget (input text; radio btns or checkboxes; drop-down etc..)

* then trying to compose my main form.xhtml by including some of these dynamically If my current Fieldtype[] is with 4 input and 2 dropdown I add them

* then add my Submit and my Cancel

* On seam side building my methods as before so that with the help of the input fields id I can figure out which fields is concerned
But I'm too newbie to seam and facelets to be sure Is this scenario possible ? If not where should I change it (as I think the whole idea is here anyway : you don't got 1000s way to do that )?

Can some most talented seam user tell me where I should look for doing these two task : compose my form dynamically and best way (seam-side) to handle the non standard form on validation .
+But beware I'm really seroius talking about "DYNAMIC" here+ 

let say for one type of entity my database told me user configured this to have 2 input fields then one group of check boxes then 1 other input and 
for a second entry could be just a text area ? 

+=> I can't just put composition by design time !!+

indeed, the order AND the type of the dynamically-rendered fields are set on runtime
may be on composition I can use EL to design the part; then I put let'say 50 composition tag on my mother-page then some style of
<ui:include or <ui:composition with template=#{formDefinition.get1stType}> #{formDefinition.get2ndType; #{formDefinition.get3rdType} 
and so on for let say may maximum of 50 fields per page.
and I will got some extra meta data filled in
 formDefinition.get1stMetadata ..to.. formDefinition.get50thMetadata
;
with this I'm able to set
on the UI side that on this UI should validate the lenght to be 5 car; on this the field is marked required etc..

Not really nice but may be it can works if the EL is permitted in this case ?

What do you think about it ?
of course any help and advice is welcomed.

Thanks you all ! PS : May be I should also found a facelets forum to ask there ? (but don't found one specially )
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 10 2008
Added on Jun 12 2008
1 comment
161 views