On 3/9/06, Rivka Shisman <[EMAIL PROTECTED]> wrote: > > Hi friends, > > > > I need to dynamically build an input form that may contain various > html:fields (i.e. html:text, html:select, html:radio etc). > > The type and name of the html:field will be determined at runtime (from > DB table). > > How can I do it using Struts and JSP?
Basically, you can not do this sort of thing with the Struts HTML tags ... but you could easily do it with JavaServer Faces components. A quick snapshot to give you the idea of how it works: HtmlForm form = ...; // Acquire a reference to the parent form component HtmlOutputLabel label1 = new HtmlOutputLabel(); // Label for username field label1.setValue("Username:"); HtmlInputText username = new HtmlInputText(); // Username field username.setId("username"); HtmlOutputLabel label2 = new HtmlOutputLabel(); // Label for password field label2.setValue("Password:"); HtmlInputSecret password = new HtmlInputSecret(); // Password field password.setId("password"); HtmlCommandButton submit = new HtmlCommandButton(); // Submit button submit.setId("logon"); List children = form.getChildren(); children.add(label1); children.add(username); children.add(label2); children.add(password); children.add(submit); There's lots more you can do, but this gives the basic flavor of dynamically creating component hierarchies. Thanks > > Rivka Craig