Search:

Apache » Lenya
project logo
  • Project
  • Developer
  • Community
  • Version 2.2
  • Version 2.0
  • Version 1.2
  • Version 2.0
    • FAQs
    • Installation
      • Download
      • Subversion Access
      • Install Instructions
    • Tutorials
      • Create a Publication
      • Create a Resource Type
        • Declaration
        • Creation
        • Presentation
        • Editing (One-Form)
        • Editing (BXE)
      • Implement a Usecase
        • Prerequisites
        • The Usecase
      • Setting up Eclipse
      • Proxying
        • Proxying
        • mod_proxy
        • mod_proxy_ajp
      • Best Practises
      • Production Checklist
      • Writing Tests
    • Concepts
      • Publication
      • Working with Documents
      • Authoring and Live mode
      • WYSIWYG
    • Technical Reference
      • Overview of Lenya Sitemaps
      • Repository
      • Access Control Specification
      • Usecase Framework
        • Overview
        • AbstractUsecase
      • Publications
        • Configuration
        • Publication Templating
      • Resource Types
      • Modules
      • Meta data
      • Protocols
        • lenya Protocol
        • lenya-document Protocol
        • site Protocol
        • lenyadoc Protocol
        • fallback Protocol
      • URLs and Links
        • URL Mapping
        • Link Management
    • Core API
    • Core Modules
      • ac
        • Overview
        • API
      • acusecases
        • Overview
        • API
      • administration
        • Overview
        • API
      • cache
        • Overview
        • API
      • janitor
        • Overview
        • API
      • ldap
        • Overview
        • API
      • linking
        • Overview
        • API
      • observation
        • Overview
        • API
      • properties
        • Overview
        • API
      • sitemanagement
        • Overview
        • API
      • templating
        • Overview
        • API
      • usecase
        • Overview
        • API
      • workflow
        • Overview
        • API
    • Standard Modules
      • blog
        • Overview
        • API
      • bxe
        • Overview
      • cforms
        • Overview
        • API
      • collection
        • Overview
        • API
      • contactform
        • Overview
        • API
      • development
        • Overview
        • API
      • editors
        • Overview
        • API
      • export
        • Overview
        • API
      • fckeditor
        • Overview
        • API
      • kupu
        • Overview
        • API
      • languageselector
        • Overview
      • lenyadoc
        • Overview
        • API
      • linkcheck
        • Overview
        • API
      • links
        • Overview
        • API
      • lucene
        • Overview
        • API
      • migration
        • Overview
        • API
      • navigation
      • neutron
        • Overview
      • news
        • Overview
        • API
      • notification
        • Overview
        • API
      • opendocument
        • Overview
        • API
      • prettyprinting
        • Overview
      • profiling
        • Overview
      • resource
        • Overview
        • API
      • simplesite
        • Overview
        • API
      • sitetree
        • Overview
        • API
      • sourcerepository
        • Overview
        • API
      • svg
        • Rounded Corners
        • Resizing Images
        • API
      • tinymce
        • Overview
        • API
      • usecasedocument
        • Overview
        • API
      • webdav
        • Getting started
        • Monitoring
        • WebDAV Servers
        • API
      • xhtml
        • Overview
        • API
      • xopus
        • Overview

Current Event

Meeting Bad Säckingen 2009

Built with Apache Lenya

Creating a Resource Type, Part 2: Creating Documents

Table of Contents
  • Adding the Menu
  • Providing the Sample

Adding the Menu

Now we'll add the menu for our module. The first item we need will trigger the usecase to create new person documents. The menu XML is located at $MODULE_HOME/config/menu.xml. Note that we're using the i18n message for the resource type label which we added in the previous section:

<?xml version="1.0"?>
<menu xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
  xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
  xmlns="http://apache.org/cocoon/lenya/menubar/1.0">
  <menus>
    <menu i18n:attr="name" name="File">
      <block areas="site authoring">
        <item uc:usecase="sitemanagement.create" href="?doctype=person">
          <i18n:translate>
            <i18n:text>New ... Document</i18n:text>
            <i18n:param><i18n:text>resourceType-person</i18n:text></i18n:param>
          </i18n:translate>
        </item>
      </block>
    </menu>
  </menus>
</menu>

The menu contains an item which triggers the sitemanagement.create usecase with the doctype=person parameter.

Providing the Sample

To create a document, the sitemanagement.create usecase needs a sample XML. We've already specified the sample location in our resource type declaration (see above). Now we have to add the corresponding FoaF person file ($MODULE_HOME/samples/foaf.xml):

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <foaf:Person rdf:ID="me">
    <foaf:title>Mr</foaf:title>
    <foaf:givenname>Homer</foaf:givenname>
    <foaf:family_name>Simpson</foaf:family_name>
    <foaf:mbox rdf:resource="mailto:chunkylover53@aol.com"/>
    <foaf:phone rdf:resource="tel:555-555-555"/>
    <foaf:workplaceHomepage rdf:resource="http://powerplantspringfield.com"/>
  </foaf:Person>
</rdf:RDF>

In the next section we'll render our newly created document as an XHTML web page.

Copyright © 1999-2009 The Apache Software Foundation. All rights reserved.