📄 abstractrequestcycleprocessor.java
字号:
requestParameters.getInterfaceName() != null) { final String componentPath = requestParameters.getComponentPath(); final Page page = session.getPage(requestParameters.getPageMapName(), componentPath, requestParameters.getVersionNumber()); if (page != null && page.getClass() == pageClass) { return resolveListenerInterfaceTarget(requestCycle, page, componentPath, requestParameters.getInterfaceName(), requestParameters); } else { return new BookmarkableListenerInterfaceRequestTarget(requestParameters .getPageMapName(), pageClass, params, requestParameters .getComponentPath(), requestParameters.getInterfaceName(), requestParameters.getVersionNumber()); } } else { return new BookmarkablePageRequestTarget(requestParameters.getPageMapName(), pageClass, params); } } catch (RuntimeException e) { throw new WicketRuntimeException("Unable to instantiate Page class: " + bookmarkablePageClass + ". See below for details.", e); } } /** * Resolves to an external resource. * * @param requestCycle * The current request cycle * @return The external resource request target */ protected IRequestTarget resolveExternalResource(RequestCycle requestCycle) { // Get the relative URL we need for loading the resource from // the servlet context // NOTE: we NEED to put the '/' in front as otherwise some versions // of application servers (e.g. Jetty 5.1.x) will fail for requests // like '/mysubdir/myfile.css' String url = requestCycle.getRequest().getURL(); if ((url.length() > 0 && url.charAt(0) != '/') || url.length() == 0) { url = '/' + url; } return new WebExternalResourceRequestTarget(url); } /** * Resolves to a home page target. * * @param requestCycle * the current request cycle. * @param requestParameters * the request parameters object * @return the home page as a request target */ protected IRequestTarget resolveHomePageTarget(final RequestCycle requestCycle, final RequestParameters requestParameters) { Session session = requestCycle.getSession(); Application application = session.getApplication(); try { // Get the home page class Class homePageClass = application.getHomePage(); PageParameters parameters = new PageParameters(requestParameters.getParameters()); // and create a dummy target for looking up whether the home page is // mounted BookmarkablePageRequestTarget homepageTarget = new BookmarkablePageRequestTarget( homePageClass, parameters); IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); CharSequence path = requestCodingStrategy.pathForTarget(homepageTarget); if (path != null) { // The home page was mounted at the given path. // Issue a redirect to that path requestCycle.setRedirect(true); } // else the home page was not mounted; render it now so // that we will keep a clean path return homepageTarget; } catch (MarkupException e) { // Markup exception should pass without modification. They show // a nice error page throw e; } catch (WicketRuntimeException e) { throw new WicketRuntimeException("Could not create home page", e); } } /** * Resolves the RequestTarget for the given interface. This method can be overridden if some * special interface needs to resolve to its own target. * * @param requestCycle * The current RequestCycle object * @param page * The page object which holds the component for which this interface is called on. * @param componentPath * The component path for looking up the component in the page. * @param interfaceName * The interface to resolve. * @param requestParameters * @return The RequestTarget that was resolved */ protected IRequestTarget resolveListenerInterfaceTarget(final RequestCycle requestCycle, final Page page, final String componentPath, final String interfaceName, final RequestParameters requestParameters) { if (page == null) { throw new IllegalArgumentException("page must not be null"); } if (interfaceName == null) { throw new IllegalArgumentException("interfaceName must not be null"); } if (interfaceName.equals(IRedirectListener.INTERFACE.getName())) { return new RedirectPageRequestTarget(page); } else if (interfaceName.equals(INewBrowserWindowListener.INTERFACE.getName())) { return INewBrowserWindowListener.INTERFACE.newRequestTarget(page, page, INewBrowserWindowListener.INTERFACE, requestParameters); } else { // Get the listener interface we need to call final RequestListenerInterface listener = RequestListenerInterface .forName(interfaceName); if (listener == null) { throw new WicketRuntimeException( "Attempt to access unknown request listener interface " + interfaceName); } // Get component Component component; final String pageRelativeComponentPath = Strings.afterFirstPathComponent(componentPath, Component.PATH_SEPARATOR); if (Strings.isEmpty(pageRelativeComponentPath)) { component = page; } else { component = page.get(pageRelativeComponentPath); } if (component == null) { throw new WicketRuntimeException("component " + pageRelativeComponentPath + " not found on page " + page.getClass().getName() + "[id = " + page.getNumericId() + "], listener interface = " + listener); } if (!component.isEnableAllowed()) { throw new UnauthorizedActionException(component, Component.ENABLE); } // Ask the request listener interface object to create a request // target return listener.newRequestTarget(page, component, listener, requestParameters); } } /** * Resolves to a page target that was previously rendered. Optionally resolves to a component * call target, which is a specialization of a page target. If no corresponding page could be * found, a expired page target will be returned. * * @param requestCycle * the current request cycle * @param requestParameters * the request parameters object * @return the previously rendered page as a request target */ protected IRequestTarget resolveRenderedPage(final RequestCycle requestCycle, final RequestParameters requestParameters) { final String componentPath = requestParameters.getComponentPath(); final Session session = requestCycle.getSession(); final Page page = session.getPage(requestParameters.getPageMapName(), componentPath, requestParameters.getVersionNumber()); // Does page exist? if (page != null) { // Set page on request requestCycle.getRequest().setPage(page); // see whether this resolves to a component call or just the page final String interfaceName = requestParameters.getInterfaceName(); if (interfaceName != null) { return resolveListenerInterfaceTarget(requestCycle, page, componentPath, interfaceName, requestParameters); } else { return new PageRequestTarget(page); } } // just return null here and let it be handled further down the road. return null; } /** * Resolves to a shared resource target. * * @param requestCycle * the current request cycle * @param requestParameters * the request parameters object * @return the shared resource as a request target */ protected IRequestTarget resolveSharedResource(final RequestCycle requestCycle, final RequestParameters requestParameters) { return new SharedResourceRequestTarget(requestParameters); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -