<?xml version="1.0" encoding="iso-8859-1"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<page
    xmlns:cinclude="http://apache.org/cocoon/include/1.0"
>
    <content>
		<p>
            In this example, java classes are used to calculate the area and perimeter of shapes.
            Various Java classes are instantiated and used from Flow.
        </p>
	<p>
            Start the example <a href="../java-shapes/startShape">here</a>.
        </p>
        <h2>The sitemap</h2>
        <p>
            There's nothing new in the sitemap, our use of
            variables allows the exact same sitemap to be reused for
            both our Flow examples.
        </p>
        <p>
            The only specific thing is the importing of the java-shapes.js
            flowscript, but this was already present for the previous
            example:
            <cinclude:include element="xml-code" src="cocoon:/xml-element/flow/sitemap.xmap/flow"/>
        </p>

        <h2>Java code</h2>
        <p>
            The java code (interface Shape, classes Rectangular, Square, Circle) is fairly trivial,
            and the computations could easily be done in javascript for such a simple case.
        </p>
        <p>
            However, our goal is to show interactions between Flow and java classes, so you shouldn't pay
            too much attention to the java code, except to note that it has no knowledge of Avalon - our java
            objects are just POJOs: Plain Old Java Objects.
        </p>

        <h2>Flowscript code</h2>
        <p>
            Here's the Flowscript which has three steps.
            <ol>
            <li>Get the selected shape from user and prepare the next page.</li>
            <li>Get shape's informations (width, height or radius) and instantiate the correct java class for the selected shape.</li>
            <li>Use java class to calculate area and perimeter and display the results</li>
            </ol>
            <cinclude:include element="flowscript-code" src="cocoon:/text-file/flow/java-shapes/java-shapes.js"/>
        </p>

        <h2>JXTemplate view</h2>
        <p>
		Shape selection
        </p>
        <cinclude:include element="xml-code" src="cocoon:/xml-element/flow/java-shapes/select.xml/page"/>
        <p>
            Here the user can select a shape.
        </p>
    </content>
</page>
