| 5 |
ebruchez |
1 |
<!--
|
|
|
2 |
Copyright (C) 2004 Orbeon, Inc.
|
|
|
3 |
|
|
|
4 |
This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
5 |
GNU Lesser General Public License as published by the Free Software Foundation; either version
|
|
|
6 |
2.1 of the License, or (at your option) any later version.
|
|
|
7 |
|
|
|
8 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
9 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
10 |
See the GNU Lesser General Public License for more details.
|
| 3249 |
ebruchez |
11 |
|
| 5 |
ebruchez |
12 |
The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
|
|
|
13 |
-->
|
|
|
14 |
<example-descriptor>
|
| 3249 |
ebruchez |
15 |
<title>OPS Pet Store</title>
|
| 9051 |
ebruchez |
16 |
<xi:include href="example-descriptor-files.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
| 5 |
ebruchez |
17 |
<requires-setup>true</requires-setup>
|
|
|
18 |
<description>
|
| 3254 |
ebruchez |
19 |
<div xmlns="http://www.w3.org/1999/xhtml">
|
|
|
20 |
<h4>About the OPS Pet Store</h4>
|
|
|
21 |
<p>
|
|
|
22 |
The OPS Pet Store is an implementation of <a
|
|
|
23 |
href="http://java.sun.com/blueprints/code/jps131/docs/index.html">Sun's Java Pet Store
|
|
|
24 |
Demo</a> entirely built with OPS. We provide below a standalone WAR file for the OPS Pet
|
|
|
25 |
Store. This WAR file can be deployed on an application server (or servlet container).
|
|
|
26 |
Instructions on how to download and install the OPS Pet Store are provided below.
|
|
|
27 |
</p>
|
|
|
28 |
<p>
|
|
|
29 |
We explore below some of the key advantages that the architecture of the OPS Pet Store
|
|
|
30 |
provides over Sun's version.
|
|
|
31 |
</p>
|
| 5 |
ebruchez |
32 |
<p align="center">
|
| 3254 |
ebruchez |
33 |
<img print-format="png" src="doc/pages/petstore-web-home-small.png" width="200" height="175"/>
|
| 5 |
ebruchez |
34 |
</p>
|
| 3254 |
ebruchez |
35 |
<h4>Look & Feel</h4>
|
|
|
36 |
<p>
|
|
|
37 |
In addition to the Web browser look & feel provided by Sun's Pet Store, the OPS Pet
|
|
|
38 |
Store features a look & feel for PDAs. The screenshot at the top of this page shows
|
|
|
39 |
the Web look & feel; the two screenshots below have been taken while browsing the
|
|
|
40 |
OPS Pet Store on a Palm with the PDA look & feel.
|
|
|
41 |
</p>
|
|
|
42 |
<p align="center">
|
|
|
43 |
<img print-format="jpg" src="doc/pages/petstore-pda-home-small.jpg" width="130" height="182"/>
|
|
|
44 |
</p>
|
|
|
45 |
<p>
|
|
|
46 |
Using plain old JSP, the natural way to implement multiple look & feels is to copy
|
|
|
47 |
all the JSP files used for the Web look & feel in an other directory and to modify
|
|
|
48 |
each file to suit a PDA screen. With OPS, we just have to make sure that a page view
|
|
|
49 |
(the equivalent of a JSP in the OPS world) generates tags representing a structural
|
|
|
50 |
version of the page that does not include any look & feel information (for instance,
|
|
|
51 |
one would put the title of the page in a simple <code><title></code> tag, instead
|
|
|
52 |
of using HTML / CSS). This structural version is then converted appropriately for a
|
|
|
53 |
specific look & feel with a stylesheet.
|
|
|
54 |
</p>
|
|
|
55 |
<p>
|
|
|
56 |
In the OPS Pet Store source code, <code>pages/category-view.xsl</code> implements the
|
|
|
57 |
view for the page listing all the products for a category. Note that this page uses
|
|
|
58 |
structural tags like <code><title></code> and <code><box-table></code>. All
|
|
|
59 |
the views use the same set of tags. Those tags are converted to actual HTML targeted at
|
|
|
60 |
either a Web browser or a PDA in the stylesheets <code>epilogue/layout-web.xsl</code>
|
|
|
61 |
and <code>epilogue/layout-pda.xsl</code>.
|
|
|
62 |
</p>
|
|
|
63 |
<h4>Internationalization</h4>
|
|
|
64 |
<p>
|
|
|
65 |
The Pet Store is available in both English and Japanese. In Sun's version,
|
|
|
66 |
internationalization is performed by copying all the JSP files and changing the English
|
|
|
67 |
strings to Japanese. This leads to a huge duplication of code. Instead, with OPS we can
|
|
|
68 |
use in the view tags like: <code><i18n:text key="welcome"/></code>. Then those
|
|
|
69 |
tags are replaced by the actual text corresponding to "welcome" in the user's locale in
|
|
|
70 |
a single stylesheet.
|
| 5 |
ebruchez |
71 |
|
| 3254 |
ebruchez |
72 |
<p align="center">
|
|
|
73 |
<img print-format="png" src="doc/pages/petstore-jp-small.png" width="200" height="103" border="1"/>
|
|
|
74 |
</p>
|
| 5 |
ebruchez |
75 |
|
| 3254 |
ebruchez |
76 |
The stylesheet replacing the <code><i18n:text></code> with actual localized text
|
|
|
77 |
is <code>epilogue/i18n.xsl</code>. The resources for the English and Japanese languages
|
|
|
78 |
are stored in <code>epilogue/i18n-en_US.xml</code> and
|
|
|
79 |
<code>epilogue/i18n-ja_JP.xml</code>.
|
|
|
80 |
</p>
|
|
|
81 |
<h4>Backend</h4>
|
|
|
82 |
<p>
|
|
|
83 |
The OPS Pet Store can use two different data stores: either a SQL database or an XML
|
|
|
84 |
file. The type of store to be used is specified in <code>database/type.xml</code> and
|
|
|
85 |
can be changed dynamically. By default, the content of this file is
|
|
|
86 |
<code><type>db</type></code> and the database is used. This can be changed
|
|
|
87 |
to <code><type>file</type></code>, in which case the content of the file
|
|
|
88 |
<code>database/database.xml</code> will be used instead of the database.
|
|
|
89 |
</p>
|
| 5 |
ebruchez |
90 |
|
| 3254 |
ebruchez |
91 |
<p>
|
|
|
92 |
The backend of the Pet Store essentially needs to query the database, for instance to
|
|
|
93 |
get all the products in a category or the details about an item. See for instance
|
|
|
94 |
<code>pages/category-model.xpl</code> which uses the <a href="doc/processors-sql">SQL
|
|
|
95 |
Processor</a> to generate XML from the result of a SQL query.
|
|
|
96 |
</p>
|
|
|
97 |
|
|
|
98 |
<p>
|
|
|
99 |
You can read the OPS PetStore <a href="/petstore-sources">source files</a>.
|
|
|
100 |
</p>
|
|
|
101 |
</div>
|
| 5 |
ebruchez |
102 |
</description>
|
|
|
103 |
</example-descriptor>
|