Skip to content

Instantly share code, notes, and snippets.

@pedromtavares
Created May 3, 2010 15:25
Show Gist options
  • Save pedromtavares/388191 to your computer and use it in GitHub Desktop.
Save pedromtavares/388191 to your computer and use it in GitHub Desktop.
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.redirect = new Redirector(request, response);
if (request.getParameter("id")==null){
if (request.getMethod().equals("POST"))
this.doCreate(request, response);
else
if (request.getParameter("method")!=null)
this.doNew(request, response);
else
this.doIndex(request, response);
}
else{
this.resource= manager.find(this.resource.getClass(), Integer.parseInt(request.getParameter("id")));
if (this.resource == null) {
this.redirect.to(getServletName(), "Recurso não encontrado.");
return;
}
if (request.getMethod().equals("POST")){
this.doUpdate(request, response);
}
else{
if (request.getParameter("method")!=null){
String method = request.getParameter("method");
if (method.equals("edit"))
this.doEdit(request, response);
if (method.equals("delete"))
this.doDestroy(request, response);
}
else
this.doShow(request, response);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment