You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/03/24 19:48:59 UTC

svn commit: r757950 [1/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...

Author: sabob
Date: Tue Mar 24 18:48:56 2009
New Revision: 757950

URL: http://svn.apache.org/viewvc?rev=757950&view=rev
Log:
added two new examples demonstrating HEAD elements

Added:
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java
    incubator/click/trunk/click/examples/webapp/assets/js/jquery-1.3.2.js
    incubator/click/trunk/click/examples/webapp/assets/rating/
    incubator/click/trunk/click/examples/webapp/assets/rating/delete.gif   (with props)
    incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.css
    incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js
    incubator/click/trunk/click/examples/webapp/assets/rating/star.gif   (with props)
    incubator/click/trunk/click/examples/webapp/general/control-head-demo.htm
    incubator/click/trunk/click/examples/webapp/general/page-head-demo.css
    incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm
    incubator/click/trunk/click/examples/webapp/general/page-head-demo.js
Modified:
    incubator/click/trunk/click/LICENSE.txt
    incubator/click/trunk/click/NOTICE.txt
    incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml
    incubator/click/trunk/click/framework/src/org/apache/click/Control.java
    incubator/click/trunk/click/framework/src/org/apache/click/Page.java

Modified: incubator/click/trunk/click/LICENSE.txt
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/LICENSE.txt?rev=757950&r1=757949&r2=757950&view=diff
==============================================================================
--- incubator/click/trunk/click/LICENSE.txt (original)
+++ incubator/click/trunk/click/LICENSE.txt Tue Mar 24 18:48:56 2009
@@ -308,6 +308,51 @@
 
 ======================================================================
 
+JQUERY LICENSE (MIT License)
+
+Copyright (c) 2005-2008 John Resig
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+======================================================================
+
+STAR RATING PLUGIN LICENSE (MIT License)
+
+Copyright (c) 2008 Fyneworks.com
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+======================================================================
+
 COLOR PICKER LICENSE (MIT License)
 
 Copyright 2008 Sebo Zoltan <ia...@yahoo.com>

Modified: incubator/click/trunk/click/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/NOTICE.txt?rev=757950&r1=757949&r2=757950&view=diff
==============================================================================
--- incubator/click/trunk/click/NOTICE.txt (original)
+++ incubator/click/trunk/click/NOTICE.txt Tue Mar 24 18:48:56 2009
@@ -63,12 +63,24 @@
 
 ======================================================================
 
-This product includes the ColorPicker library developer by Sebo Zoltan,
+This product includes the ColorPicker library, developed by Sebo Zoltan,
 distributed under the terms of the MIT license.
 http://www.dhtmlgoodies.com/index.html?whichScript=submitted-color-picker
 
 ======================================================================
 
+This product includes the JQuery JavaScript library, developed by
+John Resig, distributed under the terms of the MIT license.
+http://jquery.com/
+
+======================================================================
+
+This product includes the JQuery Star Rating plugin, developed by
+Fyneworks.com, distributed under the terms of the MIT license.
+http://www.fyneworks.com/jquery/star-rating/
+
+======================================================================
+
 This product includes the rico JavaScript library, developed by 
 Sabre Airline Solutions and released under the Apache 2.0 license.
 http://openrico.org

Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java Tue Mar 24 18:48:56 2009
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+package org.apache.click.examples.page.general;
+
+import java.util.List;
+import org.apache.click.control.Field;
+import org.apache.click.control.Form;
+import org.apache.click.control.Submit;
+import org.apache.click.element.CssImport;
+import org.apache.click.element.JsImport;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.util.HtmlStringBuffer;
+
+/**
+ * This example demonstrates how to manipulate the Head elements of a
+ * custom StarRating Control.
+ *
+ * @author Bob Schellink
+ */
+public class ControlHeadDemo extends BorderPage {
+
+    public ControlHeadDemo() {
+
+        Form form = new Form("form");
+
+        StarRating rating = new StarRating("rating", 5, 2);
+        form.add(rating);
+
+        form.add(new Submit("submit"));
+
+        addControl(form);
+    }
+
+    /**
+     * A custom StarRating Control based on the JQuery Rating plugin.
+     */
+    public class StarRating extends Field {
+
+        private int maxStars;
+
+        public StarRating(String name, int maxStars, int selectedValue) {
+            super(name);
+            this.maxStars = maxStars;
+            setValue(Integer.toString(selectedValue));
+        }
+
+        /**
+         * Return the list of HEAD elements.
+         *
+         * @return list the list of HEAD elements
+         */
+        public List getHeadElements() {
+            if (headElements == null) {
+                headElements = super.getHeadElements();
+
+                // Add the JQuery library to the control
+                headElements.add(new JsImport("/assets/js/jquery-1.3.2.js"));
+
+                // Add the Rating JavaScript library to the control
+                headElements.add(new JsImport("/assets/rating/jquery.rating.js"));
+
+                // Add the Rating Css to the control
+                headElements.add(new CssImport("/assets/rating/jquery.rating.css"));
+            }
+            return headElements;
+        }
+
+        /**
+         * Render the HTML representation of the StarRating control.
+         *
+         * @param buffer the buffer to render the output to
+         */
+        public void render(HtmlStringBuffer buffer) {
+            // Render a radio button for each star
+            for (int i = 1; i <= maxStars; i++) {
+                String strValue = Integer.toString(i);
+                buffer.elementStart("input");
+                buffer.appendAttribute("type", "radio");
+                buffer.appendAttribute("name", getName());
+                buffer.appendAttribute("value", strValue);
+                buffer.appendAttribute("class", "star");
+                if (strValue.equals(getValue())) {
+                    buffer.appendAttribute("checked", "checked");
+                }
+                buffer.append("\n");
+            }
+        }
+    }
+}

Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java?rev=757950&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java Tue Mar 24 18:48:56 2009
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+package org.apache.click.examples.page.general;
+
+import java.util.Map;
+import org.apache.click.Context;
+import org.apache.click.control.ActionLink;
+import org.apache.click.control.Field;
+import org.apache.click.control.TextField;
+import org.apache.click.element.CssImport;
+import org.apache.click.element.CssStyle;
+import org.apache.click.element.JsImport;
+import org.apache.click.element.JsScript;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.util.ClickUtils;
+
+/**
+ * This example demonstrates how to manipulate the Head elements of a Page.
+ *
+ * @author Bob Schellink
+ */
+public class PageHeadDemo extends BorderPage {
+
+    private ActionLink link;
+    private Field field;
+
+    public PageHeadDemo() {
+        // When this link is clicked it will toggle the Field's disabled attribute
+        link = new ActionLink("link", "Hide");
+        link.setId("link-id");
+
+         // Create a new TextField and add it the Page controls
+        field = new TextField("field");
+
+        // Add JavaScript and Css imports
+        setHeadElements();
+
+        addControl(link);
+        addControl(field);
+    }
+
+    private void setHeadElements() {
+        // Add a Css import to the Page
+        getHeadElements().add(new CssImport("/general/page-head-demo.css"));
+
+        // Add inline Css content to the Page that increases the field font-size
+        getHeadElements().add(new CssStyle("#" + field.getId() + " { font-size: 18px; }"));
+
+        // Add the JQuery library to the Page
+        getHeadElements().add(new JsImport("/assets/js/jquery-1.3.2.js"));
+
+        // Add a JQuery template which adds a 'click' listener to the link
+        // that will show/hide the field
+        Context context = getContext();
+
+        // Create a template model and pass in the linkId
+        Map jsModel = ClickUtils.createTemplateModel(this, context);
+        jsModel.put("linkId", '#' + link.getId());
+
+        String content = context.renderTemplate("/general/page-head-demo.js", jsModel);
+
+        getHeadElements().add(new JsScript(content));
+    }
+}

Modified: incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml?rev=757950&r1=757949&r2=757950&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml Tue Mar 24 18:48:56 2009
@@ -63,6 +63,9 @@
     <menu label="Page Flow Patterns" path="pageflow/start-page.htm"/>
     <menu label="Wizard Demo" path="wizard/wizard.htm"/>
     <menu separator="true"/>
+    <menu label="Page Head Demo" path="general/page-head-demo.htm"/>
+    <menu label="Control Head Demo" path="general/control-head-demo.htm"/>
+    <menu separator="true"/>
     <menu label="Velocity Macro" path="velocity/velocity-macro.htm"/>
     <menu label="Velocity Simple Table" path="velocity/simple-table.htm"/>
     <menu label="Velocity Action Table" path="velocity/action-table.htm"/>