Wicket で、
エラーメッセージを
java.lang.IllegalArgumentException: A child with id '@@@@@@' already exists
調べた
エラーが 発生した Wicket の Version
Wicket 1.5.2
MarkupContainer#add(final Component… children) の 動作に ついて
wicket/MarkupContainer.java at master · apache/wicket
の
- MarkupContainer#add(final Component… children) 1
/** * Adds the child component(s) to this container. * * @param children * The child(ren) to add. * @throws IllegalArgumentException * Thrown if a child with the same id is replaced by the add operation. * @return This */ public MarkupContainer add(final Component... children) { for (Component child : children) { Args.notNull(child, "child"); if (this == child) { throw new IllegalArgumentException( exceptionMessage("Trying to add this component to itself.")); } MarkupContainer parent = getParent(); while (parent != null) { if (child == parent) { String msg = "You can not add a component's parent as child to the component (loop): Component: " + this.toString(false) + "; parent == child: " + parent.toString(false); if (child instanceof Border.BorderBodyContainer) { msg += ". Please consider using Border.addToBorder(new " + Classes.simpleName(this.getClass()) + "(\"" + this.getId() + "\", ...) instead of add(...)"; } throw new WicketRuntimeException(msg); } parent = parent.getParent(); } checkHierarchyChange(child); if (log.isDebugEnabled()) { log.debug("Add " + child.getId() + " to " + this); } // Add the child to my children Component previousChild = children_put(child); if (previousChild != null && previousChild != child) { throw new IllegalArgumentException( exceptionMessage("A child '" + previousChild.getClass().getSimpleName() + "' with id '" + child.getId() + "' already exists")); } addedComponent(child); } return this; }
対象の
// Add the child to my children Component previousChild = children_put(child); if (previousChild != null && previousChild != child) { throw new IllegalArgumentException( exceptionMessage("A child '" + previousChild.getClass().getSimpleName() + "' with id '" + child.getId() + "' already exists")); }
RuntimeConfigurationType.DEVELOPMENT
、であっても、RuntimeConfigurationType.DEPLOYMENT
でも
Page 継承関係、add
したと
MarkupContainer の
MarkupContainer#addOrReplace(final Component… children) を 使う
MarkupContainer#addOrReplace
を
MarkupContainer#replace
と
MarkupContainer#get(String path) と、 MarkupContainer#add(final Component… children) の 組み合わせ
MarkupContainer#get
で
このMarkupContainer#add
の
その他 queue と、 dequeue メソッド
Wicket 7 から、MarkupContainer
に、
これは、
以下、
Wicket7の
2度 add したい
以上です。
コメント