Seaside with scriptaculous updater

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Seaside with scriptaculous updater

Ezequiel Davidovich Caballero
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

Reply | Threaded
Open this post in threaded view
|

Seaside with scriptaculous updater

Ezequiel Davidovich Caballero



On Saturday, November 9, 2013 7:07 PM, Ezequiel Davidovich Caballero <[hidden email]> 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.

commandRequestUI renderParametersOn.txt (480 bytes) Download Attachment
commandRequestUI renderCommandListOn.txt (956 bytes) Download Attachment
commandRequestUI rendercontentOn.txt (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Seaside with scriptaculous updater

Stéphane Ducasse
In reply to this post by Ezequiel Davidovich Caballero
Welcome ezequiel

- copy and paste your methods so that we can follow directly.
- did you send your questions to the easide mailing-list?

Stef

On Nov 9, 2013, at 11:07 PM, Ezequiel Davidovich Caballero <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: Seaside with scriptaculous updater

Ezequiel Davidovich Caballero
Ok, third time's the charm, I'll copy paste the methods on the mail.

I'm trying to render the third component (the one at the bottom) using the same messages I use on the first method (renderContenOn) to render the second one (the one in the middle).

Thanks in advance!
Ezequiel



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. ].
].
].


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

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.
]


On Sunday, November 10, 2013 2:13 PM, Ezequiel Davidovich Caballero <[hidden email]> wrote:
Stephane,

Thanks for the welcoming message! I attached the methods in text files (to make it more readable). Didn't know there was a Seaside list, I'll look for it.

Cheers!
Ezequiel

ps: I am not a compiler, I am a free programmer! (I was one of the two argentinean students who got the Prisoner reference)


On Sunday, November 10, 2013 8:43 AM, Stéphane Ducasse <[hidden email]> wrote:
Welcome ezequiel

- copy and paste your methods so that we can follow directly.
- did you send your questions to the easide mailing-list?

Stef

On Nov 9, 2013, at 11:07 PM, Ezequiel Davidovich Caballero <[hidden email]> 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