如何使用Apache Wicket将重点放在组件上?搜索导致的信息非常少,主要是设置默认字段.我不想设置默认字段,而是在设置焦点时,例如,选择特定的单选按钮.
mar*_*n-g 17
我建议使用原生org.apache.wicket.ajax.AjaxRequestTarget#focusComponent().例如:
/**
* Sets the focus in the browser to the given component. The markup id must be set. If
* the component is null the focus will not be set to any component.
*
* @param component
* The component to get the focus or null.
*/
org.apache.wicket.ajax.AjaxRequestTarget#focusComponent(Component component)
Run Code Online (Sandbox Code Playgroud)
创建行为以设置焦点后,您应该能够在任何事件上将其添加到组件,只需确保该组件是AjaxRequestTarget的一部分.我不明白为什么这不起作用......
myRadioButton.add(new AjaxEventBehavior("onchange") {
@Override
protected void onEvent(AjaxRequestTarget target) {
myOtherComponent.add(new DefaultFocusBehavior());
target.addComponent(myForm);
}
});
Run Code Online (Sandbox Code Playgroud)
这是一个链接,显示如果您还没有创建默认焦点行为:http: //javathoughts.capesugarbird.com/2009/01/wicket-and-default-focus-behavior.html
| 归档时间: |
|
| 查看次数: |
13883 次 |
| 最近记录: |