Пример #1
0
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    // set return content type
    response.setContentType("text/html;charset=utf-8");

    request.setAttribute("news", getNews());
    PortletRequestDispatcher reqDispatcher = getPortletContext().getRequestDispatcher(PATHOGEN_JSP);
    reqDispatcher.include(request, response);
  }
Пример #2
0
 public void doEdit(RenderRequest request, RenderResponse response)
     throws IOException, PortletException {
   setRenderAttributes(request);
   response.setContentType("text/html");
   response.setTitle("Edit");
   PortletRequestDispatcher prd =
       getPortletContext().getRequestDispatcher("/WEB-INF/jsp/Browser/edit.jsp");
   prd.include(request, response);
 }
Пример #3
0
  /** Serve up the custom <code>config</code> mode. */
  protected void doCustomConfigure(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    // Set the MIME type for the render response
    response.setContentType(request.getResponseContentType());

    // Invoke the JSP to render
    PortletRequestDispatcher rd =
        getPortletContext().getRequestDispatcher(getJspFilePath(request, CONFIG_JSP));
    rd.include(request, response);
  }
Пример #4
0
  /**
   * Serve up the <code>view</code> mode.
   *
   * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest,
   *     javax.portlet.RenderResponse)
   */
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    // Set the MIME type for the render response
    response.setContentType(request.getResponseContentType());

    // Invoke the JSP to render
    PortletRequestDispatcher rd =
        getPortletContext().getRequestDispatcher(getJspFilePath(request, VIEW_JSP));
    rd.include(request, response);
  }
Пример #5
0
 /* (non-Javadoc)
  * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
  */
 @Override
 protected void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException, UnavailableException {
   response.setContentType("text/html");
   String username = request.getParameter("usernameFromAction");
   request.setAttribute("usernameFromDoView", username);
   String jspPath = (username != null && !username.isEmpty()) ? "/hello.jsp" : "/view.jsp";
   PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(jspPath);
   prd.include(request, response);
 }
Пример #6
0
 /* (non-Javadoc)
  * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
  */
 @Override
 protected void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException, UnavailableException {
   response.setContentType("text/html");
   PrintWriter writer = response.getWriter();
   writer.write("Hello World!");
   writer.write(
       "<html><head></head><body><a href=\"/FileDownloadExample/Download.do?FileId=XXX.pdf\">Download</a></body></html>");
   writer.close();
 }
Пример #7
0
  /** Notify user that not logged in. */
  public void writeNotLoggedInPageHtml(
      RenderRequest request, RenderResponse response, Window window) throws IOException {
    response.setContentType("text/html");
    final BufferedWriter page =
        new BufferedWriter(new OutputStreamWriter(response.getPortletOutputStream(), "UTF-8"));

    page.write("<div class=\"portlet-msg-error\">Please login to use the mail portlet.</div>");

    page.close();
  }
Пример #8
0
  @Override
  protected void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    response.setContentType("text/html");

    PortletRequestDispatcher dispatcher =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");

    dispatcher.include(request, response);
  }
Пример #9
0
  @Override
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    renderResponse.setContentType(ContentTypes.TEXT_HTML_UTF8);

    PrintWriter printWriter = renderResponse.getWriter();

    printWriter.print("Welcome to ".concat(ReleaseInfo.getReleaseInfo()).concat("."));
  }
  public void doEdit(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = getTitleString(request);
    if (title != null) response.setTitle(title);

    Context context = new VelocityContext();
    context.put("tlang", rb);
    context.put("validator", validator);
    sendAlert(request, context);

    PortletURL url = response.createActionURL();
    context.put("actionUrl", url.toString());
    context.put("doCancel", "sakai.cancel");
    context.put("doUpdate", "sakai.update");

    // get current site
    Placement placement = ToolManager.getCurrentPlacement();
    String siteId = "";

    // find the right LTIContent object for this page
    String source = placement.getPlacementConfig().getProperty(SOURCE);
    Long key = getContentIdFromSource(source);
    if (key == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find content id placement=" + placement.getId() + " source=" + source);
      return;
    }

    Map<String, Object> content = m_ltiService.getContent(key);
    if (content == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find content item placement=" + placement.getId() + " key=" + key);
      return;
    }

    // attach the ltiToolId to each model attribute, so that we could have the tool configuration
    // page for multiple tools
    String foundLtiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
    Map<String, Object> tool = m_ltiService.getTool(Long.valueOf(foundLtiToolId));
    if (tool == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find tool placement=" + placement.getId() + " key=" + foundLtiToolId);
      return;
    }

    String[] contentToolModel = m_ltiService.getContentModel(Long.valueOf(foundLtiToolId));
    String formInput = m_ltiService.formInput(content, contentToolModel);
    context.put("formInput", formInput);

    vHelper.doTemplate(vengine, "/vm/edit.vm", context, out);
  }
Пример #11
0
 public void doView(RenderRequest request, RenderResponse response) {
   try {
     setRenderAttributes(request);
     response.setContentType("text/html");
     PortletRequestDispatcher prd =
         getPortletContext().getRequestDispatcher("/WEB-INF/jsp/Browser/browser.jsp");
     prd.include(request, response);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  /* set the Portlet's default Edit: it's a simple <form> */
  public void doEdit(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    renderResponse.setContentType("text/html");
    PortletURL saveSettingsStatisticsURL = renderResponse.createActionURL();
    saveSettingsStatisticsURL.setParameter(
        "saveSettingsGoogleMapsUtility", "saveSettingsGoogleMapsUtility");
    renderRequest.setAttribute(
        "saveSettingsGoogleMapsUtilityURL", saveSettingsStatisticsURL.toString());

    include(editJSP, renderRequest, renderResponse);
  }
Пример #13
0
  @Override
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException {

    renderResponse.setContentType(ContentTypes.TEXT_HTML);

    PrintWriter printWriter = renderResponse.getWriter();

    printWriter.write("<a href=\"");
    printWriter.write(String.valueOf(renderResponse.createActionURL()));
    printWriter.write("\">Send Event</a>");

    printWriter.close();
  }
 /** Include a page. */
 private void include(RenderRequest request, RenderResponse response, String pageName)
     throws PortletException {
   response.setContentType(request.getResponseContentType());
   if (!StringUtil.isDefined(pageName)) {
     throw new NullPointerException("null or empty page name");
   }
   try {
     PortletRequestDispatcher dispatcher =
         getPortletContext().getRequestDispatcher("/portlets/jsp/lastPublications/" + pageName);
     dispatcher.include(request, response);
   } catch (IOException ioe) {
     log("Could not include a page", ioe);
     throw new PortletException(ioe);
   }
 }
Пример #15
0
  /**
   * Serve up the <code>edit</code> mode.
   *
   * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest,
   *     javax.portlet.RenderResponse)
   */
  public void doEdit(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    // Set the MIME type for the render response
    response.setContentType(request.getResponseContentType());

    // Check if portlet session exists
    Vlado2PortletSessionBean sessionBean = getSessionBean(request);
    if (sessionBean == null) {
      response.getWriter().println("<b>NO PORTLET SESSION YET</b>");
      return;
    }

    // Invoke the JSP to render
    PortletRequestDispatcher rd =
        getPortletContext().getRequestDispatcher(getJspFilePath(request, EDIT_JSP));
    rd.include(request, response);
  }
Пример #16
0
  protected void remoteRender(RenderRequest renderRequest, RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.GET, getServerPortletURL());

    setRequestParameters(renderRequest, renderResponse, oAuthRequest);

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    renderResponse.setContentType(ContentTypes.TEXT_HTML);

    PrintWriter printWriter = renderResponse.getWriter();

    printWriter.write(response.getBody());
  }
Пример #17
0
  /**
   * Serve up the <code>view</code> mode.
   *
   * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest,
   *     javax.portlet.RenderResponse)
   */
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    // Set the MIME type for the render response
    response.setContentType(request.getResponseContentType());
    HttpServletRequest req = (HttpServletRequest) request;
    ServletRequest sreq = (ServletRequest) request;
    System.out.println("TEST--->" + req.getQueryString());
    System.out.println("TEST2--->" + sreq.getParameter("param"));
    // Check if portlet session exists
    Vlado2PortletSessionBean sessionBean = getSessionBean(request);
    if (sessionBean == null) {
      response.getWriter().println("<b>NO PORTLET SESSION YET</b>");
      return;
    }

    // Invoke the JSP to render
    PortletRequestDispatcher rd =
        getPortletContext().getRequestDispatcher(getJspFilePath(request, VIEW_JSP));
    rd.include(request, response);
  }
 protected void doEdit(RenderRequest rRequest, RenderResponse rResponse)
     throws PortletException, IOException {
   rResponse.setContentType("text/html");
   PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/edit.jsp");
   prd.include(rRequest, rResponse);
 }
  // Render the portlet - this is not supposed to change the state of the portlet
  // Render may be called many times so if it changes the state - that is tacky
  // Render will be called when someone presses "refresh" or when another portlet
  // onthe same page is handed an Action.
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    response.setContentType("text/html");

    // System.out.println("==== doView called ====");

    // Grab that underlying request to get a GET parameter
    ServletRequest req = (ServletRequest) ThreadLocalManager.get(CURRENT_HTTP_REQUEST);
    String popupDone = req.getParameter("sakai.popup");

    PrintWriter out = response.getWriter();
    Placement placement = ToolManager.getCurrentPlacement();
    response.setTitle(placement.getTitle());
    String source = placement.getPlacementConfig().getProperty(SOURCE);
    if (source == null) source = "";
    String height = placement.getPlacementConfig().getProperty(HEIGHT);
    if (height == null) height = "1200px";
    boolean maximize = "true".equals(placement.getPlacementConfig().getProperty(MAXIMIZE));

    boolean popup = false; // Comes from content item
    boolean oldPopup = "true".equals(placement.getPlacementConfig().getProperty(POPUP));

    // Retrieve the corresponding content item and tool to check the launch
    Map<String, Object> content = null;
    Map<String, Object> tool = null;
    Long key = getContentIdFromSource(source);
    if (key == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find content id placement=" + placement.getId() + " source=" + source);
      return;
    }
    try {
      content = m_ltiService.getContent(key);
      // If we are supposed to popup (per the content), do so and optionally
      // copy the calue into the placement to communicate with the portal
      popup = getLongNull(content.get("newpage")) == 1;
      if (oldPopup != popup) {
        placement.getPlacementConfig().setProperty(POPUP, popup ? "true" : "false");
        placement.save();
      }
      String launch = (String) content.get("launch");
      Long tool_id = getLongNull(content.get("tool_id"));
      if (launch == null && tool_id != null) {
        tool = m_ltiService.getTool(tool_id);
        launch = (String) tool.get("launch");
      }

      // Force http:// to pop-up if we are https://
      String serverUrl = ServerConfigurationService.getServerUrl();
      if (request.isSecure() || (serverUrl != null && serverUrl.startsWith("https://"))) {
        if (launch != null && launch.startsWith("http://")) popup = true;
      }
    } catch (Exception e) {
      out.println(rb.getString("get.info.notconfig"));
      e.printStackTrace();
      return;
    }

    if (source != null && source.trim().length() > 0) {

      Context context = new VelocityContext();
      context.put("tlang", rb);
      context.put("validator", validator);
      context.put("source", source);
      context.put("height", height);
      sendAlert(request, context);
      context.put("popupdone", Boolean.valueOf(popupDone != null));
      context.put("popup", Boolean.valueOf(popup));
      context.put("maximize", Boolean.valueOf(maximize));

      vHelper.doTemplate(vengine, "/vm/main.vm", context, out);
    } else {
      out.println(rb.getString("get.info.notconfig"));
    }

    // System.out.println("==== doView complete ====");
  }
 /*
  * @see wicket.Response#setContentType(java.lang.String)
  */
 public void setContentType(final String mimeType) {
   if (res instanceof RenderResponse) {
     RenderResponse r = (RenderResponse) res;
     r.setContentType(mimeType);
   }
 }
 public void setContentType(String type) {
   response.setContentType(type);
 }