Open GoogleCodeExporter opened 9 years ago
Sorry for the late reply...I have been away for a few days.
The problem is your browser is not recognizing the response headers as a file
download. If you look in the AbstractViewExporter.responseHeaders() method you
can
see how I set things in the response.
This is the first I have heard about it not working with JMesa, but I have
seen this
problem in general on projects before.
What I would do is try a test without using JMesa and see what works for you. I
do
not know what framework you use, but just create a simple Controller (or
Action) and
see if you can just export some simple text string.
That, or you could get the source code working on your computer and play around
with
the response headers.
http://code.google.com/p/jmesa/wiki/ProjectBuild
You will probably have to spend some time on Google to figure out what you need.
If you figure it out let me know and I can work with you to get the api more
generic
so it works for you.
Original comment by jeff.johnston.mn@gmail.com
on 18 Nov 2009 at 10:07
Thanks for you response. At the end I get the solution after trying some
methods.
I've used API code and tags. This is "the code":
====================================
<%@page buffer="none" session="true" import="java.util.*, org.opencms.jsp.*,
org.opencms.file.*,org.opencms.xml.content.*, org.jmesa.view.editor.*,
com.lowagie.text.pdf.*, jxl.write.biff.*" %>
<%@page import="javax.servlet.*"%>
<%@page import="org.jmesa.facade.*, org.jmesa.limit.*,
org.jmesa.view.component.*,
org.jmesa.view.html.component.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
pageContext.setAttribute("cms", cms);
CmsRequestContext cmsRequest = cms.getRequestContext();
CmsJspNavBuilder navigation = cms.getNavigation();
CmsJspNavElement navElement = (CmsJspNavElement)
navigation.getNavigationBreadCrumb(3, 3).get(0);
String rutaInicio = navElement.getParentFolderName();
String rutaActual = cmsRequest.getFolderUri();
Boolean esFilaImpar = true;
CmsObject cmsObj = cms.getCmsObject();
CmsProject curProj = cmsObj.getRequestContext().currentProject();
List listadoNoticias = null;
cmsObj.loginUser("Admin", "admin");
listadoNoticias = cmsObj.getResourcesInFolder("/ruta_noticias/",
CmsResourceFilter.requireType(3060)); // Elegi en el xml el Id de noticias 3060
List<Noticia> listado = new ArrayList<Noticia>();
if (listadoNoticias != null) {
for (int i = 0; i < listadoNoticias.size(); i++) {
Noticia noticia= new Noticia();
CmsFile ficheroNoticia = (CmsFile) listadoNoticias.get(i);
CmsJspXmlContentBean cjxc = new CmsJspXmlContentBean(pageContext,
request, response);
I_CmsXmlContentContainer icms = cjxc.contentload("singleFile",
ficheroNoticia.getRootPath().substring(14), false);
Iterator it = icms.getCollectorResult().iterator();
while (it.hasNext()) {
CmsResource recurso = (CmsResource)it.next();
CmsFile arquivo = new CmsFile(recurso);
String cadcontido = new String(arquivo.getContents());
CmsXmlContent content = CmsXmlContentFactory.unmarshal(cmsObj,arquivo);
String desde = content.getValue("FechaDesde[1]",
cmsRequest.getLocale()).getStringValue(cmsObj);
String visible = content.getValue("Visible[1]",
cmsRequest.getLocale()).getStringValue(cmsObj);
navElement =
navigation.getNavigationForResource(ficheroNoticia.getRootPath().substring(14));
String titular = content.getValue("Titular[1]",
cmsRequest.getLocale()).getStringValue(cmsObj);
noticia.setNombreFichero(ficheroNoticia.getRootPath().substring(14));
noticia.setId(i);
noticia.setFecha(new Date(Long.parseLong(desde)));
noticia.setTitular(titular);
noticia.setPrioridad(navElement.getNavPosition());
noticia.setVisible(Boolean.parseBoolean(visible));
listado.add(noticia);
}
}
}
if (request.getSession().getAttribute("listado") == null){
request.getSession().setAttribute("listado", listado);
}
TableFacade tablefacade = TableFacadeFactory.createTableFacade("jmesa_noticias",
request);
tablefacade.setColumnProperties("fecha", "titular", "prioridad");
tablefacade.setItems(listado);
tablefacade.setExportTypes(response, ExportType.CSV, ExportType.JEXCEL,
ExportType.PDFP);
tablefacade.setStateAttr("restore");
Limit limit = tablefacade.getLimit();
if(limit.isExported())
{
Table table = tablefacade.getTable();
Row row = table.getRow();
Column colFecha = row.getColumn("fecha");
colFecha.setTitle("Fecha");
colFecha.getCellRenderer().setCellEditor(new DateCellEditor("dd/MM/yyyy"));
Column colTitular = row.getColumn("titular");
colTitular.setTitle("Titular");
Column colPrioridad = row.getColumn("prioridad");
colPrioridad.setTitle("Prioridad");
tablefacade.render();
}
else{
%>
<%@ taglib prefix="jmesa" uri="http://code.google.com/p/jmesa" %>
<%@page import="mi_libreria.Noticia"%>
......
--[ head ]--
......
<div id="listadoContenido">
<form name="displ2" action="index.html">
<jmesa:tableFacade toolbar="mi_libreria.ToolbarJMesa" id="jmesa_noticias"
stateAttr="restore" items="${listado}"
var="noticias" editable="true" exportTypes="jexcel,pdfp,csv" >
<jmesa:htmlTable>
<jmesa:htmlRow uniqueProperty="id">
<jmesa:htmlColumn property="checkbox" title=" "
worksheetEditor="org.jmesa.worksheet.editor.CheckboxWorksheetEditor"
filterable="false" sortable="false" width="2%"/>
<jmesa:htmlColumn property="fecha" title="Fecha"
pattern="dd/MM/yyyy" editable="false"
cellEditor="org.jmesa.view.editor.DateCellEditor" sortable="true" width="10%"
headerClass="sortable" sortOrder="asc,desc,none" />
<jmesa:htmlColumn property="titular" title="Titular"
sortable="true" filterEditor="org.jmesa.view.html.editor.DroplistFilterEditor"
editable="false" headerClass="sortable" sortOrder="asc,desc,none" width="70%"/>
<jmesa:htmlColumn property="prioridad" filterable="false"
title="Prioridad" editable="false" sortable="true" headerClass="sortable"
sortOrder="desc,asc,none" width="8%"/>
<jmesa:htmlColumn property="visible" title="Visible"
editable="false" sortable="true" width="10%"><img
src="<cms:link>${rutaImagen}dibujos/${noticias.mostrarVisible}</cms:link>"
/></jmesa:htmlColumn>
</jmesa:htmlRow>
</jmesa:htmlTable>
</jmesa:tableFacade>
</form>
<c:set var="rutaPrincipal"><%=rutaActual%></c:set>
<script type="text/javascript">
function onInvokeAction(id,action)
{
setExportToLimit(id, '');
//Con este IF hacemos que sólo se pueda ordenar las columnas de una
en una,
//no manteniendo ordenaciones de columnas ya pinchadas
if (action == 'sort') {
var limit = jQuery.jmesa.getTableFacade(id).limit;
var sortSet = limit.getSortSet();
if (sortSet) {
var sort = limit.sortSet[limit.sortSet.length - 1];
removeAllSortsFromLimit(id)
limit.sortSet[0] = sort;
}
}
createHiddenInputFieldsForLimitAndSubmit(id);
}
function onInvokeExportAction(id,action) {
var parameterString = createParameterStringForLimit(id);
location.href = 'index.html?' + parameterString;
}
</script>
</div>
....
--[ foot ]--
<%
}
%>
==================================
Really I use 1 IF: WAY "A" to generate de export file (it works peferctly with
PDF,
Excel and CSV), and WAY "B" to show the list with the information, the personal
toolbar, etc. I don't know if the code could be more optimize (sure yes!!) but
by the
moment my first procupation were it works. Thanks for you response and I hope
than my
solution helps to anybody with the same problem i had.
Original comment by andyned...@gmail.com
on 19 Nov 2009 at 7:40
Original issue reported on code.google.com by
andyned...@gmail.com
on 12 Nov 2009 at 11:58