wiki:DespoinaLog/2010/04/27

Version 1 (modified by trac, 14 years ago) (diff)

--

HVP pilot add functionality (build servlet in molgenis)

In order to proper present your data from a javascript call (in a plugin) you need a servlet :

  1. Add in model the function :
    • * public String getCustomHtmlHeaders()
    • {
    • return "<script src=\"res/scripts/lib.js\" language=\"javascript\"></script>\n" +
    • "<script src=\"Prototype/prototype.js\" language=\"javascript\"></script>\n" ;
    • }
  2. Place the javascript file in the referred location. In the ftl file call the function as onclick="RestJsonDatafromOntocat(InputTerm?)" not as onclick="__action.value='SubmitTerm?' . The second is used for function inside the model.
    • Arguments from the .ftl file can be reached through arguments
  3. Add in web.xml the declaration of the servlet
  4. Create directory & file for servlet ( /hvp_pilot/handwritten/java/servlets/SearchJsonServlet.java )
  5. Incude the necessary :
    • * package servlets;
    • import java.io.IOException;
    • import java.io.PrintWriter;
    • import javax.servlet.ServletException;
    • import javax.servlet.http.HttpServletRequest;
    • import javax.servlet.http.HttpServletResponse;
    • import org.apache.log4j.Logger;
    • import org.molgenis.util.HttpServletRequestTuple;
    • import org.molgenis.util.Tuple;
      • IS this the minimum/optimal set???
  6. What about throws ServletException, IOException....?
  7. What about doGet & doPost? http://www.molgenis.org/browser/molgenis2_test/src/handwritten/RESTServlet.java?rev=1473