|
How Corinis Works - An Overview
|
How Corinis Works - An Overview The Call Hierarchy ![]() 1. The Request When you open a webpage with your browser, you make a request to the server providing the webpage. This request is made up of the URL (http://www.corinis.com/index.jsp), get parameters (?Document_id=123), post parameters (same as get, only you cannot see them in the url) and/or cookies (also mostly invisible to the user). The corinis functions use this information to find out what document the user wants to view, or what message he wants to enter in a forum. This is all done automatically by the core module (see 5.) So the entry point to any html/jsp/php/... page is always the request. We will next see what happens behind the scenes to get a better understanding how Corinis works. 2. The JSP Corins is written in Java. In order to use the Corinis functions you need to call them using Java. Some CMS already provide the "calling" - you put a special php/cgi/... in your webfolder and it does everything for you. Corinis does not quite work like this - this is so you can have full control over whats going on (i.e. where you want your navigation/content/forum/voting on the site). If you look through the tutorials and howtos you will see that getting "anything" to be displayed is quite easy (or you just download one of the premade templates). The JSP (or Java Server Pages) are text files containing static Content (plain HTML/CSS/JavaScript) but can also call java functions. An easy JSP with HTML and Java would be: <html><body> Everything between <% and %> is java code, the rest normal html. Corinis functions are called just like that (Altough you have two choices: use real java or use the provided jsp taglib - see more about this in the howtos). Using this technique you can easily combine static html (for the stuff that never changes) and dynamic java functions (for the content/navigation/...). Now what is going on if we call a Corinis function like cms.getDocument() (or <corinis:cms/>) ? 3./4. The function call The above question was actually the only exception from the rule (because it does not need an xsl), so let me exaplain a standard function call (like core.parseDom(forum.getEntry(), "show.xsl") or <corinis:module name="Forum" function="getEntry" xsl="show.xsl"/>). As you can see a standard function call consists of the module, the function and an xsl.
Wherever you put this in the jsp page, it will be replaced by whatever the function is returning and the xsl used (the provided show.xsl is like a debug xsl that shows the dom tree in its original layout). Now we know that:
5./6. Core and How Functions work When you call a Corinis function, you need to have the Core module initialized. If you use taglibs, this is done for you, if not, you must do this on your own (see the howto). The Core module provides following:
Each module depends on Core to be initialized in order to work correctly. This is how a function knows i.e. which Forum/Cms Document it should display or which data it should put in the database when a new Posting is being created. The module functions encapsulate the whole functionality and use the data from the request (through the Core module) to do what they are meant for. When done they always return a XML tree (except Cms.getDocument - which already returns the final cms docment). The XML tree includes information like if the function succeeded and/or the data to display (like all entries in the forum or the site structure). The whole interaction is done through the request parameters. 7. The XSL If you dont know what XSL is, please see the w3c homepage (www.w3.org) and visit the XSL/XSLT secions (or google). Corinis uses XSL to transform the XML data into "readable" html (and/or javascript) to be put back to the client. The xsl is being defined in the jsp and passed to the function.
Why so complicated? It might seem pretty complicated having so many steps to produce a webpage, but once you get the hang of this, it becomes real easy. The reason for this is because implementing this way allows the most flexible way of creating a webpage with the least "hacking" time. You do not have to dig through lines of code to find exactly that table cell you want to change, since you write it from scratch - without any "real" coding (since it is provided by the functions you call). This allows you to create virtually any design (from 1/2/3 column div or table based to flash-xml) and full control over where page elements are positioned (since you can call any functions anywhere on your page you can have one page conatining a forum, a voting, a cms and a webshop or split it into as many pages as you want). The only things you need to know is what request parameter what function uses and what xml tree it returns (you can find information about this on the dev pages or the javadocs). If you have any questions about this article please use the forum! |