fredag 22 januari 2010

Server Side Code

First try with a custom plankton app has succeeded. How to extend plankton and make your own server logic:

Start your java project. Include the plankton.jar library. In your app, import com.plankton.*. Create a new WebServer object. That's basically it. But that doesn't do anything more than running the plankton webserver on it's own.

To insert your own server logic - create a new class that extends com.plankton.WebPage, let's call it myapp.TestWebPage. Do something in the class, let's just write something to the page in the constructor of the class:

write("hello world");

Then, last step to attach it to a plk-file. Add the class reference to the initial <plk> node:

<plk template="template.html" class="myapp.TestWebPage">
... your design ...

Done. Run your app. Surf to your .plk page and the text "hello world" will be printed before any content in the file. My example here

http://worldofcreeps.com:443/plankton.plk

The text I wrote from my custom class is "I'm running the PlanktonTest!!!"

Inga kommentarer:

Skicka en kommentar