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)
@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 件のコメント:
コメントを投稿