{"record":{"id":"63ca83104dba76af","repo":"theonedev/onedev","slug":"no-page-found-for-component","errorCode":null,"errorMessage":"No Page found for component ","messagePattern":"No Page found for component ","errorType":"exception","errorClass":"WicketRuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/Component.java","lineNumber":1770,"sourceCode":"\t/**\n\t * Gets the page holding this component.\n\t * \n\t * @return The page holding this component\n\t * @throws WicketRuntimeException\n\t *             Thrown if component is not yet attached to a Page.\n\t * @see #findPage()\n\t */\n\t@Override\n\tpublic final Page getPage()\n\t{\n\t\t// Search for nearest Page\n\t\tfinal Page page = findPage();\n\n\t\t// If no Page was found\n\t\tif (page == null)\n\t\t{\n\t\t\t// Give up with a nice exception\n\t\t\tthrow new WicketRuntimeException(\"No Page found for component \" + this);\n\t\t}\n\n\t\treturn page;\n\t}\n\n\t/**\n\t * Gets the path to this component relative to its containing page, i.e. without leading page\n\t * id.\n\t * \n\t * @return The path to this component relative to the page it is in\n\t */\n\t@Override\n\tpublic final String getPageRelativePath()\n\t{\n\t\treturn Strings.afterFirstPathComponent(getPath(), PATH_SEPARATOR);\n\t}\n\n\t/**","sourceCodeStart":1752,"sourceCodeEnd":1788,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/Component.java#L1752-L1788","documentation":"Component.getPage() calls findPage() and throws this WicketRuntimeException if the component is not attached to a Page. Many Wicket APIs (URL generation, session access, request targets) require a page, so calling them on a detached or unattached component surfaces this error.","triggerScenarios":"Calling getPage(), getRequest(), getResponse(), urlFor(), setResponsePage, etc. on a component that has not been added to a page, or after it was removed; also during constructor code that runs before the component is added to its parent.","commonSituations":"Accessing getRequest()/getPage() inside a component's constructor (component not yet parented); calling page-dependent APIs on components removed from the hierarchy; tests that forget startPage/createRequestCycle.","solutions":["Defer page/request-dependent logic to onInitialize(), onBeforeRender(), or onConfigure() instead of the constructor","Ensure the component is added to a Page before calling getPage()-dependent APIs","In constructors, use the constructor parameters (e.g. IModel) instead of getRequest()","In tests, start the page first so the component hierarchy is attached"],"exampleFix":"// before\npublic MyPanel(String id) {\n    super(id);\n    setResponsePage(Home.class); // no page yet\n}\n// after\npublic MyPanel(String id) {\n    super(id);\n    add(new Link<Void>(\"go\") {\n        @Override\n        public void onClick() {\n            setResponsePage(Home.class);\n        }\n    });\n}","handlingStrategy":"type-guard","validationCode":"if (component.findPage() == null) {\n    // defer page-dependent logic until attached\n    return;\n}","typeGuard":"boolean isAttachedToPage(Component c) {\n    return c.findPage() != null;\n}","tryCatchPattern":"try {\n    component.getPage().getUrl();\n} catch (WicketRuntimeException e) {\n    if (e.getMessage().startsWith(\"No Page found for component\")) {\n        // component is not in a page hierarchy yet\n    }\n}","preventionTips":["Never call getPage()/getRequest() in component constructors; use onInitialize/onBeforeRender","Pass IModel data through constructors instead of request lookups","Call page-dependent APIs only from link onClick(), onSubmit(), or render-phase hooks"],"tags":["wicket","page","component-hierarchy"],"backgroundTag":"resource-not-found","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"}