我需要选择由选项 1、2、3 ... 250 组成。
<p>
<t:label for="quantity2" style="width:40%" />
<t:select t:id="quantity2" t:model="literal:0,1,2,3,4,5,6,7" />
</p>
此代码有效,但我希望数字达到 250!
谢谢你,对不起我的英语不好。
我需要选择由选项 1、2、3 ... 250 组成。
<p>
<t:label for="quantity2" style="width:40%" />
<t:select t:id="quantity2" t:model="literal:0,1,2,3,4,5,6,7" />
</p>
此代码有效,但我希望数字达到 250!
谢谢你,对不起我的英语不好。
来自选择组件的文档“当模型参数是字符串时,它以逗号分隔。当模型参数是字符串列表时,每个元素都被认为是一个选择选项。”
所以,我建议你使用一个字符串列表:
TML
<t:select t:id="quantity2" value="selectedQuantity2" t:model="quantities" />
爪哇
public List<String> getQuantities() {
// create a list of strings from "1" to "250"
}
Change your select do this:
<t:select t:id="quantity2" value="selectedQuantity2" t:model="Quantity2Model" />
In your page class, do this
@Property
private SelectModel quantity2Model;
@Inject
SelectModelFactory smf;
void setupRender()
{
List<int> values = new ArrayList<int>();
for (int i = 0; i <= 250; ++i)
{
values.Add(i);
}
quantity2Model = smf.create(values, "name");
}
Warning: I've never even heard of tapestry until I read your question, and I am not proficient in Java, so this is just based on my research from here. Good luck!