Hi,

     what that result.tmpl file contains? is there a way to load ftl files
using CLAP, from web application context, like i am planning to store files
either in WEB-INF or classes folder.

Thanks for your help.

On Mon, Nov 17, 2008 at 8:53 PM, Thierry Boileau (via Nabble) <
[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:

> Hello,
>
> >File templateDir=new File("clap:///template");
> I don't think a java.io.File can be instantiated with a CLAP URI (CLAP is a
> pure Restlet concept). I just suggested you to create a FileRepresentation
> from either a CLAP or a WAR URI in order to return a Representation of a
> file.
>
> If you want to build your HTML representations with Freemarker, you can
> either:
>  - create a TemplateRepresentation with it's template name, which
> requires you to set up the Freemarker configuration as you do but with a
> standard directory => File templateDir = new File("c:/temp/template");
>  - or create a TemplateRepresentation from a Representation of the
> template. For example:
> result = new TemplateRepresentation(new
> FileRepresentation("war:///items/result.tmpl",MediaType.TEXT_HTML),
> configme(), getItem(), MediaType.TEXT_HTML );
>
> I hope this will help you.
>
> Best regards,
> Thierry Boileau
> --
> Restlet ~ Core developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
> > Hi Thierry,
> >
> >             Thanks for your reply, i tried to get the files from
> classpath
> > using CLAP.i have "template" directory in the classpath. but it is still
> not
> > able to read the files in that folder.actually i am trying to use
> freemarker
> > template files stored in my classpath to render output.
> > code is ...
> >
> > public Representation getRepresentation(Variant variant) {
> > Representation result = null;
> > if (variant.getMediaType().equals(MediaType.TEXT_HTML)) {
> > try {
> > //  page.buildFromBackend(getRequest());
> > result = new TemplateRepresentation(getTemplateName(),
> > configme(), getItem(),
> > MediaType.TEXT_HTML);
> > }
> > ---
> > }
> > return result;
> > }
> >
> > Configuration configme() throws IOException{
> > Configuration config=null;
> > config=new Configuration();
> > File templateDir=new File("clap:///template");
> > TemplateLoader fileTemplateLoader=new FileTemplateLoader(templateDir);
> > config.setTemplateLoader(fileTemplateLoader);
> > return config;
> > }
> >
> > String getTemplateName() { return "oneitem.ftl"; }
> >
> > Stack Trace :
> > java.io.FileNotFoundException: clap:\template does not exist.
> > at freemarker.cache.FileTemplateLoader$1.run(FileTemplateLoader.java:125)
>
> > at java.security.AccessController.doPrivileged(Native Method)
> > at
> freemarker.cache.FileTemplateLoader.<init>(FileTemplateLoader.java:122)
> > ---
> > ---
> >
> > please help me .. Thanks
> >
> >
> > Thierry Boileau wrote:
> >
> >> Hello,
> >>
> >>
> >> you can use the WAR protocol scheme (used for serving files from a war
> >> application deployed inside a servlet container), or the CLAP one
> >> (looks for "files" from the classpath).
> >> For example, if your "items" directory is located just under the
> >> "Web-Content" directory:
> >>
> >> FileRepresentation rep=new
> >> FileRepresentation("war:///items/result.jsp",MediaType.TEXT_HTML);
> >>
> >> I would like to precise the FileRepresentation simply gets the content
> >> of the targetted file.
> >>
> >>
> >> Best regards,
> >> Thierry Boileau
> >> --
> >>  Restlet
> >> ~ Core developer ~ http://www.restlet.org
> >> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
> >>
> >>
> >>       I am trying to create a web application with restlet. how can i
> call
> >> a
> >> file in the web application (using relative path).
> >> I went through documentation of restlet, there creating html content in
> >> the
> >> Resource class was explained as shown here.
> >>
> >> getResponse().setStatus(Status.SUCCESS_CREATED);
> >> String result="<h3>Item Created. </h3>";
> >> result += " <p>use <br>
> >> http://localhost:8080/itemRestlet/itemapp/items <br>in
> >> a new browser instance to see the data.</p>";
> >> Representation rep = new
> StringRepresentation(result,MediaType.TEXT_HTML);
> >>
> >>         The FileRepresentation class can take path of the file you want
> to
> >> invoke and content type, but here the problem is trying to locate
> >> result.jsp
> >> in the webserver installation directory rather than in webapp.
> >>
> >>  FileRepresentation rep=new
> >> FileRepresentation("items/result.jsp",MediaType.TEXT_HTML);
> >>
> >>         Can any one please help me to invoke this result.jsp from a
> >> resource?
> >> I am trying to invoke a html/jsp page from web application from a
> >> resource....help me please
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/refering-a-web-app-file-with-FileRepresentation-tp1493159p1509846.html
> To start a new topic under Restlet Discuss, email
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> To unsubscribe from Restlet Discuss, click here< (link removed) ==>.
>
>
>

-- 
View this message in context: 
http://n2.nabble.com/refering-a-web-app-file-with-FileRepresentation-tp1493159p1512866.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

Reply via email to