You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by re...@apache.org on 2008/08/01 17:15:29 UTC
svn commit: r681719 [7/10] - in /incubator/empire-db/site: ./ community/
css/ documentation/ downloads/ empiredb/ images/ images/diagrams/
images/logos/ images/mail/ images/menu/ javadocs/ js/ struts2ext/ support/
Propchange: incubator/empire-db/site/js/prototype.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/site/news.htm
URL: http://svn.apache.org/viewvc/incubator/empire-db/site/news.htm?rev=681719&view=auto
==============================================================================
--- incubator/empire-db/site/news.htm (added)
+++ incubator/empire-db/site/news.htm Fri Aug 1 08:15:26 2008
@@ -0,0 +1,283 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
+<!-- #BeginTemplate "main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata, persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+ <title>Empire-db relational data persistence - News</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="./js/prototype.js"></script>
+ <script type="text/javascript" src="./js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="empire-db.ico" />
+ <link rel="stylesheet" href="css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+<style type="text/css">
+
+div#top {
+ height: 20px;
+}
+
+table#comparison {
+ display: block;
+ width: 580px;
+}
+
+table#comparison th {
+ background-color: #F0F0F0;
+}
+
+table#comparison tbody th {
+ width: 150px;
+ text-align: left;
+}
+
+table#comparison td {
+ text-align: center;
+}
+
+table#comparison td.classical {
+ background-color: #ffffaa; /* #ffff99; */
+}
+
+table#comparison td.empiredb {
+ background-color: #ffd5aa; /* #ffcc99; /*
+}
+
+</style>
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="images/logos/empire-db-logo.gif" alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a target="_blank" href="http://incubator.apache.org/">
+ <img src="images/logos/apache-incubator-logo.png" alt="Apache Incubator" /></a>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a href="index.html">Home</a></li>
+ <li id="menu_news"><a href="news.htm">News</a></li>
+ <li id="menu_empiredb"><a href="empiredb/empiredb.htm">Empire-db</a>
+ <ul class="subMenu">
+ <li id="menu_empiredb_extending_pattern"><a href="empiredb/pattern.htm">The Empire DAO-<br />pattern</a></li>
+ <li id="menu_empiredb_handling_metadata"><a href="empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li id="menu_empiredb_wrong"><a href="empiredb/hibernate.htm">What's wrong with Hibernate and JPA</a></li>
+ <li id="menu_empiredb_stringfree"><a href="empiredb/stringfree.htm">The principle of<br/>string-free coding</a></li>
+ <li id="menu_empiredb_faq"><a href="empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a href="struts2ext/struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li id="menu_struts2ext_forms_controls"><a href="struts2ext/forms_controls.htm">Forms and controls</a></li>
+ <li id="menu_struts2ext_rendering_parsing"><a href="struts2ext/rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag reference</a></li>-->
+ <li id="menu_struts2ext_input_controls"><a href="struts2ext/input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads"><a href="downloads/downloads.htm">Downloads</a>
+ <ul class="subMenu">
+ <li id="menu_downloads_license"><a href="downloads/license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation"><a href="documentation/documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li id="menu_documentation_class_overview"><a href="documentation/class_overview.htm">Empire-db class<br />overview</a></li>
+ <li id="menu_documentation_tutorials"><a href="documentation/tutorial.htm">Tutorial</a></li>
+ <li id="menu_documentation_getting_started"><a href="documentation/getting_started.htm">Getting started</a></li>
+ <li id="menu_documentation_api"><a href="documentation/api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community"><a href="community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li id="menu_community_mailing_lists"><a href="community/mailing_lists.htm">Mailing lists</a></li>
+ <!--<li id="menu_community_source_code"><a href="community/source_code.htm">Source code</a></li>-->
+ <li id="menu_community_jira"><a href="community/jira.htm">Ticketing system</a></li>
+ <!--<li id="menu_community_road_map"><a href="community/road_map.htm">Road map</a></li>-->
+ <li id="menu_community_contributors"><a href="community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a href="disclaimer.htm">Disclaimer</a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_news' );
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <!-- #BeginEditable "pathway" -->
+ News
+ <!-- #EndEditable -->
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <h1>Latest News</h1>
+ <div class="news">
+ <div class="createdate">Tuesday, 8 July 2008</div>
+ <p><a href="http://wiki.apache.org/incubator/Empire-dbProposal">The Empire-db proposal</a> has been accepted
+ by the Apache Incubator PMC for <a href="http://incubator.apache.org/">incubation</a> at the
+ <a href="http://www.apache.org/">Apache Software Foundation!</a><br />
+ </div>
+
+ <div class="news">
+ <div class="createdate">Sunday, 6 July 2008</div>
+ <p>Empire-db 2.0.2 released, featuring new Bean metadata support.<br />
+ Click <a href="downloads/downloads.htm">here</a> to download.
+ </div>
+
+ <div class="news">
+ <div class="createdate">Tuesday, 17 June 2008</div>
+ <p>Empire-db passed in a proposal to the <a href="http://www.apache.org/">Apache Software Foundation</a> to
+ become an <a href="http://incubator.apache.org/">Apache Incubator project</a>.<br/>
+ Click <a href="http://wiki.apache.org/incubator/Empire-dbProposal">here</a> to read the proposal.
+ </div>
+
+ <div class="news">
+ <div class="createdate">Sunday, 6 April 2008</div>
+ <p>Empire-db 2.0.1 released, featuring new MySQL database support.<br />
+ Click <a href="downloads/downloads.htm">here</a> to download.
+ </div>
+
+ <div class="news">
+ <div class="createdate">Sunday, 13 January 2008</div>
+ <p>Empire-db website goes online.</p>
+ </div>
+
+ <div class="news">
+ <div class="createdate">Friday, 11 January 2008</div>
+ <p>Empire-db 2.0.0 has been released, see details
+ and download at <a href="downloads/downloads.htm">Downloads</a>
+ </p>
+ </div>
+
+ <div class="news">
+ <div class="createdate">Thursday, 10 January 2008</div>
+ <p>Empire-db registered with <a href="http://sourceforge.net/projects/empire-db">SourceForge.net</a></p>
+ </div>
+
+ <div id="current_versions">
+ <h2>Current Versions</h2>
+ <p>
+ <a href="downloads/downloads.htm">Empire-db-2.0.2</a> for Java 5, Release date: 06.07.2008
+ </p>
+ <p>
+ <a href="downloads/downloads.htm">Empire-Struts2-Ext-1.0.2</a> Release date: 06.07.2008
+
+ </p>
+ <p>
+ <a href="downloads/downloads.htm">Empire-db-1.4.2</a> for Java 1.4, Release date: 11.01.2008
+ </p>
+ </div>
+
+
+ <h1>News...</h1>
+ <table id="find_out_more">
+ <tr><th class="odd"><a href="empiredb/empiredb.htm">Empire-db at a glance</a></th><td class="odd">Empire-db facts and features.</td></tr>
+ <tr><th><a href="empiredb/hibernate.htm">Empire-db vs. Hibernate</a></th><td>Learn about the different concepts of relational data persistence.</td></tr>
+ <tr><th class="odd"><a href="struts2ext/struts2ext.htm">Empire-db and Struts 2</a></th><td class="odd">Find out how Web applications can benefit from Empire-db's dynamic beans and metadata.</td></tr>
+ <tr><th><a href="downloads/downloads.htm">Get Empire-db</a></th><td>Download Empire-db and related packages as well as sample projects.</td></tr>
+ </table>
+
+ <!--<img style="display: block; margin: auto; width: 600px; height: 272px;" src="images/diagrams/dao_pattern.png" alt="" />-->
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img src="images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page <img src="images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" || prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" || next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" && prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" && next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <small>Copyright © 2008, The Apache Software Foundation</small> <!--<p style="padding-right: 25px; text-align: right;">
+ <a href="http://validator.w3.org/check?uri=referer">
+ <img
+ src="images/valid-xhtml10.png"
+ alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
+ </p>--></div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: incubator/empire-db/site/news.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/site/struts2ext/Kopie von forms_controls.htm
URL: http://svn.apache.org/viewvc/incubator/empire-db/site/struts2ext/Kopie%20von%20forms_controls.htm?rev=681719&view=auto
==============================================================================
--- incubator/empire-db/site/struts2ext/Kopie von forms_controls.htm (added)
+++ incubator/empire-db/site/struts2ext/Kopie von forms_controls.htm Fri Aug 1 08:15:26 2008
@@ -0,0 +1,372 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
+<!-- #BeginTemplate "../main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata, persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+<title>Empire-db and Struts2 - Forms and controls</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" src="../js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="../empire-db.ico" />
+ <link rel="stylesheet" href="../css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="../images/logos/empire-db-logo.gif" alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a target="_blank" href="http://incubator.apache.org/">
+ <img src="../images/logos/apache-incubator-logo.png" alt="Apache Incubator" /></a>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a href="../index.html">Home</a></li>
+ <li id="menu_news"><a href="../news.htm">News</a></li>
+ <li id="menu_empiredb">
+ <a href="../empiredb/empiredb.htm">Empire-db</a>
+ <ul class="subMenu">
+ <li id="menu_empiredb_extending_pattern">
+ <a href="../empiredb/pattern.htm">The Empire DAO-<br />pattern</a></li>
+ <li id="menu_empiredb_handling_metadata">
+ <a href="../empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li id="menu_empiredb_wrong">
+ <a href="../empiredb/hibernate.htm">What's wrong with Hibernate and JPA</a></li>
+ <li id="menu_empiredb_stringfree">
+ <a href="../empiredb/stringfree.htm">The principle of<br/>string-free coding</a></li>
+ <li id="menu_empiredb_faq">
+ <a href="../empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a href="struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li id="menu_struts2ext_forms_controls">
+ <a href="forms_controls.htm">Forms and controls</a></li>
+ <li id="menu_struts2ext_rendering_parsing">
+ <a href="rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag reference</a></li>-->
+ <li id="menu_struts2ext_input_controls">
+ <a href="input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads">
+ <a href="../downloads/downloads.htm">Downloads</a>
+ <ul class="subMenu">
+ <li id="menu_downloads_license">
+ <a href="../downloads/license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation">
+ <a href="../documentation/documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li id="menu_documentation_class_overview">
+ <a href="../documentation/class_overview.htm">Empire-db class<br />overview</a></li>
+ <li id="menu_documentation_tutorials">
+ <a href="../documentation/tutorial.htm">Tutorial</a></li>
+ <li id="menu_documentation_getting_started">
+ <a href="../documentation/getting_started.htm">Getting started</a></li>
+ <li id="menu_documentation_api">
+ <a href="../documentation/api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community">
+ <a href="../community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li id="menu_community_mailing_lists">
+ <a href="../community/mailing_lists.htm">Mailing lists</a></li>
+ <!--<li id="menu_community_source_code"><a href="community/source_code.htm">Source code</a></li>-->
+ <li id="menu_community_jira">
+ <a href="../community/jira.htm">Ticketing system</a></li>
+ <!--<li id="menu_community_road_map"><a href="community/road_map.htm">Road map</a></li>-->
+ <li id="menu_community_contributors">
+ <a href="../community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a href="../disclaimer.htm">Disclaimer</a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_struts2ext', 'menu_struts2ext_forms_controls' );
+ var next_page = "rendering_parsing.htm";
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <!-- #BeginEditable "pathway" -->
+ <a href="struts2ext.htm">Empire-db and Struts2</a> » Forms and controls
+ <!-- #EndEditable -->
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <h1>Input controls part 1 â Forms and controls</h1>
+ <p> For database driven Web applications one of the most common tasks is displaying
+ a form for adding new and modifying existing records. To demonstrate how much safer,
+ cleaner and more efficient you can work using the Empire-Struts2-Extensions we
+ compare it to standard Struts2.</p>
+ <p> Letâs first look at the attributes that are required to define a form input control:</p>
+ <ol>
+ <li>The type of input (text, selection list, checkbox)</li>
+ <li>The maximum input length for text fields</li>
+ <li>The list of possible values for selection lists</li>
+ <li>Whether or not the field is mandatory</li>
+ <li>Whether or not the field value is editable or read only</li>
+ </ol>
+ <p> While points 1 to 4 are usually defined through static attributes of a particular
+ field, the fieldâs accessibility (point 5) is more likely to depend on the context,
+ such as the recordâs state or user credentials â and thus has more complex requirements.
+ This point is further discussed in the section <a href="#access_logic">Implementing field level access logic</a>.</p>
+ <p> The definition of a full featured input control with standard Struts2 tags looks somewhat like this:</p>
+ <pre><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.lastname"</span><span style="color: #FF0000; ">
+ size</span><span style="color: #0000FF; ">="40"</span><span style="color: #FF0000; ">
+ required</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; ">
+ disabled</span><span style="color: #0000FF; ">="!hasAccess('employee.lastname')"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span></pre>
+
+ <p> With Empire-Struts2-Extensions youâd simply write:</p>
+ <pre><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.LASTNAME %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span></pre>
+
+ <p> The same applies to a field that is displayed as a selection list. With traditional Struts2 tags
+ it may look like this:</p>
+ <pre><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:select </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.gender"</span><span style="color: #FF0000; ">
+ list</span><span style="color: #0000FF; ">="genders"</span><span style="color: #FF0000; "> listKey</span><span style="color: #0000FF; ">="key"</span><span style="color: #FF0000; "> listValue</span><span style="color: #0000FF; ">="value"</span><span style="color: #FF0000; ">
+ required</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; ">
+ disabled</span><span style="color: #0000FF; ">="!hasAccess('employee.department')"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span></pre>
+
+ <p> Again with Empire-Struts2-Extensions the code is simply:</p>
+ <pre><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.DEPARTMENT_ID %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span></pre>
+
+ <p> All the information necessary to set all input control
+ attributes is provided by the meta information
+ supplied by the record and column objects. The following code shows the corresponding column
+ definition for the two fields with extended view specific metadata:</p>
+ <pre><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> Employees </span><span style="color: #0000FF; ">extends</span><span style="color: #000000; "> DBTable
+{
+ </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">final</span><span style="color: #000000; "> DBTableColumn LASTNAME;
+ </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">final</span><span style="color: #000000; "> DBTableColumn GENDER;
+
+ </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> Employees(DBDatabase db)
+ {
+ </span><span style="color: #0000FF; ">super</span><span style="color: #000000; ">(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">EMPLOYEES</span><span style="color: #000000; ">"</span><span style="color: #000000; ">, db);
+ </span><span style="color: #000000; "> </span><span style="color: #008000; ">// Add columns
+</span><span style="color: #000000; "> LASTNAME </span><span style="color: #000000; ">=</span><span style="color: #000000; "> addColumn(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">LASTNAME</span><span style="color: #000000; ">"</span><span style="color: #000000; ">, DataType.TEXT, </span><span style="color: #000000; ">40</span><span style="color: #000000; ">, </span><span style="color: #0000FF; ">true</span><span style="color: #000000; ">);
+ GENDER </span><span style="color: #000000; ">=</span><span style="color: #000000; "> addColumn(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">GENDER</span><span style="color: #000000; ">"</span><span style="color: #000000; ">, DataType.TEXT, </span><span style="color: #000000; ">1</span><span style="color: #000000; ">, </span><span style="color: #0000FF; ">false</span><span style="color: #000000; ">);
+ </span><span style="color: #000000; "> </span><span style="color: #008000; ">// Set control types
+ </span><span style="color: #000000; "> LASTNAME.setControlType(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">text</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);
+ GENDER.setControlType(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">select</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);
+ </span><span style="color: #008000; ">//</span><span style="color: #008000; "> Set gender options</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> Options genders </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Options();
+ genders.set(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">M</span><span style="color: #000000; ">"</span><span style="color: #000000; ">, </span><span style="color: #000000; ">"</span><span style="color: #000000; ">Male</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);
+ genders.set(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">F</span><span style="color: #000000; ">"</span><span style="color: #000000; ">, </span><span style="color: #000000; ">"</span><span style="color: #000000; ">Female</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);
+ GENDER.setOptions(genders);
+ }
+}</span></pre>
+
+ <p> As you can see, we have added the control type and possible gender
+ options here for our two columns. For simplicity we have put this
+ together with the database schema definition, but you may as well
+ separate it and add the data in a different class or method.</p>
+
+ <h1>Form definition â the whole story</h1>
+ <p> Summing up, with traditional Struts2 syntax the entire form to display an employee record may look like this:</p>
+ <pre><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:form </span><span style="color: #FF0000; ">action</span><span style="color: #0000FF; ">="employeeDetail!doSave"</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.employeeId"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="true"</span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.firstname"</span><span style="color: #FF0000; "> size</span><span style="color: #0000FF; ">="40"</span><span style="color: #FF0000; "> required</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.lastname"</span><span style="color: #FF0000; "> size</span><span style="color: #0000FF; ">="40"</span><span style="color: #FF0000; "> required</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:select </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.gender"</span><span style="color: #FF0000; "> list</span><span style="color: #0000FF; ">="#{'M':'Male', 'F':'Female'}"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.dateOfBirth"</span><span style="color: #FF0000; "> size</span><span style="color: #0000FF; ">="10"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">tr</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">td </span><span style="color: #FF0000; ">class</span><span style="color: #0000FF; ">="tdLabel"</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:label </span><span style="color: #FF0000; ">value</span><span style="color: #0000FF; ">="%{getText('employee.phoneNumber')}"</span><span style="color: #FF0000; "> theme</span><span style="color: #0000FF; ">="simple"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">:</span><span style="color: #0000FF; "></</span><span style="color: #800000; ">td</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">td</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.phoneNumber_cou"</span><span style="color: #FF0000; "> size</span><span style="color: #0000FF; ">="4"</span><span style="color: #FF0000; ">
+ maxlength</span><span style="color: #0000FF; ">="4"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; ">
+ theme</span><span style="color: #0000FF; ">="simple"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.phoneNumber_cit"</span><span style="color: #FF0000; "> size</span><span style="color: #0000FF; ">="8"</span><span style="color: #FF0000; ">
+ maxlength</span><span style="color: #0000FF; ">="8"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; ">
+ theme</span><span style="color: #0000FF; ">="simple"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">-
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:textfield </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.phoneNumber_ext"</span><span style="color: #FF0000; "> size</span><span style="color: #0000FF; ">="20"</span><span style="color: #FF0000; ">
+ maxlength</span><span style="color: #0000FF; ">="20"</span><span style="color: #FF0000; "> disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; ">
+ theme</span><span style="color: #0000FF; ">="simple"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color: #800000; ">td</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color: #800000; ">tr</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:select </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.department.departmentId"</span><span style="color: #FF0000; "> list</span><span style="color: #0000FF; ">="departments"</span><span style="color: #FF0000; ">
+ listKey</span><span style="color: #0000FF; ">="departmentId"</span><span style="color: #FF0000; "> listValue</span><span style="color: #0000FF; ">="name"</span><span style="color: #FF0000; "> required</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; ">
+ disabled</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">tr</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">td </span><span style="color: #FF0000; ">class</span><span style="color: #0000FF; ">="tdLabel"</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">s:label </span><span style="color: #FF0000; ">value</span><span style="color: #0000FF; ">="%{getText('employee.retired')}"</span><span style="color: #FF0000; ">
+ theme</span><span style="color: #0000FF; ">="simple"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; "> :</span><span style="color: #0000FF; "></</span><span style="color: #800000; ">td</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">td</span><span style="color: #0000FF; ">><</span><span style="color: #800000; ">s:checkbox </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="employee.retired"</span><span style="color: #FF0000; "> theme</span><span style="color: #0000FF; ">="simple"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></</span><span style="color: #800000; ">td</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color: #800000; ">tr</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+</span><span style="color: #0000FF; "></</span><span style="color: #800000; ">s:form</span><span style="color: #0000FF; ">></span></pre>
+
+ <p> Whereas for exactly the same form with Empire-Struts2-Extensions the code simply
+ looks like this:</p>
+ <pre><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:form </span><span style="color: #FF0000; ">record</span><span style="color: #0000FF; ">="<%= action.getEmployee() %>"</span><span style="color: #FF0000; "> action</span><span style="color: #0000FF; ">="!doSave"</span><span style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.EMPLOYEE_ID %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.FIRSTNAME %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.LASTNAME %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.GENDER %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.DATE_OF_BIRTH %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.PHONE_NUMBER %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.DEPARTMENT_ID %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color: #800000; ">e:control </span><span style="color: #FF0000; ">column</span><span style="color: #0000FF; ">="<%= EMPLOYEES.RETIRED %>"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><span style="color: #000000; ">
+</span><span style="color: #0000FF; "></</span><span style="color: #800000; ">e:form</span><span style="color: #0000FF; ">></span></pre>
+
+ <h1 id="access_logic">Implementing field level access logic</h1>
+ <p> By field level access logic we understand a function that
+ determines whether a particular field's value is editable by the user
+ or read only. If it's read only, the <i>disabled </i>attribute of the
+ corresponding input control needs to be set to <i>true</i>. In the above Struts2 form example we
+ have implemented this logic - the
+ fact that a field should be read only if the employee is retired - in the view.
+ This was
+ solely for convenience since actually it does not really belong there.</p>
+ <p> Consider for example what we additionally need to check user credentials, then all the logic
+ in the JSP becomes even more complex and hardly maintainable. But what other options do we have? </p>
+ <p> A more sensible approach is to call a function on our bean or action class that returns whether
+ or not the field is disabled â like we have done further above
+ by calling a function named <code>hasAccess()</code>.
+ However this function needs to know which field we want to check for accessibility and what
+ other option do we have as again providing the field property name as a string literal. And
+ what makes this even more tedious and error prone is that if we want to
+ do it properly we must
+ not forget to call this function for every single input field in our entire application.</p>
+ <p> This is a good example why separation of view and logic is hard
+ to achieve and not properly addressed by most
+ current Web application frameworks.</p>
+ <p> With Empire-Struts2-Extensions all this is so much simpler and safer. As you can easily see,
+ all you have to provide in your JSPs is a reference to the record and column
+ objects. The record reference
+ may easily be set for the entire form so for the individual controls only the column reference
+ needs to be provided. The same field access logic that has caused us so much trouble with the
+ traditional approach is now easily implemented where it belongs: in the model with the EmployeeRecord.</p>
+ <pre><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> EmployeeRecord </span><span style="color: #0000FF; ">extends</span><span style="color: #000000; "> DBRecord
+{
+ </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">final</span><span style="color: #000000; "> SampleDB.Employees T </span><span style="color: #000000; ">=</span><span style="color: #000000; ">
+ SampleDB.getInstance().T_EMPLOYEES;
+
+ @Override
+ </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">boolean</span><span style="color: #000000; "> isFieldReadOnly(DBColumn column)
+ {
+ </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">super</span><span style="color: #000000; ">.isFieldReadOnly(column))
+ </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">true</span><span style="color: #000000; ">;
+ </span><span style="color: #008000; ">//</span><span style="color: #008000; "> Check if Employee has retired</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (column</span><span style="color: #000000; ">!=</span><span style="color: #000000; ">T.C_RETIRED </span><span style="color: #000000; ">&&</span><span style="color: #000000; "> getBoolean(T.C_RETIRED))
+ </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">true</span><span style="color: #000000; ">;
+ </span><span style="color: #008000; ">//</span><span style="color: #008000; "> No, field is acessible</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">false</span><span style="color: #000000; ">;
+ }
+}</span></pre>
+
+ <p> Note that this is really all the code you need. There are
+ absolutely no changes to the JSPs necessary. And now you may easily
+ extend this code additionally checking user credentials if required.</p>
+ <p> With this approach separation of view and logic is so much cleaner and thus simpler to maintain and
+ to extend. This has all been achieved by utilizing Empire-dbâs metadata capabilities.
+ Without static and context specific metadata such a procedure
+ is hardly possible and probably the reason why you have not seen
+ anything like this with other solutions. </p>
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img src="../images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page
+ <img src="../images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" || prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" || next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" && prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" && next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <small>Copyright © 2008, The Apache Software Foundation</small> <!--<p style="padding-right: 25px; text-align: right;">
+ <a href="http://validator.w3.org/check?uri=referer">
+ <img
+ src="images/valid-xhtml10.png"
+ alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
+ </p>--></div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: incubator/empire-db/site/struts2ext/Kopie von forms_controls.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/site/struts2ext/forms_controls.htm
URL: http://svn.apache.org/viewvc/incubator/empire-db/site/struts2ext/forms_controls.htm?rev=681719&view=auto
==============================================================================
--- incubator/empire-db/site/struts2ext/forms_controls.htm (added)
+++ incubator/empire-db/site/struts2ext/forms_controls.htm Fri Aug 1 08:15:26 2008
@@ -0,0 +1,306 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
+<!-- #BeginTemplate "../main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata, persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+<title>Empire-db and Struts2 - Rendering and parsing</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" src="../js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="../empire-db.ico" />
+ <link rel="stylesheet" href="../css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="../images/logos/empire-db-logo.gif" alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a target="_blank" href="http://incubator.apache.org/">
+ <img src="../images/logos/apache-incubator-logo.png" alt="Apache Incubator" /></a>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a href="../index.html">Home</a></li>
+ <li id="menu_news"><a href="../news.htm">News</a></li>
+ <li id="menu_empiredb">
+ <a href="../empiredb/empiredb.htm">Empire-db</a>
+ <ul class="subMenu">
+ <li id="menu_empiredb_extending_pattern">
+ <a href="../empiredb/pattern.htm">The Empire DAO-<br />pattern</a></li>
+ <li id="menu_empiredb_handling_metadata">
+ <a href="../empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li id="menu_empiredb_wrong">
+ <a href="../empiredb/hibernate.htm">What's wrong with Hibernate and JPA</a></li>
+ <li id="menu_empiredb_stringfree">
+ <a href="../empiredb/stringfree.htm">The principle of<br/>string-free coding</a></li>
+ <li id="menu_empiredb_faq">
+ <a href="../empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a href="struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li id="menu_struts2ext_forms_controls">
+ <a href="forms_controls.htm">Forms and controls</a></li>
+ <li id="menu_struts2ext_rendering_parsing">
+ <a href="rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag reference</a></li>-->
+ <li id="menu_struts2ext_input_controls">
+ <a href="input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads">
+ <a href="../downloads/downloads.htm">Downloads</a>
+ <ul class="subMenu">
+ <li id="menu_downloads_license">
+ <a href="../downloads/license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation">
+ <a href="../documentation/documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li id="menu_documentation_class_overview">
+ <a href="../documentation/class_overview.htm">Empire-db class<br />overview</a></li>
+ <li id="menu_documentation_tutorials">
+ <a href="../documentation/tutorial.htm">Tutorial</a></li>
+ <li id="menu_documentation_getting_started">
+ <a href="../documentation/getting_started.htm">Getting started</a></li>
+ <li id="menu_documentation_api">
+ <a href="../documentation/api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community">
+ <a href="../community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li id="menu_community_mailing_lists">
+ <a href="../community/mailing_lists.htm">Mailing lists</a></li>
+ <!--<li id="menu_community_source_code"><a href="community/source_code.htm">Source code</a></li>-->
+ <li id="menu_community_jira">
+ <a href="../community/jira.htm">Ticketing system</a></li>
+ <!--<li id="menu_community_road_map"><a href="community/road_map.htm">Road map</a></li>-->
+ <li id="menu_community_contributors">
+ <a href="../community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a href="../disclaimer.htm">Disclaimer</a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_struts2ext', 'menu_struts2ext_forms_controls' );
+ var prev_page = "struts2ext.htm";
+ var next_page = "rendering_parsing.htm";
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <!-- #BeginEditable "pathway" -->
+ <a href="struts2ext.htm">Empire-db and Struts2</a> » Rendering and parsing
+ <!-- #EndEditable -->
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <h1>Input controls part 2 â Test</h1>
+ <p> One of the biggest problems in Web development is that usually the code responsible
+ for rendering data is separated from the code used for parsing and validating data.
+ In most cases the rendering is performed in a JSP page, either by directly embedding string
+ representation of the value in HTML or by a special JSP tag that renders the value
+ according to information provided with attributes on the tag. When the user submits the
+ form the values are usually pushed into a JavaBean or POJO by an interceptor which takes the
+ parameters from the request, looks for an appropriate setter method and then converts
+ the value to fit the setterâs value data type.</p>
+ <p> This procedure has several disadvantages that are best understood by the following example:<br />
+ Consider a phone number which is stored in the database in a single field. On the form however
+ you want to display and edit the phone number in three individual text fields: the first for the
+ country code, the second for the city code and the last for the extension code which are separated
+ from each other using a dash. The first problem with traditional Web application frameworks is,
+ that since there is no tag for such behaviour you have to write all the HTML code for those three
+ separate input tags plus the label in your JSP. Even worse however is, that when the form is
+ submitted three individual fields are supplied that you have to assemble to a single value again.
+ Now for this you have several options which are all quite complicated for such a simple task. If you
+ donât want to provide your own interceptor you will have to provide corresponding setters on your JavaBean and â if you donât want to rely on the order by which these setters are called - youâd
+ have to add additional post processing code that will put them together again. Still the assembly
+ code must rely on the rendering code which is in the JSP and thus not in the same place. As a third
+ problem youâll find the task of validation â for which you might have to write your own validation
+ class. At last, all this has to be done for every single phone number field you have in your
+ application. Imagine you have several phone number fields then handling
+ all of them becomes quite a nasty
+ problem.</p>
+ <p> With Empire-Struts2-Extensions the task of rendering and the task of parsing and validating form
+ values are now put together in one simple class: The input control. The input control is an abstract
+ base class for which you can easily provide your own implementation if necessary by only implementing
+ three simple methods: <code>renderText()</code>, <code>renderInput()</code> and <code>getFieldValue()</code>.
+ For the most common field types there are already implementations provided such as text, select, password, phone, checkbox and more.
+ The major differences to traditional processing are:</p>
+ <ol>
+ <li>The input control has access to field metadata and can thus perform rendering, parsing and
+ validation without additional redundant information provided in the view. However should you ever
+ need it, you may as well override these attributes in your JSPs.</li>
+ <li>The input control class distinguishes between read only and editable rendering and can thus also
+ be used for list views for example. Consider a field whose value you have
+ to format in a
+ particular way for display. Simply write your own input control class and assign the control
+ type to the corresponding column. Wherever a value for this field is displayed with any of the Empire tags
+ it will be formatted correctly â without any change or additional
+ attributes in the JSPs. </li>
+ <li>For processing submitted form data the input control uses a pull rather than the usual push
+ approach. This allows the input control to combine two or more fields to one value. This
+ is e.g. used for checkboxes where an additional hidden value is used to detect whether the
+ checkbox has been unchecked. Since the rendering code is in the same object both the splitting
+ and the assembly can easily be kept consistent.</li>
+ </ol>
+ <p>The following graphic shows how the InputControl is the interface
+ between the view and the model:</p>
+ <img style="display: block; margin: auto;" src="../images/diagrams/function_of_input_control.gif" alt="" />
+
+ <p>The list view JSP uses the <code><e:value></code> tag (or alternatively an <code><e:td></code>
+ tag which extends <code><e:value></code>) to render the field's value for
+ display. The form view on contrary uses the <code><e:control></code> tag to
+ render a form input control which may be used to change the value.
+ When the form is submitted, an action support class iterates through
+ all fields and gives the corresponding InputControl the opportunity
+ to pull the value(s) off the request and to perform parsing and
+ validation. If successful the field value is written back to the
+ record. For all three tasks access to data and metadata is
+ necessary.</p>
+
+ <h1 id="access_logic">Writing a custom input control</h1>
+ <p> The following example shows, how easily a custom input control
+ type
+ can be created and applied.</p>
+ <h2> Step 1: Write your input control class. </h2>
+ <p> Create a new class, derive it from InputControl and provide an implementation
+ for the
+ three methods <code>renderText()</code>, <code>renderInput()</code> and <code>getFieldValue()</code>.
+ Remember that your class must be fully stateless since one single instance is
+ shared for all fields and threads. However all information you
+ require
+ is provided with the parameters. Here is an outline of what your
+ class may look like:</p>
+<pre><font color="#0000FF">public class </font>CustomInputControl <font color="#0000FF">extends</font> InputControl {
+<font color="#404040"> @Override
+</font> <font color="#0000FF">public</font> Object getFieldValue(String name, RequestParamProvider request, Locale locale, DBColumn column) { ⦠}
+<font color="#404040"> @Override
+</font> <font color="#0000FF">public</font> void renderText(HtmlWriter writer, ValueInfo vi) { ⦠}
+<font color="#404040"> @Override
+</font> <font color="#0000FF">public</font> void renderInput(HtmlWriter writer, ControlInfo ci) { ⦠}
+}</pre>
+ <h2> Step 2: Register your class with the InputControlMananger. </h2>
+ <p> To make the Empire-Struts2-Extensions capable of using your
+ input control class you must register it with the input control
+ manager as follows:</p>
+<pre><font color="#008000">// Register Control</font>
+InputControlManager.registerControl(<font color="#0000FF">"custom</font><font color="#0000FF">"</font>, <font color="#0000FF">new</font> CustomInputControl());</pre>
+ <h2> Step 3: Assign your input control type to database columns</h2>
+ <p> Finally, assign your control type to database columns. To do
+ this, use the <code>setControlType()</code> function which is provided with the
+ DBColumn
+ objects. For those fields, your custom input control class will now
+ be used for rendering and form request processing.</p>
+<pre>MyDatabase db = getDatabase();
+db.<font color="#0000FF">MYTABLE</font>.<font color="#0000FF">MYCOLUMN</font>.setControlType(<font color="#0000FF">"custom</font><font color="#0000FF">"</font>);</pre>
+ <p> </p>
+
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img src="../images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page
+ <img src="../images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" || prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" || next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" && prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" && next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <small>Copyright © 2008, The Apache Software Foundation</small> <!--<p style="padding-right: 25px; text-align: right;">
+ <a href="http://validator.w3.org/check?uri=referer">
+ <img
+ src="images/valid-xhtml10.png"
+ alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
+ </p>--></div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: incubator/empire-db/site/struts2ext/forms_controls.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/site/struts2ext/input_controls.htm
URL: http://svn.apache.org/viewvc/incubator/empire-db/site/struts2ext/input_controls.htm?rev=681719&view=auto
==============================================================================
--- incubator/empire-db/site/struts2ext/input_controls.htm (added)
+++ incubator/empire-db/site/struts2ext/input_controls.htm Fri Aug 1 08:15:26 2008
@@ -0,0 +1,283 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
+<!-- #BeginTemplate "../main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata, persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+<title>Empire-db and Struts2 - Input controls</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" src="../js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="../empire-db.ico" />
+ <link rel="stylesheet" href="../css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+<style type="text/css">
+table#struts2_comparison th {
+ width: 300px;
+ border: 1px #C0C0C0 solid;
+ border-bottom: 1px black solid;
+ background: #e8e8e8;
+}
+table#struts2_comparison td {
+ text-align: center;
+ border: 1px #C0C0C0 solid;
+ background: #FCFCFC;
+}
+</style>
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="../images/logos/empire-db-logo.gif" alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a target="_blank" href="http://incubator.apache.org/">
+ <img src="../images/logos/apache-incubator-logo.png" alt="Apache Incubator" /></a>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a href="../index.html">Home</a></li>
+ <li id="menu_news"><a href="../news.htm">News</a></li>
+ <li id="menu_empiredb">
+ <a href="../empiredb/empiredb.htm">Empire-db</a>
+ <ul class="subMenu">
+ <li id="menu_empiredb_extending_pattern">
+ <a href="../empiredb/pattern.htm">The Empire DAO-<br />pattern</a></li>
+ <li id="menu_empiredb_handling_metadata">
+ <a href="../empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li id="menu_empiredb_wrong">
+ <a href="../empiredb/hibernate.htm">What's wrong with Hibernate and JPA</a></li>
+ <li id="menu_empiredb_stringfree">
+ <a href="../empiredb/stringfree.htm">The principle of<br/>string-free coding</a></li>
+ <li id="menu_empiredb_faq">
+ <a href="../empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a href="struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li id="menu_struts2ext_forms_controls">
+ <a href="forms_controls.htm">Forms and controls</a></li>
+ <li id="menu_struts2ext_rendering_parsing">
+ <a href="rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag reference</a></li>-->
+ <li id="menu_struts2ext_input_controls">
+ <a href="input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads">
+ <a href="../downloads/downloads.htm">Downloads</a>
+ <ul class="subMenu">
+ <li id="menu_downloads_license">
+ <a href="../downloads/license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation">
+ <a href="../documentation/documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li id="menu_documentation_class_overview">
+ <a href="../documentation/class_overview.htm">Empire-db class<br />overview</a></li>
+ <li id="menu_documentation_tutorials">
+ <a href="../documentation/tutorial.htm">Tutorial</a></li>
+ <li id="menu_documentation_getting_started">
+ <a href="../documentation/getting_started.htm">Getting started</a></li>
+ <li id="menu_documentation_api">
+ <a href="../documentation/api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community">
+ <a href="../community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li id="menu_community_mailing_lists">
+ <a href="../community/mailing_lists.htm">Mailing lists</a></li>
+ <!--<li id="menu_community_source_code"><a href="community/source_code.htm">Source code</a></li>-->
+ <li id="menu_community_jira">
+ <a href="../community/jira.htm">Ticketing system</a></li>
+ <!--<li id="menu_community_road_map"><a href="community/road_map.htm">Road map</a></li>-->
+ <li id="menu_community_contributors">
+ <a href="../community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a href="../disclaimer.htm">Disclaimer</a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_struts2ext', 'menu_struts2ext_input_controls' );
+
+ function toggle (id){
+ if (document.getElementById) {
+ var mydiv = document.getElementById(id);
+ mydiv.style.display = (mydiv.style.display=='block'?'none':'block');
+ }
+ }
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <!-- #BeginEditable "pathway" -->
+ Empire and Struts2 » Input controls
+ <!-- #EndEditable -->
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <h1>Empire-Struts2-Extension Input Control Types</h1>
+ <table style="margin-bottom: 10px;">
+ <thead>
+ <tr>
+ <th nowrap="true">Control Type</th>
+ <th>Class</th>
+ <th>Column Attributes</th>
+ </tr>
+ </thead >
+ <tbody>
+ <tr>
+ <td>checkbox</td>
+ <td>CheckBoxInputControl</td>
+ <td>required</td>
+ </tr>
+ <tr>
+ <td>email</td>
+ <td>EmailInputControl</td>
+ <td>required, size</td>
+ </tr>
+ <tr>
+ <td>filedata</td>
+ <td>FileDataInputControl</td>
+ <td>required, maxValue</td>
+ </tr>
+ <tr>
+ <td>hlink</td>
+ <td>HLinkInputControl</td>
+ <td>required, size</td>
+ </tr>
+ <tr>
+ <td>password</td>
+ <td>PasswordInputControl</td>
+ <td>required, size</td>
+ </tr>
+ <tr>
+ <td>phone</td>
+ <td>PhoneInputControl</td>
+ <td>required, size</td>
+ </tr>
+ <tr>
+ <td>select</td>
+ <td>SelectInputControl</td>
+ <td>required</td>
+ </tr>
+ <tr>
+ <td>text (default)</td>
+ <td>TextInputControl</td>
+ <td>required, size, minValue, maxValue, numberGroupSeperator, numberFractionDigits</td>
+ </tr>
+ <tr>
+ <td>textArea</td>
+ <td>TextAreaInputControl</td>
+ <td>required, size</td>
+ </tr>
+ </tbody>
+ </table>
+ <!--
+ <h1>Interaction of the Empire Struts 2 Extension, Empire-DB and Struts</h1>
+ <img style="display: block; margin: auto;" src="../images/diagrams/function_of_input_control.jpg" alt="Operation mode of an input control" />-->
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img src="../images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page
+ <img src="../images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" || prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" || next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" && prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" && next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <small>Copyright © 2008, The Apache Software Foundation</small> <!--<p style="padding-right: 25px; text-align: right;">
+ <a href="http://validator.w3.org/check?uri=referer">
+ <img
+ src="images/valid-xhtml10.png"
+ alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
+ </p>--></div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: incubator/empire-db/site/struts2ext/input_controls.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/site/struts2ext/rendering_parsing.htm
URL: http://svn.apache.org/viewvc/incubator/empire-db/site/struts2ext/rendering_parsing.htm?rev=681719&view=auto
==============================================================================
--- incubator/empire-db/site/struts2ext/rendering_parsing.htm (added)
+++ incubator/empire-db/site/struts2ext/rendering_parsing.htm Fri Aug 1 08:15:26 2008
@@ -0,0 +1,305 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
+<!-- #BeginTemplate "../main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata, persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+<title>Empire-db and Struts2 - Rendering and parsing</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" src="../js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="../empire-db.ico" />
+ <link rel="stylesheet" href="../css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="../images/logos/empire-db-logo.gif" alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a target="_blank" href="http://incubator.apache.org/">
+ <img src="../images/logos/apache-incubator-logo.png" alt="Apache Incubator" /></a>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a href="../index.html">Home</a></li>
+ <li id="menu_news"><a href="../news.htm">News</a></li>
+ <li id="menu_empiredb">
+ <a href="../empiredb/empiredb.htm">Empire-db</a>
+ <ul class="subMenu">
+ <li id="menu_empiredb_extending_pattern">
+ <a href="../empiredb/pattern.htm">The Empire DAO-<br />pattern</a></li>
+ <li id="menu_empiredb_handling_metadata">
+ <a href="../empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li id="menu_empiredb_wrong">
+ <a href="../empiredb/hibernate.htm">What's wrong with Hibernate and JPA</a></li>
+ <li id="menu_empiredb_stringfree">
+ <a href="../empiredb/stringfree.htm">The principle of<br/>string-free coding</a></li>
+ <li id="menu_empiredb_faq">
+ <a href="../empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a href="struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li id="menu_struts2ext_forms_controls">
+ <a href="forms_controls.htm">Forms and controls</a></li>
+ <li id="menu_struts2ext_rendering_parsing">
+ <a href="rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag reference</a></li>-->
+ <li id="menu_struts2ext_input_controls">
+ <a href="input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads">
+ <a href="../downloads/downloads.htm">Downloads</a>
+ <ul class="subMenu">
+ <li id="menu_downloads_license">
+ <a href="../downloads/license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation">
+ <a href="../documentation/documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li id="menu_documentation_class_overview">
+ <a href="../documentation/class_overview.htm">Empire-db class<br />overview</a></li>
+ <li id="menu_documentation_tutorials">
+ <a href="../documentation/tutorial.htm">Tutorial</a></li>
+ <li id="menu_documentation_getting_started">
+ <a href="../documentation/getting_started.htm">Getting started</a></li>
+ <li id="menu_documentation_api">
+ <a href="../documentation/api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community">
+ <a href="../community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li id="menu_community_mailing_lists">
+ <a href="../community/mailing_lists.htm">Mailing lists</a></li>
+ <!--<li id="menu_community_source_code"><a href="community/source_code.htm">Source code</a></li>-->
+ <li id="menu_community_jira">
+ <a href="../community/jira.htm">Ticketing system</a></li>
+ <!--<li id="menu_community_road_map"><a href="community/road_map.htm">Road map</a></li>-->
+ <li id="menu_community_contributors">
+ <a href="../community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a href="../disclaimer.htm">Disclaimer</a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_struts2ext', 'menu_struts2ext_rendering_parsing' );
+ var prev_page = "forms_controls.htm";
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <!-- #BeginEditable "pathway" -->
+ <a href="struts2ext.htm">Empire-db and Struts2</a> » Rendering and parsing
+ <!-- #EndEditable -->
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <h1>Input controls part 2 â Rendering and parsing</h1>
+ <p> One of the biggest problems in Web development is that usually the code responsible
+ for rendering data is separated from the code used for parsing and validating data.
+ In most cases the rendering is performed in a JSP page, either by directly embedding string
+ representation of the value in HTML or by a special JSP tag that renders the value
+ according to information provided with attributes on the tag. When the user submits the
+ form the values are usually pushed into a JavaBean or POJO by an interceptor which takes the
+ parameters from the request, looks for an appropriate setter method and then converts
+ the value to fit the setterâs value data type.</p>
+ <p> This procedure has several disadvantages that are best understood by the following example:<br />
+ Consider a phone number which is stored in the database in a single field. On the form however
+ you want to display and edit the phone number in three individual text fields: the first for the
+ country code, the second for the city code and the last for the extension code which are separated
+ from each other using a dash. The first problem with traditional Web application frameworks is,
+ that since there is no tag for such behaviour you have to write all the HTML code for those three
+ separate input tags plus the label in your JSP. Even worse however is, that when the form is
+ submitted three individual fields are supplied that you have to assemble to a single value again.
+ Now for this you have several options which are all quite complicated for such a simple task. If you
+ donât want to provide your own interceptor you will have to provide corresponding setters on your JavaBean and â if you donât want to rely on the order by which these setters are called - youâd
+ have to add additional post processing code that will put them together again. Still the assembly
+ code must rely on the rendering code which is in the JSP and thus not in the same place. As a third
+ problem youâll find the task of validation â for which you might have to write your own validation
+ class. At last, all this has to be done for every single phone number field you have in your
+ application. Imagine you have several phone number fields then handling
+ all of them becomes quite a nasty
+ problem.</p>
+ <p> With Empire-Struts2-Extensions the task of rendering and the task of parsing and validating form
+ values are now put together in one simple class: The input control. The input control is an abstract
+ base class for which you can easily provide your own implementation if necessary by only implementing
+ three simple methods: <code>renderText()</code>, <code>renderInput()</code> and <code>getFieldValue()</code>.
+ For the most common field types there are already implementations provided such as text, select, password, phone, checkbox and more.
+ The major differences to traditional processing are:</p>
+ <ol>
+ <li>The input control has access to field metadata and can thus perform rendering, parsing and
+ validation without additional redundant information provided in the view. However should you ever
+ need it, you may as well override these attributes in your JSPs.</li>
+ <li>The input control class distinguishes between read only and editable rendering and can thus also
+ be used for list views for example. Consider a field whose value you have
+ to format in a
+ particular way for display. Simply write your own input control class and assign the control
+ type to the corresponding column. Wherever a value for this field is displayed with any of the Empire tags
+ it will be formatted correctly â without any change or additional
+ attributes in the JSPs. </li>
+ <li>For processing submitted form data the input control uses a pull rather than the usual push
+ approach. This allows the input control to combine two or more fields to one value. This
+ is e.g. used for checkboxes where an additional hidden value is used to detect whether the
+ checkbox has been unchecked. Since the rendering code is in the same object both the splitting
+ and the assembly can easily be kept consistent.</li>
+ </ol>
+ <p>The following graphic shows how the InputControl is the interface
+ between the view and the model:</p>
+ <img style="display: block; margin: auto;" src="../images/diagrams/function_of_input_control.gif" alt="" />
+
+ <p>The list view JSP uses the <code><e:value></code> tag (or alternatively an <code><e:td></code>
+ tag which extends <code><e:value></code>) to render the field's value for
+ display. The form view on contrary uses the <code><e:control></code> tag to
+ render a form input control which may be used to change the value.
+ When the form is submitted, an action support class iterates through
+ all fields and gives the corresponding InputControl the opportunity
+ to pull the value(s) off the request and to perform parsing and
+ validation. If successful the field value is written back to the
+ record. For all three tasks access to data and metadata is
+ necessary.</p>
+
+ <h1 id="access_logic">Writing a custom input control</h1>
+ <p> The following example shows, how easily a custom input control
+ type
+ can be created and applied.</p>
+ <h2> Step 1: Write your input control class. </h2>
+ <p> Create a new class, derive it from InputControl and provide an implementation
+ for the
+ three methods <code>renderText()</code>, <code>renderInput()</code> and <code>getFieldValue()</code>.
+ Remember that your class must be fully stateless since one single instance is
+ shared for all fields and threads. However all information you
+ require
+ is provided with the parameters. Here is an outline of what your
+ class may look like:</p>
+<pre><font color="#0000FF">public class </font>CustomInputControl <font color="#0000FF">extends</font> InputControl {
+<font color="#404040"> @Override
+</font> <font color="#0000FF">public</font> Object getFieldValue(String name, RequestParamProvider request, Locale locale, DBColumn column) { ⦠}
+<font color="#404040"> @Override
+</font> <font color="#0000FF">public</font> void renderText(HtmlWriter writer, ValueInfo vi) { ⦠}
+<font color="#404040"> @Override
+</font> <font color="#0000FF">public</font> void renderInput(HtmlWriter writer, ControlInfo ci) { ⦠}
+}</pre>
+ <h2> Step 2: Register your class with the InputControlMananger. </h2>
+ <p> To make the Empire-Struts2-Extensions capable of using your
+ input control class you must register it with the input control
+ manager as follows:</p>
+<pre><font color="#008000">// Register Control</font>
+InputControlManager.registerControl(<font color="#0000FF">"custom</font><font color="#0000FF">"</font>, <font color="#0000FF">new</font> CustomInputControl());</pre>
+ <h2> Step 3: Assign your input control type to database columns</h2>
+ <p> Finally, assign your control type to database columns. To do
+ this, use the <code>setControlType()</code> function which is provided with the
+ DBColumn
+ objects. For those fields, your custom input control class will now
+ be used for rendering and form request processing.</p>
+<pre>MyDatabase db = getDatabase();
+db.<font color="#0000FF">MYTABLE</font>.<font color="#0000FF">MYCOLUMN</font>.setControlType(<font color="#0000FF">"custom</font><font color="#0000FF">"</font>);</pre>
+ <p> </p>
+
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img src="../images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page
+ <img src="../images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" || prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" || next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" && prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" && next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <small>Copyright © 2008, The Apache Software Foundation</small> <!--<p style="padding-right: 25px; text-align: right;">
+ <a href="http://validator.w3.org/check?uri=referer">
+ <img
+ src="images/valid-xhtml10.png"
+ alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
+ </p>--></div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: incubator/empire-db/site/struts2ext/rendering_parsing.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain