/** * Sets the content display mode. Note that the window attributes will be ignored if the mode is changed to * something other than {@link WContent.DisplayMode#OPEN_NEW_WINDOW}. * * @param displayMode the content display mode to set. */ public void setDisplayMode(final DisplayMode displayMode) { content.setDisplayMode(displayMode); link.setOpenNewWindow(DisplayMode.OPEN_NEW_WINDOW.equals(content.getDisplayMode())); }
ContentAccess content = getContentAccess(); String mode = DisplayMode.PROMPT_TO_SAVE.equals(getDisplayMode()) ? "attach" : "inline";
switch (content.getDisplayMode()) { case DISPLAY_INLINE: case PROMPT_TO_SAVE: throw new IllegalStateException("Invalid display mode: " + content.getDisplayMode());
/** * <p> * Override handleRequest in order to perform processing specific to this component.</p> * * <p> * When the new browser window for the document content is opened, it will make another request to fetch the * content. It is that situation we are trying to detect and handle here.</p> * * @param request the request being responded to. */ @Override public void handleRequest(final Request request) { resetDisplayRequested(); // Has this component been targeted to return the document content? // Look in the request for the target parameter and see if it's for us. // The target parameter is encoded into the url in the javascript that // was rendered by this component to open the new browser window. String targ = request.getParameter(Environment.TARGET_ID); boolean contentReqested = targ != null && targ.equals(getTargetId()); if (contentReqested) { ContentEscape escape = new ContentEscape(getContentAccess()); escape.setCacheable(!Util.empty(getCacheKey())); escape.setDisplayInline(getDisplayMode() != DisplayMode.PROMPT_TO_SAVE); throw escape; } }