From: <jbo...@li...> - 2006-03-19 23:48:55
|
Author: mnasato Date: 2006-03-19 18:48:49 -0500 (Sun, 19 Mar 2006) New Revision: 3044 Added: trunk/labs/davcache/cms.jsp Log: sample cms in just one jsp [#3] Added: trunk/labs/davcache/cms.jsp =================================================================== --- trunk/labs/davcache/cms.jsp 2006-03-19 23:39:03 UTC (rev 3043) +++ trunk/labs/davcache/cms.jsp 2006-03-19 23:48:49 UTC (rev 3044) @@ -0,0 +1,88 @@ +<%-- +// Copyright (C) 2005 Mirko Nasato <mi...@ar...> +// +// Distributable under the terms of the LGPL license. +// See http://www.gnu.org/copyleft/lesser.html +--%> +<%@ page import="java.util.*" %> +<%@ page import="javax.naming.*" %> +<%@ page import="net.sf.davcache.*" %> +<% + +TreeCacheStoreMBean store = (TreeCacheStoreMBean) application.getAttribute(TreeCacheStore.class.getName()); +if (store == null) +{ + Context context = new InitialContext(); + store = (TreeCacheStoreMBean) context.lookup("davcache/TreeCacheStore"); +} +if (store == null) +{ + throw new RuntimeException("TreeCacheStore not found in application scope or JNDI"); +} + +String currentPageTitle = request.getParameter("page"); +if (currentPageTitle == null) + currentPageTitle = "Home"; + +String currentPageContent = store.getFileContentAsString(currentPageTitle + ".html"); + +List fileNames = new ArrayList(store.getFileNames("/")); +Collections.sort(fileNames); + +%> +<html> + <head> + <title>DavCache CMS Sample</title> + <style type="text/css"> +body { + font-family: sans-serif; + font-size: 10pt; +} + +a { + color: #990000; + text-decoration: none; +} + +div#menuPane { + position: absolute; + top: 10px; + left: 10px; + width: 120px; + min-height: 400px; + border: solid grey 1px; + padding: 10px; +} + +div#mainPane { + margin-left: 160px; +} + + </style> + </head> + + <body> + + <div id="menuPane"> + <% for (Iterator it = fileNames.iterator(); it.hasNext();) { %> + <% String fileName = (String) it.next(); %> + <% if (fileName.endsWith(".html")) { %> + <% String pageTitle = fileName.substring(0, fileName.length() - ".html".length()); %> + <a href="?page=<%= pageTitle %>"><%= pageTitle %></a><br> + <% }//if %> + <% }//for %> + </div> + + <div id="mainPane"> + + <h1>DavCache Sample CMS</h1> + + <h2><%= currentPageTitle %></h2> + + <%= currentPageContent %> + + </div> + + </body> + +</html> |