简体   繁体   English

似乎无法完全理解textInput如何在超级简单的网站上运行

[英]Cant seem to fully understand how textInput works on a super simple website

So basically all I need to do is add a 'User' object to a OrderedCollection. 所以基本上我需要做的就是在OrderedCollection中添加一个'User'对象。

All I need to grab from the user is the username and password. 我需要从用户那里获取的是用户名和密码。

Once the submit button is clicked, I would need to add the User to the collection and return to home page (which I guess would be done by calling #answer). 单击提交按钮后,我需要将用户添加到集合并返回主页(我猜这将通过调用#answer来完成)。

Read like 99x times the seaside book on textInput but I fail to understand where is the data stored once the form is submitted. 读取像textInput上的海边书籍的99倍,但我无法理解提交表单后存储的数据在哪里。

Any intel is highly appreciated. 任何英特尔高度赞赏。

This is my current form: 这是我目前的表格:

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

If you read the book 99x times, then you did not read the code samples of forms. 如果您阅读本书99次,那么您没有阅读表格的代码示例。 Your example is even given directly in the example of ContactView in http://book.seaside.st/book/fundamentals/forms/textinputfields 您的示例甚至直接在http://book.seaside.st/book/fundamentals/forms/textinputfields中ContactView示例中ContactView

In your code, the callbacks of the text input fields are empty (ie no code). 在您的代码中,文本输入字段的回调是空的(即没有代码)。 On form submission, Seaside invokes these callbacks with the values entered in the text fields. 在表单提交时,Seaside使用在文本字段中输入的值调用这些回调。 Finally, it will invoke the submit button callback. 最后,它将调用提交按钮回调。

Your code could be: 你的代码可能是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM