On Saturday, November 9, 2013 7:07 PM, Ezequiel Davidovich Caballero 
<ezelot...@yahoo.com> wrote:
 
Hi!

I'm new to the list (this is actually my first message and I signed up about an 
hour ago), hope somebody can help me with this and maybe this can help others 
too!

Thing is I've been trying to do a webapp with pharo and seaside and I've been 
using scritaculous updater and ajax to display several components in the same 
page without reloading it all. To put some context on the subject, it's a form 
to send commands to a subsystem on a satellite simulator. You choose a 
subsystem from a drop down menu, then the other drop down menu updates it's 
contents with the commands understandable by that specific subsystem. Up until 
here, everything's peachy. Thing is some commands require parameters and for 
that I thought why not make several (several = number of parameters the command 
takes) text input boxes appear when the user selects the command? So I tried 
that, but it doesn't seem to be working. I know it's bit of a pain in the arse 
to read code from an email so I have the three methods (the main 
rendercontentOn, the one with the command list and the one with the parameters) 
in separate text files for readability.

TL;DR: Why isn't my code working?


Thanks in advance


Ezequiel

ps: Now with the attachments I forgot.
renderCommandParametersOn: html
        "Used by Prototype to update the list of commands"
        | commandParameters |
        
        commandParameters :=  commandDefinition requestDefinition.
        
        commandParameters do: [ :each |
                html text: each name.
                html textInput 
                        callback: [ :value | each value: value  ];
                        value: each value . 
                html space.
                 ]
renderCommandListOn: html
        "Used by Prototype to update the list of commands"
        | commandNames commandsParametersId subsystemsCommandsId |
        
        commandsParametersId := html nextId.
        commandNames := self commandNamesForSubsystem: self subsystem.
        
        html label: 'Command: '.
        html select
                        onChange: (html scriptaculous updater 
                                                        id: 
commandsParametersId;
                                                        triggerForm: (html 
scriptaculous element up: 'form');
                                              callback: [ :ajaxHtml | self 
renderCommandParametersOn: ajaxHtml ]
                                                );
                callback: [ :value | commandDefinition := self commandWithName: 
value.
                        data := (self commandWithName: value) 
requestDefinition];
                list: commandNames

renderContentOn: html
        | names form subsystemsElementId commandsElementId commandParametersId |

        names := subsystems collect: [:aSubsystem | aSubsystem name ].

        subsystemsElementId := html nextId.     
        commandsElementId := html nextId.
        commandParametersId := html nextId.

        html heading: 'Send Command' level: 4.
        
        form := html form.
        form class: 'pure-form pure-form-aligned'.
        form with: [
                html fieldSet: [
                        html div class: 'pure-control-group';
                                with: [ 
                                      html label: 'Subsystem: '.
                                        html select
                                                id: subsystemsElementId;
                                            list: names;
                                            selected:  names first;
                                                "update the list with ID 
commandListElementId, executing renderCommandListOn: ajaxHtml "
                                                onChange: (html scriptaculous 
updater 
                                                        id: commandsElementId;
                                                        triggerFormElement: 
subsystemsElementId;
                                              callback: [ :ajaxHtml | self 
renderCommandListOn: ajaxHtml ]
                                                );
                                                "set the subsystem name posted 
by the form, then the variable subsystem will be used by renderCommandListOn: 
ajaxHtml to select the available commands for that subystem"                    
   
                                                callback: [ :value | subsystem 
:= self subsystemWithName: value. ].
                                ].
                        html div class: 'pure-control-group'; id: 
commandsElementId;
                                with: [ self renderCommandListOn: html ].
                        html div class: 'pure-control-group'; id: 
commandParametersId;
                                with: [ self renderCommandParametersOn: html ]. 
                        
                        html div class: 'pure-controls';                        
        
                                with: [ html submitButton class: 'pure-button'; 
on: #sendCommand of: self. ].
                ].
        ].

Reply via email to