Package org.ofbiz.webapp.view

Examples of org.ofbiz.webapp.view.ViewHandlerException


            // this is the object used to render forms from their definitions
            FreeMarkerWorker.getSiteParameters(request, screens.getContext());
            screens.getContext().put("formStringRenderer", new HtmlFormRenderer(request, response));
            screens.render(page);
        } catch (IOException e) {
            throw new ViewHandlerException("Error in the response writer/output stream: " + e.toString(), e);
        } catch (SAXException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (ParserConfigurationException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (GeneralException e) {
            throw new ViewHandlerException("Lower level error rendering page: " + e.toString(), e);
        } catch (TemplateModelException e) {
            throw new ViewHandlerException("Whitespace compression error rendering page: " + e.toString(), e);
        }
    }
View Full Code Here


            screens.getContext().put("formStringRenderer", new TextFormRenderer(request, response));
            screens.render(page);
            writer.flush();

        } catch (IOException e) {
            throw new ViewHandlerException("Error in the response writer/output stream: " + e.toString(), e);
        } catch (SAXException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (ParserConfigurationException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (GeneralException e) {
            throw new ViewHandlerException("Lower level error rendering page: " + e.toString(), e);
        }
    }
View Full Code Here

            screens.populateContextForRequest(request, response, servletContext);
            // this is the object used to render forms from their definitions
            screens.getContext().put("formStringRenderer", new XmlFormRenderer(request, response));
            screens.render(page);
        } catch (IOException e) {
            throw new ViewHandlerException("Error in the response writer/output stream: " + e.toString(), e);
        } catch (SAXException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (ParserConfigurationException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (GeneralException e) {
            throw new ViewHandlerException("Lower level error rendering page: " + e.toString(), e);
        }
    }
View Full Code Here

       
        //nice thought, but doesn't do auto reloading with this: config.setServletContextForTemplateLoading(context, "/");
        try {
            config.setDirectoryForTemplateLoading(new File(context.getRealPath("/")));
        } catch (java.io.IOException e) {
            throw new ViewHandlerException("Could not create file for webapp root path", e);
        }
        WrappingTemplateModel.setDefaultObjectWrapper(BeansWrapper.getDefaultInstance());
        try {       
            config.setObjectWrapper(BeansWrapper.getDefaultInstance());
            config.setCacheStorage(new OfbizCacheStorage("unknown"));
            config.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");
        } catch (TemplateException e) {
            throw new ViewHandlerException("Freemarker TemplateException", e.getCause());
        }       
    }   
View Full Code Here

    }   
   
    public void render(String name, String page, String info, String contentType, String encoding,
            HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {               
        if (page == null || page.length() == 0)
            throw new ViewHandlerException("Invalid template source");
       
        // make the root context (data model) for freemarker
        SimpleHash root = new SimpleHash(BeansWrapper.getDefaultInstance());
        prepOfbizRoot(root, request, response);
                      
        // get the template
        Template template = null;
        try {
            template = config.getTemplate(page, UtilHttp.getLocale(request));
        } catch (IOException e) {
            throw new ViewHandlerException("Cannot open template file: " + page, e);
        }
        template.setObjectWrapper(BeansWrapper.getDefaultInstance());
       
        // process the template & flush the output
        try {
            template.process(root, response.getWriter(), BeansWrapper.getDefaultInstance());
            response.flushBuffer();
        } catch (TemplateException te) {
            throw new ViewHandlerException("Problems processing Freemarker template", te);
        } catch (IOException ie) {
            throw new ViewHandlerException("Problems writing to output stream", ie);
        }      
    }
View Full Code Here

    public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
        // some containers call filters on EVERY request, even forwarded ones,
        // so let it know that it came from the control servlet

        if (request == null)
            throw new ViewHandlerException("Null HttpServletRequest object");
        if (page == null || page.length() == 0)
            throw new ViewHandlerException("Null or empty source");

        if (Debug.infoOn()) Debug.logInfo("Retreiving HTTP resource at: " + page, module);
        try {
            String result = null;
           
            List entityList = (List)request.getAttribute("entityList");
            SimpleSequence simpleList = new SimpleSequence(entityList);
            Map ctx = new HashMap();
            ctx.put("entityList", simpleList);
            StringWriter outWriter = new StringWriter();
            Template template = getDocTemplate(page);
            template.process(ctx, outWriter);
            outWriter.close();
            result = outWriter.toString();
            Debug.logInfo(result, result);
            response.getWriter().print(result);
        } catch (FileNotFoundException e) {
            throw new ViewHandlerException(e.getMessage(), e);
        } catch (IOException e) {
            throw new ViewHandlerException("IO Error in view", e);
        } catch (URISyntaxException e) {
            throw new ViewHandlerException(e.getMessage(), e);
        } catch (TemplateException e) {
            throw new ViewHandlerException(e.getMessage(), e);
        }
    }
View Full Code Here

                Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
                dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
             } else {
                GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", contentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
                if (contentRevisionItem == null) {
                    throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + contentId
                                                   + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
                }
                Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
                Debug.logInfo("SCVH(2)-contentId=" + contentId
                        + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
View Full Code Here

                        Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
                    }
                } else {
                   GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
                   if (contentRevisionItem == null) {
                       throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + rootContentId
                                                      + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
                   }
                   Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
                   Debug.logInfo("SCVH(2)-contentId=" + rootContentId
                           + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
                   dataResourceId = contentRevisionItem.getString("newDataResourceId");
                   Debug.logInfo("SCVH(3)- dataResourceId:" + dataResourceId, module);
                }
        }
      GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
        byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir);
        ByteArrayInputStream bais = new ByteArrayInputStream(byteBuffer.array());
            // hack for IE and mime types
            //String userAgent = request.getHeader("User-Agent");
            //if (userAgent.indexOf("MSIE") > -1) {
            //    Debug.log("Found MSIE changing mime type from - " + mimeTypeId, module);
            //    mimeTypeId = "application/octet-stream";
            //}
            // setup chararcter encoding and content type
            String charset = dataResource.getString("characterSetId");
            mimeTypeId = dataResource.getString("mimeTypeId");
            if (UtilValidate.isEmpty(charset)) {
              charset = servletContext.getInitParameter("charset");
            }
            if (UtilValidate.isEmpty(charset)) {
              charset = "ISO-8859-1";
            }

            // setup content type
            String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" +charset : contentType;

            UtilHttp.streamContentToBrowser(response, bais, byteBuffer.limit(), contentType2);
      } catch(GenericEntityException e) {
            throw new ViewHandlerException(e.getMessage());
      } catch(IOException e) {
            throw new ViewHandlerException(e.getMessage());
      } catch(GeneralException e) {
            throw new ViewHandlerException(e.getMessage());
      }
     }
View Full Code Here

                Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
                dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
             } else {
                GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", contentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
                if (contentRevisionItem == null) {
                    throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + contentId
                                                   + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
                }
                Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
                Debug.logInfo("SCVH(2)-contentId=" + contentId
                        + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
View Full Code Here

                   dataResourceId = content.getString("dataResourceId");
                   Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
                } else {
                   GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
                   if (contentRevisionItem == null) {
                       throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + rootContentId
                                                      + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
                   }
                   Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
                   Debug.logInfo("SCVH(2)-contentId=" + rootContentId
                           + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
                   dataResourceId = contentRevisionItem.getString("newDataResourceId");
                   Debug.logInfo("SCVH(3)- dataResourceId:" + dataResourceId, module);
                }
        }
      GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
        byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResourceId, https, webSiteId, locale, rootDir);
        ByteArrayInputStream bais = new ByteArrayInputStream(byteWrapper.getBytes());
            // hack for IE and mime types
            //String userAgent = request.getHeader("User-Agent");
            //if (userAgent.indexOf("MSIE") > -1) {
            //    Debug.log("Found MSIE changing mime type from - " + mimeTypeId, module);
            //    mimeTypeId = "application/octet-stream";
            //}
            // setup chararcter encoding and content type
            String charset = dataResource.getString("characterSetId");
            mimeTypeId = dataResource.getString("mimeTypeId");
            if (UtilValidate.isEmpty(charset)) {
              charset = servletContext.getInitParameter("charset");
            }
            if (UtilValidate.isEmpty(charset)) {
              charset = "ISO-8859-1";
            }

            // setup content type
            String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" +charset : contentType;

            UtilHttp.streamContentToBrowser(response, bais, byteWrapper.getLength(), contentType2);
      } catch(GenericEntityException e) {
            throw new ViewHandlerException(e.getMessage());
      } catch(IOException e) {
            throw new ViewHandlerException(e.getMessage());
      } catch(GeneralException e) {
            throw new ViewHandlerException(e.getMessage());
      }
     }
View Full Code Here

TOP

Related Classes of org.ofbiz.webapp.view.ViewHandlerException

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.