我正在构建自己的PageRow组件,并且我试图找出如何在将选择值从10个结果更改为50之后重新加载页面。我需要在刷新期间设置查询参数,我想我可以使用onChanged事件来做到这一点,但这不起作用。有人对如何做到这一点有任何想法吗?
答案 0 :(得分:1)
由于您不需要POST值,因此实际上不需要使用select组件。
爪哇
@Property private int currentRows;
@Inject private ComponentResources resources;
public Link getEventLink(int rows) {
Link link = resources.createEventLink("setRows", rows);
link.addParameter("foo", "bar");
return link;
}
Object onSetRows(int rows) {
...
return this;
}
TML
<select id="rows">
<t:loop source="[10,20,30,40,50]" value="currentRows">
<option value="${getEventLink(currentRows)}">${currentRows}</option>
</t:loop>
</select>
Javascript(jQuery)
$('#rows').change(function() {
document.location.href = $(this).val();
});
您可以轻松地对此进行调整,并使用正确的SelectModel和select组件。
答案 1 :(得分:0)
在服务器端,@ Inject ComponentResources并使用createEventLink(...)为每个选项生成事件URL(10-50)。
在客户端上,将更改侦听器附加到select,它设置window.location.href并导致加载事件URL。