Yuv*_*val 5 java customization wicket titlebar
我需要在Wicket模态窗口的标题栏中添加一个按钮.我在Wicket API中找不到任何有用的东西可以帮助我.有没有办法以这种方式自定义标题栏?
你可以借助CSS实现这种效果.创建自定义模式窗口(如果您不想创建自定义样式)并指定css资源.
package org.ru5.test;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.resources.CompressedResourceReference;
import org.apache.wicket.model.IModel;
public class CustomModalWindow extends ModalWindow {
private static final long serialVersionUID = 1L;
private static ResourceReference CSS = new CompressedResourceReference(
CustomModalWindow.class, "res/custom-modal.css");
/**
* Creates a new modal window component.
*
* @param id
* Id of component
*/
public CustomModalWindow(final String id) {
super(id);
init();
}
/**
* Creates a new modal window component.
*
* @param id
* Id of component
* @param model
* Model
*/
public CustomModalWindow(final String id, final IModel<?> model) {
super(id, model);
init();
}
private void init() {
add(CSSPackageResource.getHeaderContribution(CSS));
}
}
Run Code Online (Sandbox Code Playgroud)
/org/ru5/test/CustomModalWindow.html
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body><wicket:panel><div wicket:id="content"></div></wicket:panel></body>
</html>
Run Code Online (Sandbox Code Playgroud)
你需要的一切:
/org/ru5/test/res/custom-modal.css
.headBtn{position: absolute; z-index: 20001; top: 2px; left: 200px;}
Run Code Online (Sandbox Code Playgroud)
/org/ru5/test/TestPanelForTestWindow.html
....
<div class="headBtn">
<input type="button" value="ok">
</div>
....
Run Code Online (Sandbox Code Playgroud)
您可以尝试覆盖modal.js函数,或者只是在JS DOM的帮助下制作技巧.希望这会有所帮助.
根据 /org/apache/wicket/extension/ajax/markup/html/modal/res/modal.js 你不能通过 wicket api 修改模态窗口装饰器,因为模态窗口标记完全在 JavaScript 中定义。因此,与往常一样,您可以选择简单但不好的方法并用自己的方式替换 modal.js,否则您很难在显示后使用 js 修改带有类“w_captionText”的 span 来更改模态窗口。或者可能(我没有测试它)您可以在 Caption 属性中定义自定义代码,并告诉 wicket 不要转义此 Caption 中的特殊 html 字符。也许有帮助。
| 归档时间: |
|
| 查看次数: |
10806 次 |
| 最近记录: |