{"record":{"id":"8db60aef7e690fa8","repo":"theonedev/onedev","slug":"this-method-is-only-meant-to-be-invoked-on-the-com","errorCode":null,"errorMessage":"This method is only meant to be invoked on the component where the parameter component==this","messagePattern":"This method is only meant to be invoked on the component where the parameter component==this","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/Component.java","lineNumber":4561,"sourceCode":"\tpublic boolean canCallListenerInterface(Method method)\n\t{\n\t\treturn isEnabledInHierarchy() && isVisibleInHierarchy();\n\t}\n\n\t/**\n\t * CAUTION: this method is not meant to be overridden like it was in wicket 1.4 when\n\t * implementing {@link IHeaderContributor}. overload\n\t * {@link Component#renderHead(org.apache.wicket.markup.head.IHeaderResponse)} instead to\n\t * contribute to the response header.\n\t * \n\t * @param component\n\t * @param response\n\t */\n\tpublic final void renderHead(Component component, IHeaderResponse response)\n\t{\n\t\tif (component != this)\n\t\t{\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\"This method is only meant to be invoked on the component where the parameter component==this\");\n\t\t}\n\t\trenderHead(response);\n\t}\n\n\t/**\n\t * Render to the web response whatever the component wants to contribute to the head section.\n\t * \n\t * @param response\n\t *            Response object\n\t */\n\t@Override\n\tpublic void renderHead(IHeaderResponse response)\n\t{\n\t\t// noop\n\t}\n\n\t/** {@inheritDoc} */","sourceCodeStart":4543,"sourceCodeEnd":4579,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/Component.java#L4543-L4579","documentation":"Component.renderHead(Component component, IHeaderResponse response) from IHeaderContributor must only be invoked with the component itself as the first argument. Wicket enforces this with an IllegalStateException to catch frameworks or custom code that pass a different component, which would render headers in the wrong context.","triggerScenarios":"Manually calling component.renderHead(otherComponent, response) inside onRender/onComponentTag or from a behavior with the wrong component reference; custom header contribution pipelines passing a parent/child component.","commonSituations":"Custom render strategies or third-party integrations invoking IHeaderContributor directly; copy-pasted renderHead delegation code passing the wrong `this` reference; behaviors calling renderHead with the behavior's host mismatched.","solutions":["Pass the same component instance: component.renderHead(component, response).","Prefer overriding renderHead(IHeaderResponse) on the component and let the framework call it, rather than invoking it manually.","If delegating between components, call the other component's renderHead on that component itself."],"exampleFix":"// before\nother.renderHead(this, response); // wrong component\n// after\nthis.renderHead(response); // or: other.renderHead(other, response);","handlingStrategy":"validation","validationCode":"if (component != this) { throw new IllegalArgumentException(\"renderHead must be called with this component\"); }","typeGuard":null,"tryCatchPattern":"try { c.renderHead(c, response); } catch (IllegalStateException e) { c.renderHead(response); }","preventionTips":["Let the framework invoke renderHead; avoid calling it manually.","When delegating, always call renderHead on the component that implements it, passing that same instance.","Prefer overriding the single-argument renderHead(IHeaderResponse)."],"tags":["wicket","rendering","headers","illegal-state"],"backgroundTag":"invalid-argument-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}