Here's some stuff mathiaslin has liked. To find more cool stuff, check out Explore »

mathiaslin says...

When exporting the Formgenerator data to CSV, there might be some problems with exporting numbers and trailing zeros when opening the file in Excel. I.e. if you have a column with zip codes and some values start with 0, they will get lost in Excel. Also, when exporting large numbers, Excel usually displays them withe the +E syntax.
 
To avoid it, the csv should escape such numbers with a = in front of it, i.e.the CSV should read:
,="07635",
 
We modified the class com.alkacon.opencms.formgenerator.database.export.CmsCvsExportBean.java, method escapeExcelCsv: checking if the value can be parsed as Double or Long, if so, put an = in front of the escaped value.
(The = cannot be put in front of all types of fields; if put in front of an escaped string value that contains commas, it will break the format; so we
really need to check if it's a number value).


/**
* Escapes CSV values for excel.<p>
*
* @param value the value to escape
*
* @return the escaped excel value.
*/
private String escapeExcelCsv(final String value) {
// Begin: SYSVISION modification
boolean isNumber=false;
try {Long.valueOf(value);isNumber=true;} catch (Exception e) {};
try {Double.valueOf(value);isNumber=true;} catch (Exception e) {};
// End: SYSVISION modification

String result = value;
StringBuffer buffer = new StringBuffer();
buffer.append("\"");
char[] chars = value.toCharArray();
for (int i = 0; i < chars.length; i++) {
// escape double quote escape delimiter within value:
if ('"' == chars[i]) {
buffer.append("\"");
}
buffer.append(chars[i]);
}
buffer.append("\"");
result = buffer.toString();
return (isNumber?"=":"") + result; // SYSVISION modification
}

Filed under: formgenerator, opencms, sysvision

mathiaslin says...

In recent projects we have used the Spring MVC integrated into OpenCms. This topic is not new to the OpenCms community, as it has already been covered a
little in the OpenCms wiki and also Bearingpoint provides an open source submodule in their Commons-Project at Sourceforge.
 
Nevertheless, we make our small 'getting-started' project available now - it's aimed for developers who want to integrate Spring & Hibernate into
OpenCms for the first time and would like to have a ready-to-go starting point/project setup.
The project includes Eclipse and NetBeans project files as well as the ant build file. We used it for OpenCms7.0.5 and OpenCms7.5. With these OpenCms versions, the versions of the depending lib files used by Spring and OpenCms should not
conflict. (We didn't use it with OpenCms6 yet).
 
SVN:
http://svn.sysvision.net:9027/svn/com.sysvision.opencms.spring/
User: anon, Password: anon
 
or download as zip from:
http://www.sysvision.de/en/expertise/cms/solutions/opencms_spring_integration.html
 
The project contains a Readme.pdf how to use it. We hope it's useful to someone and are open for any comments, suggestions and improvements.
 
(A note regarding Hibernate: we don't use the OpenSessionInViewPattern (OSIV), so you won't find it in the project. If you want/need it, you will
find infos about it in the opencms-wiki.org)

Filed under: java, opencms, opensource, spring, sysvision