click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r757950 [3/3] - in /incubator/click/trunk/click: ./ examples/src/org/apache/click/examples/page/general/ examples/webapp/WEB-INF/ examples/webapp/assets/js/ examples/webapp/assets/rating/ examples/webapp/general/ framework/src/org/apache/cl...
Date Tue, 24 Mar 2009 18:48:59 GMT
Added: incubator/click/trunk/click/examples/webapp/assets/rating/delete.gif
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/assets/rating/delete.gif?rev=757950&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/click/trunk/click/examples/webapp/assets/rating/delete.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.css
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.css?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.css (added)
+++ incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.css Tue Mar 24
18:48:56 2009
@@ -0,0 +1,26 @@
+/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ */
+div.rating-cancel,div.star-rating {
+        float:left;
+        width:17px;
+        height:15px;
+        text-indent:-999em;
+        cursor:pointer;
+        display:block;
+        background:transparent;
+        overflow:hidden;
+}
+
+div.rating-cancel,div.rating-cancel a{background:url(delete.gif) no-repeat 0 -16px;}
+div.star-rating,div.star-rating a{background:url(star.gif) no-repeat 0 0px;}
+div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0
0px;border:0;}
+div.star-rating-on a{background-position:0 -16px!important;}
+div.star-rating-hover a{background-position:0 -32px;}
+/* Read Only CSS */
+div.star-rating-readonly a{cursor:default !important;}
+/* Partial Star CSS */
+div.star-rating{background:transparent!important;overflow:hidden!important;}
\ No newline at end of file

Added: incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js (added)
+++ incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js Tue Mar 24
18:48:56 2009
@@ -0,0 +1,344 @@
+/*
+ ### jQuery Star Rating Plugin v3.10 - 2009-03-23 ###
+ * Home: http://www.fyneworks.com/jquery/star-rating/
+ * Code: http://code.google.com/p/jquery-star-rating-plugin/
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ ###
+*/
+
+/*# AVOID COLLISIONS #*/
+;if(window.jQuery) (function($){
+/*# AVOID COLLISIONS #*/
+	
+	// IE6 Background Image Fix
+	if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e)
{ }
+	// Thanks to http://www.visualjquery.com/rating/rating_redux.html
+	
+	// plugin initialization
+	$.fn.rating = function(options){
+		if(this.length==0) return this; // quick fail
+		
+		// Handle API methods
+		if(typeof arguments[0]=='string'){
+			// Perform API methods on individual elements
+			if(this.length>1){
+				var args = arguments;
+				return this.each(function(){
+					$.fn.rating.apply($(this), args);
+    });
+			};
+			// Invoke API method handler
+			$.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
+			// Quick exit...
+			return this;
+		};
+		
+		// Initialize options for this call
+		var options = $.extend(
+			{}/* new object */,
+			$.fn.rating.options/* default options */,
+			options || {} /* just-in-time options */
+		);
+		
+		// loop through each matched element
+		this
+		 .not('.star-rating-applied')
+			.addClass('star-rating-applied')
+		.each(function(){
+			
+			// Load control parameters / find context / etc
+			var eid = (this.name || 'unnamed-rating').replace(/\[|\]+/g, "_");
+			var context = $(this.form || document.body);
+			var input = $(this);
+			var raters = context.data('rating') || { count:0 };
+			var rater = raters[eid];
+			var control;
+			
+			// if rater is available, verify that the control still exists
+			if(rater) control = rater.data('rating');
+			
+			if(rater && control){
+				// add star to control if rater is available and the same control still exists
+				control.count++;
+				
+			}
+			else{
+				// create new control if first star or control element was removed/replaced
+				
+				// Initialize options for this raters
+				control = $.extend(
+					{}/* new object */,
+					options || {} /* current call options */,
+					($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options
*/
+					{ count:0, stars: [], inputs: [] }
+				);
+				
+				// increment number of rating controls
+				control.serial = raters.count++;
+				
+				// create rating element
+				rater = $('<span class="star-rating-control"/>');
+				input.before(rater);
+				
+				// Mark element for initialization (once all stars are ready)
+				rater.addClass('rating-to-be-drawn');
+				
+				// Accept readOnly setting from 'disabled' property
+				if(input.attr('disabled')) control.readOnly = true;
+				
+				// Create 'cancel' button
+				rater.append(
+					control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel
+ '">' + control.cancelValue + '</a></div>')
+					.mouseover(function(){
+						$(this).rating('drain');
+						$(this).addClass('star-rating-hover');
+						//$(this).rating('focus');
+					})
+					.mouseout(function(){
+						$(this).rating('draw');
+						$(this).removeClass('star-rating-hover');
+						//$(this).rating('blur');
+					})
+					.click(function(){
+					 $(this).rating('select');
+					})
+					.data('rating', control)
+				);
+				
+			}; // first element of group
+			
+			// insert rating star
+			var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="'
+ (this.title || this.value) + '">' + this.value + '</a></div>');
+			rater.append(star);
+			
+			// inherit attributes from input element
+			if(this.id) star.attr('id', this.id);
+			if(this.className) star.addClass(this.className);
+			
+			// Half-stars?
+			if(control.half) control.split = 2;
+			
+			// Prepare division control
+			if(typeof control.split=='number' && control.split>0){
+				var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
+				var spi = (control.count % control.split), spw = Math.floor(stw/control.split);
+				star
+				// restrict star's width and hide overflow (already in CSS)
+				.width(spw)
+				// move the star left by using a negative margin
+				// this is work-around to IE's stupid box model (position:relative doesn't work)
+				.find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
+			};
+			
+			// readOnly?
+			if(control.readOnly)//{ //save a byte!
+				// Mark star as readOnly so user can customize display
+				star.addClass('star-rating-readonly');
+			//}  //save a byte!
+			else//{ //save a byte!
+			 // Enable hover css effects
+				star.addClass('star-rating-live')
+				 // Attach mouse events
+					.mouseover(function(){
+						$(this).rating('fill');
+						$(this).rating('focus');
+					})
+					.mouseout(function(){
+						$(this).rating('draw');
+						$(this).rating('blur');
+					})
+					.click(function(){
+						$(this).rating('select');
+					})
+				;
+			//}; //save a byte!
+			
+			// set current selection
+			if(this.checked)	control.current = star;
+			
+			// hide input element
+			input.hide();
+			
+			// backward compatibility, form element to plugin
+			input.change(function(){
+    $(this).rating('select');
+   });
+			
+			// attach reference to star to input element and vice-versa
+			star.data('rating.input', input.data('rating.star', star));
+			
+			// store control information in form (or body when form not available)
+			control.stars[control.stars.length] = star[0];
+			control.inputs[control.inputs.length] = input[0];
+			control.rater = raters[eid] = rater;
+			control.context = context;
+			
+			input.data('rating', control);
+			rater.data('rating', control);
+			star.data('rating', control);
+			context.data('rating', raters);
+  }); // each element
+		
+		// Initialize ratings (first draw)
+		$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');
+		
+		return this; // don't break the chain...
+	};
+	
+	/*--------------------------------------------------------*/
+	
+	/*
+		### Core functionality and API ###
+	*/
+	$.extend($.fn.rating, {
+		
+		focus: function(){
+			var control = this.data('rating'); if(!control) return this;
+			if(!control.focus) return this; // quick fail if not required
+			// find data for event
+			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
+   // focus handler, as requested by focusdigital.co.uk
+			if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
+		}, // $.fn.rating.focus
+		
+		blur: function(){
+			var control = this.data('rating'); if(!control) return this;
+			if(!control.blur) return this; // quick fail if not required
+			// find data for event
+			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
+   // blur handler, as requested by focusdigital.co.uk
+			if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
+		}, // $.fn.rating.blur
+		
+		fill: function(){ // fill to the current mouse position.
+			var control = this.data('rating'); if(!control) return this;
+			// do not execute when control is in read-only mode
+			if(control.readOnly) return;
+			// Reset all stars and highlight them up to this element
+			this.rating('drain');
+			this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
+		},// $.fn.rating.fill
+		
+		drain: function() { // drain all the stars.
+			var control = this.data('rating'); if(!control) return this;
+			// do not execute when control is in read-only mode
+			if(control.readOnly) return;
+			// Reset all stars
+			control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
+		},// $.fn.rating.drain
+		
+		draw: function(){ // set value and stars to reflect current selection
+			var control = this.data('rating'); if(!control) return this;
+			// Clear all stars
+			this.rating('drain');
+			// Set control value
+			if(control.current){
+				control.current.data('rating.input').attr('checked','checked');
+				control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');
+			}
+			else
+			 $(control.inputs).removeAttr('checked');
+			// Show/hide 'cancel' button
+			control.cancel[control.readOnly || control.required?'hide':'show']();
+			// Add/remove read-only classes to remove hand pointer
+			this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
+		},// $.fn.rating.draw
+		
+		select: function(value){ // select a value
+			var control = this.data('rating'); if(!control) return this;
+			// do not execute when control is in read-only mode
+			if(control.readOnly) return;
+			// clear selection
+			control.current = null;
+			// programmatically (based on user input)
+			if(typeof value!='undefined'){
+			 // select by index (0 based)
+				if(typeof value=='number')
+ 			 return $(control.stars[value]).rating('select');
+				// select by literal value (must be passed as a string
+				if(typeof value=='string')
+					//return 
+					$.each(control.stars, function(){
+						if($(this).data('rating.input').val()==value) $(this).rating('select');
+					});
+			}
+			else
+				control.current = this[0].tagName=='INPUT' ? 
+				 this.data('rating.star') : 
+					(this.is('.rater-'+ control.serial) ? this : null);
+			
+			// Update rating control state
+			this.data('rating', control);
+			// Update display
+			this.rating('draw');
+			// find data for event
+			var input = $( control.current ? control.current.data('rating.input') : null );
+			// click callback, as requested here: http://plugins.jquery.com/node/1655
+			if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);//
callback event
+		},// $.fn.rating.select
+		
+		readOnly: function(toggle, disable){ // make the control read-only (still submits value)
+			var control = this.data('rating'); if(!control) return this;
+			// setread-only status
+			control.readOnly = toggle || toggle==undefined ? true : false;
+			// enable/disable control value submission
+			if(disable) $(control.inputs).attr("disabled", "disabled");
+			else     			$(control.inputs).removeAttr("disabled");
+			// Update rating control state
+			this.data('rating', control);
+			// Update display
+			this.rating('draw');
+		},// $.fn.rating.readOnly
+		
+		disable: function(){ // make read-only and never submit value
+			this.rating('readOnly', true, true);
+		},// $.fn.rating.disable
+		
+		enable: function(){ // make read/write and submit value
+			this.rating('readOnly', false, false);
+		}// $.fn.rating.select
+		
+ });
+	
+	/*--------------------------------------------------------*/
+	
+	/*
+		### Default Settings ###
+		eg.: You can override default control like this:
+		$.fn.rating.options.cancel = 'Clear';
+	*/
+	$.fn.rating.options = { //$.extend($.fn.rating, { options: {
+			cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
+			cancelValue: '',           // value to submit when user click the 'cancel' link
+			split: 0,                  // split the star into how many parts?
+			
+			// Width of star image in case the plugin can't work it out. This can happen if
+			// the jQuery.dimensions plugin is not available OR the image is hidden at installation
+			starWidth: 16//,
+			
+			//NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
+			//half:     false,         // just a shortcut to control.split = 2
+			//required: false,         // disables the 'cancel' button so user can only select one
of the specified values
+			//readOnly: false,         // disable rating plugin interaction/ values cannot be changed
+			//focus:    function(){},  // executed when stars are focused
+			//blur:     function(){},  // executed when stars are focused
+			//callback: function(){},  // executed when a star is clicked
+ }; //} });
+	
+	/*--------------------------------------------------------*/
+	
+	/*
+		### Default implementation ###
+		The plugin will attach itself to file inputs
+		with the class 'multi' when the page loads
+	*/
+	$(function(){ $('input[type=radio].star').rating(); });
+	
+	
+	
+/*# AVOID COLLISIONS #*/
+})(jQuery);
+/*# AVOID COLLISIONS #*/

Added: incubator/click/trunk/click/examples/webapp/assets/rating/star.gif
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/assets/rating/star.gif?rev=757950&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/click/trunk/click/examples/webapp/assets/rating/star.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/click/trunk/click/examples/webapp/general/control-head-demo.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/general/control-head-demo.htm?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/general/control-head-demo.htm (added)
+++ incubator/click/trunk/click/examples/webapp/general/control-head-demo.htm Tue Mar 24 18:48:56
2009
@@ -0,0 +1,26 @@
+<!--
+#* 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.*#
+-->
+
+This demo shows how to manipulate the HEAD elements of a custom Star Rating
+Control based on the JQuery <a class="external" target="_blank" href="http://www.fyneworks.com/jquery/star-rating/">Star
Rating</a>
+plugin.
+
+<p/>
+
+$form
\ No newline at end of file

Added: incubator/click/trunk/click/examples/webapp/general/page-head-demo.css
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/general/page-head-demo.css?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/general/page-head-demo.css (added)
+++ incubator/click/trunk/click/examples/webapp/general/page-head-demo.css Tue Mar 24 18:48:56
2009
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#field-div {
+    width: 300px;
+    background-color: #D0D0D0;
+    padding: 2em;
+    border: 3px solid #585858;
+}

Added: incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm (added)
+++ incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm Tue Mar 24 18:48:56
2009
@@ -0,0 +1,39 @@
+<!--
+#* 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.*#
+-->
+
+This demo shows how to manipulate the HEAD elements of a Page by adding
+the JQuery library and render the JavaScript
+<a href="$context/source-viewer.htm?filename=/general/page-head-demo.js">page-head-demo.js</a>
+to the Field's HEAD elements.
+<p/>
+
+The <tt>page-head-demo.js</tt> uses JQuery to register a 'click' listener on
the
+link that toggles the 'field-div' visibility.
+
+<hr/>
+
+$link
+
+<p/>
+
+<div id="container">
+    <div id="field-div">
+        $field.label $field
+    </div>
+</div>
\ No newline at end of file

Added: incubator/click/trunk/click/examples/webapp/general/page-head-demo.js
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/general/page-head-demo.js?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/general/page-head-demo.js (added)
+++ incubator/click/trunk/click/examples/webapp/general/page-head-demo.js Tue Mar 24 18:48:56
2009
@@ -0,0 +1,32 @@
+// 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.
+
+$(document).ready(function() {
+
+  // Register a click listener on the link that will toggle field-div visibility
+  $('$linkId').click(function() {
+
+    // Toggle the field-div to slide up or down
+    $('#container').slideToggle("fast");
+
+    // Change the link text each time its clicked
+    $(this).text($(this).text() == 'Show' ? 'Hide' : 'Show');
+
+    // Return false which overrides the default link click action
+    return false;
+  });
+});

Modified: incubator/click/trunk/click/framework/src/org/apache/click/Control.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/Control.java?rev=757950&r1=757949&r2=757950&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/Control.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/Control.java Tue Mar 24 18:48:56
2009
@@ -178,20 +178,19 @@
     public String getHtmlImports();
 
     /**
-     * Return the list of {@link org.apache.click.element.Element HEAD elements}
+     * Return the list of HEAD {@link org.apache.click.element.Element elements}
      * to be included in the page. Example HEAD elements include
-     * {@link org.apache.click.element.JsImport JavaScript imports},
-     * {@link org.apache.click.element.JsScript inline JavasSript},
-     * {@link org.apache.click.element.CssImport Css imports} and
-     * {@link org.apache.click.element.CssStyle inline Css}.
+     * {@link org.apache.click.element.JsImport JsImport},
+     * {@link org.apache.click.element.JsScript JsScript},
+     * {@link org.apache.click.element.CssImport CssImport} and
+     * {@link org.apache.click.element.CssStyle CssStyle}.
      * <p/>
-     * Controls can include their own list of HEAD elements by implementing
+     * Controls can contribute their own list of HEAD elements by implementing
      * this method.
      * <p/>
      * The recommended approach when implementing this method is to use
-     * <tt>lazy loading</tt> to only add HEAD elements <tt>once</tt>
and when
-     * <tt>needed</tt>.
-     * For example:
+     * <tt>lazy loading</tt> to ensure the HEAD elements are only added
+     * <tt>once</tt> and when <tt>needed</tt>. For example:
      *
      * <pre class="prettyprint">
      * public MyControl extends AbstractControl {
@@ -221,8 +220,10 @@
      * public MyControl extends AbstractControl {
      *
      *     public MyControl() {
+     *
      *         JsImport jsImport = new JsImport("/mycorp/mycontrol/mycontrol.js");
      *         getHeadElements().add(jsImport);
+     *
      *         CssImport cssImport = new CssImport("/mycorp/mycontrol/mycontrol.css");
      *         getHeadHeaders().add(cssImport);
      *     }
@@ -230,7 +231,9 @@
      *
      * One can also add HEAD elements from event handler methods such as
      * {@link #onInit()}, {@link #onProcess()}, {@link #onRender()}
-     * etc. <b>Please note:</b> when adding HEAD elements to event handlers,
+     * etc.
+     * <p/>
+     * <b>Please note:</b> when adding HEAD elements to event handlers,
      * its possible that the control will be added to a
      * {@link Page#stateful Stateful} page, so you will need to set the HEAD
      * elements list to <tt>null</tt> in the Control's {@link #onDestroy()}
@@ -242,9 +245,11 @@
      *
      *     // Set HEAD elements in the onInit event handler
      *     public void onInit() {
+     *
      *         // Add HEAD elements
      *         JsImport jsImport = new JsImport("/mycorp/mycontrol/mycontrol.js");
      *         getHeadElements().add(jsImport);
+     *
      *         CssImport cssImport = new CssImport("/mycorp/mycontrol/mycontrol.css");
      *         getHeadElements().add(cssImport);
      *     }

Modified: incubator/click/trunk/click/framework/src/org/apache/click/Page.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/Page.java?rev=757950&r1=757949&r2=757950&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/Page.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/Page.java Tue Mar 24 18:48:56
2009
@@ -24,7 +24,9 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.click.element.Element;
 import org.apache.click.util.Format;
+import org.apache.click.util.HtmlStringBuffer;
 import org.apache.click.util.MessagesMap;
 import org.apache.click.util.PageImports;
 
@@ -658,19 +660,19 @@
     }
 
     /**
-     * Return the list of {@link org.apache.click.element.Element HEAD elements}
+     * Return the list of HEAD {@link org.apache.click.element.Element elements}
      * to be included in the page. Example HEAD elements include
-     * {@link org.apache.click.element.JsImport JavaScript imports},
-     * {@link org.apache.click.element.JsScript inline JavasSript},
-     * {@link org.apache.click.element.CssImport Css imports} and
-     * {@link org.apache.click.element.CssStyle inline Css}.
+     * {@link org.apache.click.element.JsImport JsImport},
+     * {@link org.apache.click.element.JsScript JsScript},
+     * {@link org.apache.click.element.CssImport CssImport} and
+     * {@link org.apache.click.element.CssStyle CssStyle}.
      * <p/>
-     * Pages can include their own list of HEAD elements by implementing
+     * Pages can contribute their own list of HEAD elements by overriding
      * this method.
      * <p/>
-     * The recommended approach when implementing this method is to use
-     * <tt>lazy loading</tt> to only add HEAD elements once and when needed.
-     * For example:
+     * The recommended approach when overriding this method is to use
+     * <tt>lazy loading</tt> to ensure the HEAD elements are only added
+     * <tt>once</tt> and when <tt>needed</tt>. For example:
      *
      * <pre class="prettyprint">
      * public MyPage extends Page {
@@ -702,6 +704,7 @@
      *     public MyPage() {
      *         JsImport jsImport = new JsImport("/mycorp/js/mypage.js");
      *         getHeadElements().add(jsImport);
+     *
      *         CssImport cssImport = new CssImport("/mycorp/js/mypage.css");
      *         getHeadElements().add(cssImport);
      *     }
@@ -709,7 +712,9 @@
      *
      * One can also add HEAD elements from event handler methods such as
      * {@link #onInit()}, {@link #onGet()}, {@link #onPost()}, {@link #onRender()}
-     * etc. <b>Please note:</b> when using {@link #stateful Stateful} pages,
you
+     * etc.
+     * <p/>
+     * <b>Please note:</b> when using {@link #stateful Stateful} pages, you
      * will need to set the HEAD elements list to <tt>null</tt> in the
      * {@link #onDestroy()} event handler, otherwise the HEAD elements list will
      * continue to grow with each request:
@@ -724,9 +729,11 @@
      *
      *     // Set HEAD elements in the onInit event handler
      *     public void onInit() {
+     *
      *         // Add HEAD elements
      *         JsImport jsImport = new JsImport("/mycorp/js/mypage.js");
      *         getHeadElements().add(jsImport);
+     *
      *         CssImport cssImport = new CssImport("/mycorp/js/mypage.css");
      *         getHeadElements().add(cssImport);
      *     }



Mime
View raw message