IDEMPIERE-1309 Improve JasperReport support for loading of resources (image, text file, etc )
This commit is contained in:
parent
a174382caf
commit
cf87e78e05
|
@ -376,6 +376,12 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
reportResult(AD_PInstance_ID, "Can not find report", trxName);
|
reportResult(AD_PInstance_ID, "Can not find report", trxName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (reportPath.startsWith("@#LocalHttpAddr@")) {
|
||||||
|
String localaddr = Env.getContext(Env.getCtx(), "#LocalHttpAddr");
|
||||||
|
if (!Util.isEmpty(localaddr)) {
|
||||||
|
reportPath = reportPath.replace("@#LocalHttpAddr@", localaddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JasperData data = null;
|
JasperData data = null;
|
||||||
File reportFile = null;
|
File reportFile = null;
|
||||||
|
@ -421,7 +427,13 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
resourcePath = resourcePath + "/";
|
resourcePath = resourcePath + "/";
|
||||||
}
|
}
|
||||||
params.put("SUBREPORT_DIR", resourcePath);
|
params.put("SUBREPORT_DIR", resourcePath);
|
||||||
params.put("RESOURCE_DIR", resourcePath);
|
if (reportPath.startsWith("http://") || reportPath.startsWith("https://")) {
|
||||||
|
int i = reportPath.lastIndexOf("/");
|
||||||
|
String httpPath = reportPath.substring(0, i+1);
|
||||||
|
params.put("RESOURCE_DIR", httpPath);
|
||||||
|
} else {
|
||||||
|
params.put("RESOURCE_DIR", resourcePath);
|
||||||
|
}
|
||||||
|
|
||||||
if (jasperReport != null && pi.getTable_ID() > 0 && Record_ID <= 0 && pi.getRecord_IDs() != null && pi.getRecord_IDs().length > 0)
|
if (jasperReport != null && pi.getTable_ID() > 0 && Record_ID <= 0 && pi.getRecord_IDs() != null && pi.getRecord_IDs().length > 0)
|
||||||
{
|
{
|
||||||
|
@ -576,7 +588,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
if (reportPath.startsWith("attachment:") && attachment != null) {
|
if (reportPath.startsWith("attachment:") && attachment != null) {
|
||||||
resFile = getAttachmentResourceFile(jasperName, currLang);
|
resFile = getAttachmentResourceFile(jasperName, currLang);
|
||||||
} else if (reportPath.startsWith("resource:")) {
|
} else if (reportPath.startsWith("resource:")) {
|
||||||
resFile = getResourcesForResourceFile(jasperName, currLang);
|
resFile = getResourcesForResourceFile(jasperName, currLang);
|
||||||
} else {
|
} else {
|
||||||
resFile = new File(jasperName+"_"+currLang.getLocale().getLanguage()+".properties");
|
resFile = new File(jasperName+"_"+currLang.getLocale().getLanguage()+".properties");
|
||||||
if (!resFile.exists()) {
|
if (!resFile.exists()) {
|
||||||
|
@ -826,17 +838,15 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
MAttachmentEntry[] entries = attachment.getEntries();
|
MAttachmentEntry[] entries = attachment.getEntries();
|
||||||
for(int i = 0; i < entries.length; i++) {
|
for(int i = 0; i < entries.length; i++) {
|
||||||
// @Trifon
|
// @Trifon
|
||||||
if (!entries[i].getName().equals(name)
|
if (!entries[i].getName().equals(name))
|
||||||
&& (entries[i].getName().toLowerCase().endsWith(".jrxml")
|
|
||||||
|| entries[i].getName().toLowerCase().endsWith(".jasper")
|
|
||||||
|| entries[i].getName().toLowerCase().endsWith(".jpg")
|
|
||||||
|| entries[i].getName().toLowerCase().endsWith(".png")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
File reportFile = getAttachmentEntryFile(entries[i]);
|
File reportFile = getAttachmentEntryFile(entries[i]);
|
||||||
if (reportFile != null)
|
if (reportFile != null) {
|
||||||
subreports.add(reportFile);
|
if (entries[i].getName().toLowerCase().endsWith(".jrxml")
|
||||||
|
|| entries[i].getName().toLowerCase().endsWith(".jasper")) {
|
||||||
|
subreports.add(reportFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File[] subreportsTemp = new File[0];
|
File[] subreportsTemp = new File[0];
|
||||||
|
|
|
@ -359,7 +359,13 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
|
||||||
}
|
}
|
||||||
|
|
||||||
Env.setContext(ctx, "#UIClient", "zk");
|
Env.setContext(ctx, "#UIClient", "zk");
|
||||||
|
StringBuilder localHttpAddr = new StringBuilder(Executions.getCurrent().getScheme());
|
||||||
|
localHttpAddr.append("://").append(Executions.getCurrent().getLocalAddr());
|
||||||
|
int port = Executions.getCurrent().getLocalPort();
|
||||||
|
if (port > 0 && port != 80) {
|
||||||
|
localHttpAddr.append(":").append(port);
|
||||||
|
}
|
||||||
|
Env.setContext(ctx, "#LocalHttpAddr", localHttpAddr.toString());
|
||||||
Clients.response(new AuScript("zAu.cmd0.clearBusy()"));
|
Clients.response(new AuScript("zAu.cmd0.clearBusy()"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue