Package cambridge

Examples of cambridge.Template


      }

      // Grab the locale-specific version of the template.
      Locale locale = RequestContextUtils.getLocale(request);

      Template template = templateFactory.createTemplate(locale);
      template.printTo(response.getWriter());
   }
View Full Code Here


         new File("src/main/cambridgetemplates/" + expressionLanguage), "utf-8", -1);

      TemplateFactory tf = templateLoader.newTemplateFactory("skeleton.html");

      for (int i = 0; i < loop; i++) {
         Template template = tf.createTemplate();
         DataModel.User loggedInUser = model.getLoggedInUser();
         template.setProperty("title", "Entries");
         template.setProperty("loggedInUser", loggedInUser);
         template.setProperty("entries", model.getEntries());
         try {
            template.printTo(writer);
            writer.flush();
         } catch (IOException e) {
            e.printStackTrace();
         }
      }
View Full Code Here

   ArrayList<User> users;

   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      Template t = tf.createTemplate();
      t.setProperty("users", users);
      t.printTo(resp.getWriter());
   }
View Full Code Here

   public void apply(Http.Request request, Http.Response response) {
      TemplateFactory tf = getTemplateFactory(templateName);

      final String contentType = MimeTypes.getContentType(templateName, "text/plain");

      Template template = tf.createTemplate(args);

      try {
         OutputStreamWriter out = new OutputStreamWriter(response.out);
         template.printTo(out);
         out.flush();
         setContentTypeIfNotSet(response, contentType);
      } catch (IOException e) {
         throw new UnexpectedException(e);
      }
View Full Code Here

         new File("src/main/cambridgetemplates/" + expressionLanguage), "utf-8", -1);

      TemplateFactory tf = templateLoader.newTemplateFactory("skeleton.html", Expressions.cambridgeExpressionLanguage);

      for (int i = 0; i < loop; i++) {
         Template template = tf.createTemplate();
         DataModel.User loggedInUser = model.getLoggedInUser();
         template.setProperty("title", "Entries");
         template.setProperty("loggedInUser", loggedInUser);
         template.setProperty("entries", model.getEntries());
         try {
            template.printTo(writer);
            writer.flush();
         } catch (IOException e) {
            e.printStackTrace();
         }
      }
View Full Code Here

   ArrayList<User> users;

   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      Template t = tf.createTemplate();
      t.setProperty("users", users);
      t.printTo(resp.getWriter());
   }
View Full Code Here

        }

        Locale locale = RequestContextUtils.getLocale(request);

        TemplateFactory templateFactory = cambridgeConfig.getTemplateFactory(url);
        Template template = templateFactory.createTemplate(locale);
        ExpressionContext context = template.getContext();
        context.setVariables(model);
        template.printTo(response.getWriter());
    }
View Full Code Here

        Cambridge.getInstance().bindTag(Cambridge.DefaultNamespaceURI, "form").toProvider(new FormTagProvider());

        FileTemplateLoader loader = new FileTemplateLoader();
        TemplateFactory templateFactory = loader.parseAndCreateTemplateFactory(template, Expressions.cambridgeExpressionLanguage);

        Template t = templateFactory.createTemplate();

        Form form = new Form();
        form.setAction("/test");
        form.setMethod(Form.Method.Post);
        form.setName("testForm");

        ArrayList<FormInput> formInputs = new ArrayList<FormInput>();
        formInputs.add(new TextFormInput("username", "text", "username", "User Name"));
        form.setInputs(formInputs);

        t.setProperty("f", form);

        PrintWriter writer = new PrintWriter(System.out);
        try {
            t.printTo(writer);
            writer.flush();
            System.out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of cambridge.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.