Wicket自分用メモ
出力結果からwicket:idを消す
getMarkupSettings().setStripWicketTags(true);
ログアウト
add(new Link("logout"){ public void onClick(){ getSession().invalidate(); setResponsePage(getApplication().getHomePage()); } });
HTMLのアトリビュート値書き換え
item.add(new SimpleAttributeModifier("class", "menu-on"));
スタイルシートの参照パスをコンテキストパス足して書き換え
WebApplication application = (WebApplication)getApplication(); final String contextPath = application.getServletContext().getContextPath(); WebComponent cssLink = new WebComponent("cssLink"){ @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); String cssHref = tag.getAttributes().getString("href"); tag.getAttributes().put("href", contextPath + "/" + cssHref); } }; add(cssLink);
もっと良い方法ありそう
add(new StyleSheetReference("cssLink", MyPage.class, "myPage.css"));
CSSの定義ならこうやね。
あとHTMLコメント内は処理されない。