You can but will have to specify the Page to Template mapping yourself:
<pages package="org.apache.click.examples.page">
<page path="notemplate.htm" classname="NoTemplate"/>
</pages>
The NoTemplate page does not need to have an associated template since
Click knows that the URL path "notemplate.htm" maps to NoTemplate Page.
Note that the template and Page class does not have to be the same when
performing manually mapping. The following will also work:
<pages package="org.apache.click.examples.page">
<page path="image.htm" classname="NoTemplate"/>
</pages>
Here Click will map the URL path "image.htm" to NoTemplate Page.
However you need to make sure that the NoTemplate Page overrides getPath
and return null:
public class NoTemplate extends BorderPage {
public void onInit() {
try {
// Write directly to the response writer or outputstream
getContext().getResponse().getWriter().print("Hello world");
} catch (IOException ex) {
}
}
public String getPath() {
return null; // <-- Return null
}
}
(Actually getPath can return a value as long as the template it returns
exists so Velocity can render it)
kind regards
bob
WarnerJan Veldhuis wrote:
Hello list,
I have an ImagePage class which serves images from a database. All is
working fine, except that I have to have an empty image.htm in order for
the URL to be recognized. Since it serves images, I don't need the .htm
for any html output. Can I somehow leave out the image.htm and only
keep the ImagePage class?
Cheers,
WarnerJan