Smalltalk/Seaside-一种更优雅的单选按钮使用方式?

Smalltalk/Seaside-一种更优雅的单选按钮使用方式?,smalltalk,seaside,Smalltalk,Seaside,所以我想做一些类似的事情: html unorderedList: [ group := html radioGroup. self employeeNames do: [ :eachEmp | html listItem: [ group radioButton selected: <set tmpVar = em

所以我想做一些类似的事情:

html unorderedList: [
group := html radioGroup.
self employeeNames do: [ :eachEmp | 
                    html listItem: [
                                group radioButton
                                   selected: <set tmpVar = empKey>
                                   callback: [ self <dependent on button pushed> ].            
                         html text: eachEmp ] ] ]   ]
我想做的是生成一个员工列表,每行都有单选按钮。然后,根据选择的单选按钮和按下的按钮,我们执行一些操作

所以我想要的视觉表现是这样的:

html unorderedList: [
group := html radioGroup.
self employeeNames do: [ :eachEmp | 
                    html listItem: [
                                group radioButton
                                   selected: <set tmpVar = empKey>
                                   callback: [ self <dependent on button pushed> ].            
                         html text: eachEmp ] ] ]   ]
|张贴考勤卡|-|时间表历史记录|-|打印工资支票|-|删除|

雇员1。。。。。数据数据数据 雇员2。。。。。数据数据数据 雇员3。。。。。数据数据数据 雇员4。。。。。数据数据数据 雇员5。。。。。数据数据数据 例如,他们可以选择Employee 3,然后按下| Delete |-这将触发Employee 3的删除


我想我可以处理代码的selected:部分,但是我不知道如何处理回调?有没有一种方法可以动态选择呼叫什么?

因为您使用的是无线组,所以您只能从员工列表中选择一个条目。现在,如果您使用表单元素包装控件,您的动作锚定可以简单地触发表单的提交:

formName := 'employee-form'.

html form
    name: formName;
    with: [
        html unorderedList: [
            group := html radioGroup.
            self employeeNames do: [ :eachEmp | 
            html listItem: [
                group radioButton
                    selected: nil "<set tmpVar = empKey>";
                    callback: [ :value | self "<dependent on button pushed>" ];  
                    with: eachEmp ] ] ] ].

html anchor
    submitFormNamed: formName;
    callback: [ :value | self handleDelete ]
    with: 'delete'
锚的回调将在表单元素的所有回调之后进行计算


旁注:注意使用with:设置锚定和单选按钮文本。您几乎应该始终使用with:作为html的最后一条消息。

因为您使用的是广播组,所以您只能从员工列表中选择一个条目。现在,如果您使用表单元素包装控件,您的动作锚定可以简单地触发表单的提交:

formName := 'employee-form'.

html form
    name: formName;
    with: [
        html unorderedList: [
            group := html radioGroup.
            self employeeNames do: [ :eachEmp | 
            html listItem: [
                group radioButton
                    selected: nil "<set tmpVar = empKey>";
                    callback: [ :value | self "<dependent on button pushed>" ];  
                    with: eachEmp ] ] ] ].

html anchor
    submitFormNamed: formName;
    callback: [ :value | self handleDelete ]
    with: 'delete'
锚的回调将在表单元素的所有回调之后进行计算

旁注:注意使用with:设置锚定和单选按钮文本。您几乎应该始终使用with:作为html的最后一条消息