似乎无法完全理解textInput在超级简单网站上的工作方式

Ale*_*ejo 2 oop smalltalk seaside pharo

因此,基本上我需要做的就是向OrderedCollection中添加一个“用户”对象。

我需要从用户那里获取的只是用户名和密码。

单击提交按钮后,我需要将用户添加到集合中并返回首页(我想可以通过调用#answer来完成)。

在textInput上的阅读速度是海边书籍的99倍,但是提交表单后,我无法理解存储在哪里的数据。

任何英特尔都将受到高度赞赏。

这是我目前的表格:

html form: [ 
        html text: 'Username: '.
        html  textInput 
            callback: [  ];
            value: 'Enter username here'.
        html break.
        html text: 'Password: '.
        html textInput 
            callback: [  ];
            value: 'Enter password here'.
        html break.
        html submitButton 
            callback: [  ];
            value: 'Add user']
Run Code Online (Sandbox Code Playgroud)

Joh*_*n B 7

如果您读过99本书,那么您就没有阅读表格的代码示例。您的示例甚至直接ContactViewhttp://book.seaside.st/book/fundamentals/forms/textinputfields中的示例中给出

在您的代码中,文本输入字段的回调为空(即没有代码)。在提交表单时,Seaside会使用在文本字段中输入的值来调用这些回调。最后,它将调用Submit按钮回调。

您的代码可能是:

| user pass |
html form: [ 
        html text: 'Username: '.
        html  textInput 
            callback: [:userValue | user := userValue ];
            value: 'Enter username here'.
        html break.
        html text: 'Password: '.
        html textInput 
            callback: [:passValue | pass := passValue ];
            value: 'Enter password here'.
        html break.
        html submitButton
            callback: [ self addUser: user withPassword: pass ];
            value: 'Add user']
Run Code Online (Sandbox Code Playgroud)

  • @Alejo,我可以建议您继续提出新问题,而不要像上面一样将其添加到评论中吗? (2认同)