Login  Register

Re: Dev - Producing an XML response

Posted by David E. Jones on May 29, 2006; 7:31pm
URL: http://ofbiz.116.s1.nabble.com/Dev-Producing-an-XML-response-tp168258p168263.html


The mime type and character encoding are set in the view-map tag in the controller.xml file. See the Control Servlet Guide on ofbiz.org for documentation.

-David


[hidden email] wrote:

> Hi!
>
> That's my first time posting on this list. ;o)
>
> I'm trying to integrate OFBiz within another web application. What I need to do
> is extract the global menu (name and links) and output it in xml. (The global
> menu will be removed from the pages) This is working fine, the outupt is
> correctly formatted. The only problem I get is that the response's contentType
> won't set to text/xml with this code, even if it's there (in the bsh file). My
> browser receives a text/html content type response.
>
> Have I missed something?
>
> I tried to browse and search the lists archives, but I did not find anything
> aoubt this. If this subject has already been discussed, please tell me where.
> Thanks!
>
> Please see the content of the files attached.
>
> Thanks a lot!
>
>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <#if (requestAttributes.security)?exists>
> <#assign security = requestAttributes.security>
> </#if>
> <#if (requestAttributes.externalLoginKey)?exists>
> <#assign externalKeyParam = "?externalLoginKey=" + requestAttributes.externalLoginKey?if_exists>
> </#if>
> <#if (externalLoginKey)?exists>
> <#assign externalKeyParam = "?externalLoginKey=" + requestAttributes.externalLoginKey?if_exists>
> </#if>
> <#assign ofbizServerName = application.getAttribute("_serverId")?default("default-server")>
> <#assign contextPath = request.getContextPath()>
> <#assign displayApps = Static["org.ofbiz.base.component.ComponentConfig"].getAppBarWebInfos(ofbizServerName)>
> <#if requestAttributes.uiLabelMap?exists>
> <#assign uiLabelMap = requestAttributes.uiLabelMap>
> </#if>
>
> <#if requestAttributes.userLogin?has_content>
> <#assign userLogin = requestAttributes.userLogin>
> </#if>
> <ofbizGlobalMenu>
> <#if userLogin?has_content>
> <#list displayApps as display>
>  <#assign thisApp = display.getContextRoot()>
>  <#assign permission = true>
>  <#assign permissions = display.getBasePermission()>
>  <#list permissions as perm>
>      <#if (perm != "NONE" && !security.hasEntityPermission(perm, "_VIEW", session))>
>          <#assign permission = false>
>      </#if>
>  </#list>
>  <#if permission == true>
> <application link="${response.encodeURL(thisApp + "/control/main" + externalKeyParam)}" title="<#if uiLabelMap?exists>${uiLabelMap[display.title]}<#else>${display.title}</#if>" />
>  </#if>
> </#list>
> </#if>
> </ofbizGlobalMenu>
>
>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!--
>  *  Copyright (c) 2003-2005 The Open For Business Project - www.ofbiz.org
>  *
>  *  Permission is hereby granted, free of charge, to any person obtaining a
>  *  copy of this software and associated documentation files (the "Software"),
>  *  to deal in the Software without restriction, including without limitation
>  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
>  *  and/or sell copies of the Software, and to permit persons to whom the
>  *  Software is furnished to do so, subject to the following conditions:
>  *
>  *  The above copyright notice and this permission notice shall be included
>  *  in all copies or substantial portions of the Software.
>  *
>  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
>  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
>  *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
>  *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
>  *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
>  *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>  *
>  *@author     Si Chen ([hidden email])
>  *
> -->
>
> <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/site-conf.xsd">
>     <description>First myTests World Site Configuration File</description>
>     <owner>Open For Business Project (c) 2005 </owner>
>     <errorpage>/error/error.jsp</errorpage>
>
>     <handler name="java" type="request" class="org.ofbiz.webapp.event.JavaEventHandler"/>
>     <handler name="soap" type="request" class="org.ofbiz.webapp.event.SOAPEventHandler"/>
>     <handler name="service" type="request" class="org.ofbiz.webapp.event.ServiceEventHandler"/>
>     <handler name="service-multi" type="request" class="org.ofbiz.webapp.event.ServiceMultiEventHandler"/>
>     <handler name="simple" type="request" class="org.ofbiz.webapp.event.SimpleEventHandler"/>
>
>     <handler name="bsf" type="request" class="org.ofbiz.webapp.event.BsfEventHandler"/>
>
>     <handler name="ftl" type="view" class="org.ofbiz.webapp.ftl.FreeMarkerViewHandler"/>
>     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
>     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
>
>     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
>
>     <preprocessor>
>         <!-- Events to run on every request before security (chains exempt) -->
>         <!-- <event type="java" path="org.ofbiz.webapp.event.TestEvent" invoke="test"/>
>         <event type="java" path="org.ofbiz.securityext.login.LoginEvents" invoke="checkExternalLoginKey"/>-->
>     </preprocessor>
>     <postprocessor>
>         <!-- Events to run on every request after all other processing (chains exempt) -->
>         <!-- <event type="java" path="org.ofbiz.webapp.event.TestEvent" invoke="test"/> -->
>     </postprocessor>
>
>     <!-- Request Mappings -->
>     <request-map uri="main">
>         <response name="success" type="view" value="main"/>
>     </request-map>
>
>     <!--
>     <request-map uri="login">
>       <security https="true" auth="false"/>
>       <event type="java" path="org.ofbiz.securityext.login.LoginEvents" invoke="login"/>
>       <response name="success" type="view" value="main"/>
>       <response name="error" type="view" value="login"/>
>     </request-map>
>     -->
>     <request-map uri="login">
>     <description>Logs in a user</description>
>       <security https="true" auth="false"/>
>       <event type="bsf" path="/" invoke="myTestsBsh.bsh"/>
>       <response name="success" type="request" value="checkLogin"/>
>       <response name="error" type="view" value="login"/>
>     </request-map>
>    
>     <request-map uri="checkLogin" edit="false">
>         <description>Verify a user is logged in.</description>
>         <security https="true" auth="false"/>
>         <event type="java" path="org.ofbiz.securityext.login.LoginEvents" invoke="checkLogin" />
>         <response name="success" type="view" value="main" />
>         <response name="error" type="view" value="login" />
>     </request-map>
>    
>
>     <!-- end of request mappings -->
>
>     <!-- View Mappings -->
>     <view-map name="error" type="jsp" page="/error/error.jsp"/>
>     <view-map name="main" type="ftl" page="main.ftl"/>
>     <view-map name="login" type="ftl" page="login.ftl"/>
>     <!-- end of view mappings -->
> </site-conf>
>
>
> ------------------------------------------------------------------------
>
>  
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev