com.buglabs.osgi.sewing.pub
Class SewingController

java.lang.Object
  extended by com.buglabs.osgi.sewing.pub.SewingController

public abstract class SewingController
extends java.lang.Object

Implement SewingController to handle the requests to your Sewing App Typically these are public inner classes in your SewingHttpServlet, but they don't have to be. The important thing is to map the url to the controller in your SewingHttpServlet.getControllerMap() method. Lastly, the convention is that the controller class name matches the template name which matches the url. But this doesn't have to be the case. To map a different url to a different controller, do so in your SewingHttpServlet implementation's getControllerMap() method. If you only do this, the controller will still use the url to map to the template. To use a different template, override getTemplateName() in your SewingController.


Field Summary
protected  boolean skip_action
           
 
Constructor Summary
SewingController()
           
 
Method Summary
 void beforeGet(RequestParameters params, HttpServletRequest req, HttpServletResponse resp)
          Override this method if you want to add pre-processing code before a GET request
 void beforePost(RequestParameters params, HttpServletRequest req, HttpServletResponse resp)
          Override this method if you want to add pre-processing code before a POST request
 void clearRedirect()
           
 boolean doRedirect()
          Tells servlet to process a redirect if one is pending
 TemplateModelRoot get(RequestParameters params, HttpServletRequest req, HttpServletResponse resp)
          Override this method to handle get requests Default implementation will simply render the correctly named template without any processing
 RedirectInfo getRedirectInfo()
           
 boolean getSkipAction()
           
 java.lang.String getTemplateName()
          Override this method if you need to set a name for your template that is not part of the conventions.
protected  void paramDebug(RequestParameters params)
          Go ahead and have fun
 TemplateModelRoot post(RequestParameters params, HttpServletRequest req, HttpServletResponse resp)
          Override this method to handle post requests Default implementation will simply render the correctly named template without any processing
protected  void redirectTo(java.lang.String url)
          This does a simple redirect by setting the meta refresh tag in the html page
protected  void render(int requestType, java.lang.String controllerName, RequestParameters params, HttpServletRequest req, HttpServletResponse resp)
          Called from controller to set up for a redirect to a different controller This is the best way to pass params to a new controller
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

skip_action

protected boolean skip_action
Constructor Detail

SewingController

public SewingController()
Method Detail

getSkipAction

public boolean getSkipAction()

get

public TemplateModelRoot get(RequestParameters params,
                             HttpServletRequest req,
                             HttpServletResponse resp)
Override this method to handle get requests Default implementation will simply render the correctly named template without any processing

Parameters:
params -
req -
resp -
Returns:

post

public TemplateModelRoot post(RequestParameters params,
                              HttpServletRequest req,
                              HttpServletResponse resp)
Override this method to handle post requests Default implementation will simply render the correctly named template without any processing

Parameters:
params -
req -
resp -
Returns:

getTemplateName

public java.lang.String getTemplateName()
Override this method if you need to set a name for your template that is not part of the conventions. Include the extension in the name you provide. SewingHttpServlet calls this when looking for a template. If it gets null, it uses the url to find the template. For example, if the url ends with 'foobar', and this method has not been overridden in the controller for foobar, then it will try to load foobar.fml from the templates folder

Returns:

doRedirect

public boolean doRedirect()
Tells servlet to process a redirect if one is pending

Returns:

getRedirectInfo

public RedirectInfo getRedirectInfo()
Returns:

clearRedirect

public void clearRedirect()

beforeGet

public void beforeGet(RequestParameters params,
                      HttpServletRequest req,
                      HttpServletResponse resp)
Override this method if you want to add pre-processing code before a GET request


beforePost

public void beforePost(RequestParameters params,
                       HttpServletRequest req,
                       HttpServletResponse resp)
Override this method if you want to add pre-processing code before a POST request


render

protected final void render(int requestType,
                            java.lang.String controllerName,
                            RequestParameters params,
                            HttpServletRequest req,
                            HttpServletResponse resp)
Called from controller to set up for a redirect to a different controller This is the best way to pass params to a new controller

Parameters:
requestType -
controller -
params -
req -
resp -

redirectTo

protected final void redirectTo(java.lang.String url)
This does a simple redirect by setting the meta refresh tag in the html page

Parameters:
url -

paramDebug

protected final void paramDebug(RequestParameters params)
Go ahead and have fun

Parameters:
params -