Hi Craig,

sorry, if this is totally OT, but I just posted a similar question in
the sun forum: Where would you actually place the code you mentioned
within a JSF component? I mean beginEncode() is called each time the
page is requested so what can I do, if I only want to add a component
once? I don't think that implementing NamingContainer and calling
findComponent() is a really nice solution ...

Thanks,
Tom

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