Package com.opensymphony.module.sitemesh

Examples of com.opensymphony.module.sitemesh.HTMLPage


        }
        return contentBuffers.get(name);
    }

    public static HTMLPage content2htmlPage(Content content) {
        HTMLPage htmlPage = null;
        if (content instanceof HTMLPage) {
            htmlPage = (HTMLPage) content;
        } else if (content instanceof TokenizedHTMLPage2Content) {
            htmlPage = ((TokenizedHTMLPage2Content)content).getPage();
        } else {
View Full Code Here


            velocityManager.init(servletContext);

            // get encoding
            String encoding = getEncoding();

            HTMLPage htmlPage = new Content2HTMLPage(content, request);

            // get the template and context
            org.apache.velocity.Template template = velocityManager.getVelocityEngine().getTemplate(oldDecorator.getPage(), encoding);
            Context context = velocityManager.createContext(ctx.getValueStack(), request, response);

            // put the page in the context
            context.put("page", htmlPage);
            context.put("head", htmlPage.getHead());
            context.put("title", htmlPage.getTitle());
            context.put("body", htmlPage.getBody());

            // finally, render it
            PrintWriter writer = response.getWriter();
            template.merge(context, writer);
            writer.flush();
View Full Code Here

            if (model == null) {
                model = freemarkerManager.buildTemplateModel(ctx.getValueStack(), ctx.getActionInvocation().getAction(), servletContext, request, response, config.getObjectWrapper());
            }

            // populate the hash with the page
            HTMLPage htmlPage = new Content2HTMLPage(content, request);
            model.put("page", htmlPage);
            model.put("head", htmlPage.getHead());
            model.put("title", htmlPage.getTitle());
            model.put("body", htmlPage.getBody());
            model.put("page.properties", new SimpleHash(htmlPage.getProperties()));

            // finally, render it
            template.process(model, response.getWriter());
        } catch (Exception e) {
            String msg = "Error applying decorator to request: " + request.getRequestURL() + "?" + request.getQueryString() + " with message:" + e.getMessage();
View Full Code Here

    protected boolean preTemplateProcess(HttpServletRequest request, HttpServletResponse response, Template template, TemplateModel templateModel) throws ServletException, IOException {
        boolean result = super.preTemplateProcess(request, response, template, templateModel);

        SimpleHash hash = (SimpleHash) templateModel;

        HTMLPage htmlPage = (HTMLPage) request.getAttribute(RequestConstants.PAGE);

        String title, body, head;

        if (htmlPage == null) {
            title = "No Title";
            body = "No Body";
            head = "<!-- No head -->";
        } else {
            title = htmlPage.getTitle();

            StringWriter buffer = new StringWriter();
            htmlPage.writeBody(buffer);
            body = buffer.toString();

            buffer = new StringWriter();
            htmlPage.writeHead(buffer);
            head = buffer.toString();

            hash.put("page", htmlPage);
        }
View Full Code Here

* @see com.opensymphony.module.sitemesh.HTMLPage#writeHead(java.io.Writer)
*/
public class HeadTag extends AbstractTag {
    public final int doEndTag() throws JspException
    {
      HTMLPage htmlPage = (HTMLPage)getPage();
      try
      {
        htmlPage.writeHead(getOut());
      }
      catch(IOException e)
      {
        throw new JspException("Error writing head element: " + e.toString(), e);
      }
View Full Code Here

  {
    boolean result=super.preTemplateProcess(request, response, template, templateModel);
   
    SimpleHash hash = (SimpleHash) templateModel;
   
    HTMLPage htmlPage = (HTMLPage) request.getAttribute(RequestConstants.PAGE);

    String title, body, head;

    if(htmlPage==null)
    {
      title="No Title";
      body="No Body";
      head="<!-- No head -->";
    }
    else
    {
      title=htmlPage.getTitle();
     
      StringWriter buffer = new StringWriter();
      htmlPage.writeBody(buffer);
      body=buffer.toString();
     
      buffer = new StringWriter();
      htmlPage.writeHead(buffer);
      head=buffer.toString();

      hash.put("page",htmlPage);
    }
   
View Full Code Here

TOP

Related Classes of com.opensymphony.module.sitemesh.HTMLPage

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.