| 1 | == HVP pilot add functionality (build servlet in molgenis) == |
| 2 | In order to proper present your data from a javascript call (in a plugin) you need a servlet : |
| 3 | |
| 4 | 1. Add in model the function : |
| 5 | * * public String getCustomHtmlHeaders() |
| 6 | * { |
| 7 | * return "<script src=\"res/scripts/lib.js\" language=\"javascript\"></script>\n" + |
| 8 | * "<script src=\"Prototype/prototype.js\" language=\"javascript\"></script>\n" ; |
| 9 | * |
| 10 | * } |
| 11 | 1. 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. |
| 12 | * Arguments from the .ftl file can be reached through arguments |
| 13 | 1. Add in web.xml the declaration of the servlet |
| 14 | * <servlet> |
| 15 | * <servlet-name>AddEventMenuServlet</servlet-name> |
| 16 | * <servlet-class>servlets.[wiki:AddEventMenuServlet]</servlet-class> |
| 17 | * </servlet> |
| 18 | * <servlet-mapping> <servlet-name>AddEventMenuServlet</servlet-name> |
| 19 | * <url-pattern>/AddEventMenuServlet</url-pattern> |
| 20 | * </servlet-mapping> |
| 21 | 1. Create directory & file for servlet ( /hvp_pilot/handwritten/java/servlets/SearchJsonServlet.java ) |
| 22 | 1. Incude the necessary : |
| 23 | * * package servlets; |
| 24 | * |
| 25 | * import java.io.IOException; |
| 26 | * import java.io.!PrintWriter; |
| 27 | * |
| 28 | * import javax.servlet.!ServletException; |
| 29 | * import javax.servlet.http.!HttpServletRequest; |
| 30 | * import javax.servlet.http.!HttpServletResponse; |
| 31 | * |
| 32 | * import org.apache.log4j.Logger; |
| 33 | * import org.molgenis.util.!HttpServletRequestTuple; |
| 34 | * import org.molgenis.util.Tuple; |
| 35 | * '''__IS this the minimum/optimal set???__''' |
| 36 | 1. What about throws !ServletException, IOException....? |
| 37 | 1. What about doGet & doPost? http://www.molgenis.org/browser/molgenis2_test/src/handwritten/RESTServlet.java?rev=1473 |