6/20/2008

The page auto mapping without templates

Click Framework provides the page auto mapping. This is the important feature to decrease amount of configuration.

However Click maps page classes to request-path from HTML templates. So page classes which do not have corresponded HTML template is not mapped automatically.

For example:

  • pages which share a HTML template
  • the page which returns JSON or file (response is written in the page class)
I'm thinking about annotations on Click Framework. How about the @Path annotation which specifies the auto mapping path to page classes.
@Path("/file-download.htm")
public class FileDonwloadPage extends Page {

  /**
   * Writes response for file downloading in this method.
   */
  @Override public void onRender() {
    HttpServletResponse res = getContext().getResponse();
    OutputStream out = res.getOutputStream();
    ...
  }

  /**
   * This method returns null to not render template,
   * because this class writes response contents for file download.
   */
  public String getPath(){
    return null;
  }
}
This is one idea of using annotation in Click Framework.

0 件のコメント: