From mneumann at ntecs.de Tue Nov 16 18:06:48 2004 From: mneumann at ntecs.de (Michael Neumann) Date: Tue Nov 16 18:06:31 2004 Subject: [Wee-talk] Re: Wee In-Reply-To: <200411162153.iAGLrhr2022914@rubyforge.org> References: <200411162153.iAGLrhr2022914@rubyforge.org> Message-ID: <419A8808.6030702@ntecs.de> CC'ed to wee-talk@rubyforge.org (http://rubyforge.org/mailman/listinfo/wee-talk) ... Kevin wrote: > Hi, I'm currently developing a Ruby port of Mewa (http://www.adrian-lienhard.ch/files/mewa.pdf), a program that runs on top of Squeak/Seaside2, and am using Wee (0.2.0) as the Seaside equivalent. One of Mewa's jobs it to generate form interfaces, then validate the input. Forms may have text, password, textarea and select elements. This leads me to the following questions: Wow. Great! A few days ago I read the paper about Mewa and was very impressed. > 1) How can I assign attr(:symbol) names to textareas and selects? Right now it seems that only text_inputs can send request input. html_writer.rb and html_canvas.rb need to be modified. I've done this for you (it's not yet commited to my svn repository). html.text_area.attr(:symbol) or: html.text_area.readonly.cols(5).rows(10).disabled.attr(:symbol) or instead of attr(), you can use with("text") as usual (attr() actually calls with() and as such closes the brush). Note that for text_area, the attr() call must be the last in the chain of the brush. As for select lists, this is currently not implemented. But they can be implemented easily by the user (e.g. you can simply output HTML and register input-actions). Do you have some ideas, how the select-list API should look? Or do you know how it is done in Seaside, I mean with it's new canvas/brush API? Here's my initial idea: def selected_item=(item) p item end html.select.assign(:selected_item).with do html.option.selected.value('1').with("First item") html.option.value('2').with('Second item') end This would assign '1' or '2' to selected_item. But the link between value and text is not done. Maybe, this is better: html.select_list(:selected_item, ['First item', true], ['Second item', false]) which would assign 'First item' or 'Second item' to selected_item, or if it's a multiple-select, both. Or we should have a SelectOption class, which wraps the displayed text, whether it's selected or not etc. What do you think? I can implement this quickly, if you want. > 2) How does Wee handle multiple inputs? This might include select lists that may have multiple options select, or multiple text fields of the same name. text fields usually don't have the same name, as the name is generated by Wee and is unique. If you need further help, feel free to ask. Regards, Michael