While it is true you cannot do it with Stuts HTML tags, remember that those tags render plain HTML when all is said and done, as does JSF incidentally, and there is nothing to stop you from doing that yourself. It's a pretty trivial exercise really.

Frank

Craig McClanahan wrote:
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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to