Thoughts Electrique

Posts Tagged ‘Development’

Overview of OpenCms Resourcetype IDs

Saturday, February 13th, 2010

I constantly forget the resource type IDs of the OpenCms resource types and then have to dig into the configuration to find them. So here is a list of all resource type IDs of the OpenCms core. Maybe it is useful to someone else.

(more…)

JSP to download OpenCms resources as a ZIP

Thursday, June 25th, 2009

What often bugged me is that I can upload a set of files into OpenCms as a ZIP file but can not download a tree of files as such (without the use of the database export feature). I had hacked together this little JSP some time ago. It allows you to dynamically download a set of OpenCms resources as a ZIP file.

The JSP has no interface since I mainly use it for development. Simply create a JSP somewhere in the OpenCms VFS and then open the file via the browser. E.g.:

“http://workplace.com/system/createzip?source=/system/modules/foo&filename=foo-module.zip

The source parameter specifies which directory to zip up and the filename parameter which filename to use for the generated file. You can only zip up resources with a total size of 10 megabytes. This is mainly to prevent OutOfMemory errors to happen. You can easily increase the size by altering the variable maxSourceSize to any value you need.

If you find any bugs or want to give feedback simply leave a comment or send me an email.

(more…)

OpenCms and Google App Engine

Wednesday, June 24th, 2009

Especially with the new JPA driver for OpenCms by Georgi Naplatanov the question of running OpenCms on Google App Engine came up quite often at the OpenCms Days 2009. I had the same Idea when I first heard of the Java support for App Engine and did some quick research on how to do this. The research showed that running OpenCms on Google App Engine would require a huge rewrite of some OpenCms core functionalities.

(more…)

Restrict visibility of OpenCms templates to certain folders

Wednesday, June 3rd, 2009

Since I’m currently working on an OpenCms mutli site solution I was looking for a possibility to restrict the available templates of a site. I know this can be done via permissions but the manual implementation of this is rather painful. I’m currently in the process of extending the OpenCms security manager to take care of this but while doing this I found an (to me) unknown feature.

By usage of the property folders.available (you might have to define it first) on a template you can specify a list of comma seperated folders in which the template is available (in the dropdown).

Unfortunately this property works only on file level and can not be inherited via the folder hierarchy. Also it does not provide a secure solution since the template can always be set via the advanced property dialog.

But you never know when a feature could come in handy.

Using jQuery UI themes for your own applications

Monday, February 23rd, 2009

It’s often the case that you need icons and graphics for your own applications, but there is no real style guide available and the customer just wants something decent and coherent. I recently started using the jQuery UI wizard to create the look and feel for my entire application. So far I am very pleased with the results.

You can even create the CSS and images using a wizard: http://jqueryui.com/themeroller

The resulting themes are dual licensed under the GPL and MIT license.

A case against the almighty project document

Saturday, December 20th, 2008

To create good documentation is an art for itself and most often underestimated by us fellow software developers, architects and software project management folks. I won’t go into the detail of what makes a good documentation (in my point of view) in this blog post too deeply (maybe in the future, if you are interested?). Instead I want to point out a negative point which I run into quite frequently: The almighty project document.

(more…)

Manipulating OpenCms XMLContent programatically (some examples)

Friday, December 12th, 2008

Because someone asked on the mailing list and I keep forgetting the respective API calls to manipulate an OpenCms XMLContent programatically.

This is just a raw code dump not a step by step tutorial.

You can also download a ZIP file for importing it into OpenCms. But you have to adjust the paths manually.

(more…)

Use the power of JSP tag files in OpenCms

Friday, December 12th, 2008

Since version 7 OpenCms is a Servlet 2.4 and JSP 2.0 conforming application. In addition to the improved expression language (EL) JSP 2.0 also brings in the possibility of developing custom tags(actions) using JSP rather than writing Java code. This allows for some pretty neat things and enables you to go one step further towards cleaner view code. I’ve used this in one of my last projects extensively to refactor common code like pagers and link generation. For example:

<cms:include file="/system/modules/com.example.ocms.commons/elements/pager">
  <cms:param name="currentPage">
    <c:out value="${model.currentPage}"/>
  </cms:param>
  <cms:param name="pageCount">
    <c:out value="${model.pageCount}"/>
  </cms:param>
</cms:include>

Became:

<wt:pager model="${model}"/>

Not does it only look cleaner and is much more focused, it also decouples your view more from the underlying CMS solution. Of course you could also develop a custom tag library using Java (which I have done a few times) but using a JSP the advantage that code can be changed on the fly and even from a web designer. You can always refactor your JSP taglib into a Java one if you need to do it. There are some limitations of JSP tag files (like you can’t use scriptlets in the body) but they are easy to get around.

But as always: This is no silver bullet. There are problems with tag files which may not be obvious at the first glance.

(more…)

Enterprise grade software is an euphemism

Thursday, December 4th, 2008

I recently had to restart a Java webapplication because somehow the JDBC connection to the database server was hanging completely. This reminded me of a sentence a friend of mine told me during the OpenCms Days 2008.

“Enterprise software just means that it’s targeted at customers who can afford the guy who restarts the application server every few hours.”

I had to laugh because while the quote is clearly cynical it has a true core. Especially if you compare languages like Java and PHP it’s true that PHP doesn’t have these kind problems. This is mostly because of the throw-away-the-state nature of PHP. After every served request PHP forgets what it’s done before and has to completely rebuild the working environment at the next request. Java in contrast is able to remember things between requests. Which makes it more powerful but also harder to maintain (more state, more problems). I’m really not sure if I’m buying into this enterprise-thing anymore. Especially if you need scalability you definitely want to keep application state at a minimum and without state you don’t really need those big interconnected clusters of application servers any more.

Here is a nice talk about scalability and serious (speak enterprise) languages I found recently. It’s from Cal Henderson a software development guy at Flickr. It’s really worth watching. Even if you’re not into Python and Django.

(Watch it at: http://www.youtube.com/watch?v=i6Fr65PFqfk&feature=PlayList&p=D415FAF806EC47A1&index=10)

JavaScript void links in OpenCms 6.2.3 WYSIWYG

Friday, November 28th, 2008

Just a quick note: There was a long standing problem regarding the FCKEditor (HTML editor) in OpenCms 6.2.X using Firefox 3. Adding links always produced an URL like javascript:void(0)/*1241321*/. Since most customers are already on OpenCms 7 this is not such a big problem but recently I had to look for a fix. It turned out the bug was quite popular and there is quite an easy workaround.

Open the file /system/workplace/resources/editors/fckeditor/editor/js/fckeditorcode_gecko_2.js in OpenCms and replace the text:

FCK.ExecuteNamedCommand('CreateLink',B);var C=document.evaluate

with:

FCK.ExecuteNamedCommand('CreateLink',B);var C=this.EditorDocument.evaluate

Publish the file and this should be it. Don’t forget to empty your browser cache afterwards (don’t just press CTRL+F5) otherwise you will still get the old file.

Of course this is not a real fix, but if you have to get rid of the problem fast. This can help.

Update: In OpenCms 6.2.3 the file is called fckeditorcode_gecko.js not fckeditorcode_gecko_2.js.