You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/04/01 16:32:22 UTC
svn commit: r390674 [2/2] - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/ajax/api/
core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/
core/src/main/java/org/apache/myfaces/custom/suggestajax/ core/src/mai...
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js?rev=390674&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js Sat Apr 1 06:32:18 2006
@@ -0,0 +1,450 @@
+/**
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+org_apache_myfaces_TableSuggest = function()
+{
+ this.tablePagesCollection = new dojo.collections.ArrayList();
+
+ this.inputField = null;
+ this.popUp = null;
+
+ this.firstHighlightedElem = null;
+ this.actualHighlightedElem = null;
+
+ this.iframe = null;
+ this.requestLocker = false;
+
+ this.lastKeyPressTime = new Date();
+ this.scrollingRow = 0;
+
+ //puting the values from the choosen row into the fields
+ org_apache_myfaces_TableSuggest.prototype.putValueToField = function(trElem)
+ {
+ if (trElem)
+ {
+ this.scrollOverflowDiv(trElem);
+
+ for (j = 0; j < trElem.childNodes.length; j++)
+ {
+ var tdElem = trElem.childNodes[j];
+
+ for (a = 0; a < tdElem.childNodes.length; a++)
+ {
+ var spanElem = tdElem.childNodes[a];
+
+ if (spanElem.id)
+ {
+ var idToPutValue = spanElem.id.substr(10);
+ var elemToPutValue = dojo.byId(idToPutValue);
+
+ if (elemToPutValue)
+ {
+ if (dojo.dom.getTagName(elemToPutValue) == "input")
+ {
+ elemToPutValue.value = spanElem.innerHTML;
+ if (elemToPutValue.onchange)
+ {
+ elemToPutValue.onchange();
+ }
+ }
+ else if (dojo.dom.getTagName(elemToPutValue) == "select")
+ {
+ for (i = 0; i < elemToPutValue.options.length; i++)
+ {
+ var optionValue = spanElem.innerHTML;
+
+ if (elemToPutValue.options[i].value == optionValue)
+ elemToPutValue.options[i].selected = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.scrollOverflowDiv = function(trElem)
+ {
+ if(this.popUp.style.overflow == "auto")
+ {
+ var popUpStyleHeight = this.popUp.style.height;
+ var popUpHeight = dojo.style.getOuterHeight(this.popUp);
+ var popUpContentHeight = dojo.style.getOuterHeight(this.popUp.childNodes[0]);
+
+ if(popUpStyleHeight != "" && popUpContentHeight > popUpHeight)
+ {
+ var prevElem = dojo.dom.prevElement(trElem);
+
+ if (prevElem)
+ {
+ this.scrollingRow++;
+
+ if (this.scrollingRow >= 4)
+ {
+ var prevYPos = dojo.html.getScrollTop();
+ window.location.href = "#" + prevElem.id;
+ var currentYPos = dojo.html.getScrollTop();
+ //smoothScroll(prevYPos, currentYPos);
+ this.inputField.focus();
+ }
+ }
+ }
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.smoothYScroll = function(prevYPos,currentYPos)
+ {
+ var yDiff = prevYPos-currentYPos;
+
+ while(yDiff < 0){
+ window.scrollBy(0,-50);
+ dojo.lang.setTimeout('org_apache_myfaces_TableSuggest.prototype.smoothYScroll('+prevYPos+','+currentYPos+')',1000);
+ yDiff = yDiff+50;
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.handleRequestResponse = function(url, tableSuggest, keyCode)
+ {
+
+ if(keyCode == 40) //down key
+ {
+ if(!this.firstHighlightedElem)
+ {
+ var firstOptionElem = this.getFirstRowElem(this.popUp);
+ this.putValueToField(firstOptionElem);
+ this.addHoverClass(firstOptionElem);
+ this.firstHighlightedElem = firstOptionElem;
+ this.actualHighlightedElem = firstOptionElem;
+ }
+ else
+ {
+ var nextElem = dojo.dom.nextElement(this.actualHighlightedElem);
+
+ if(nextElem)
+ {
+ if(dojo.dom.getTagName(nextElem) == "tr")
+ {
+ this.putValueToField(nextElem);
+ this.addOutClass(this.actualHighlightedElem);
+ this.addHoverClass(nextElem);
+ this.actualHighlightedElem = nextElem
+ }
+ }
+ else
+ {
+ var table = dojo.html.getFirstAncestorByTag(this.actualHighlightedElem,"table");
+ var pageField = dojo.dom.nextElement(table);
+
+ if(pageField)
+ {
+ if(dojo.dom.getTagName(pageField) == "div")
+ {
+ this.nextPage(pageField);
+ this.firstHighlightedElem = this.getFirstRowElem(this.popUp);
+ this.putValueToField(this.firstHighlightedElem);
+ this.addOutClass(this.actualHighlightedElem);
+ this.addHoverClass(this.firstHighlightedElem);
+ this.actualHighlightedElem = this.firstHighlightedElem;
+ }
+ }
+ else
+ dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
+ }
+ }
+ }
+ else if(keyCode == 38) //up key
+ {
+ var prevElem = dojo.dom.prevElement(this.actualHighlightedElem);
+
+ if(prevElem)
+ {
+ if(dojo.dom.getTagName(prevElem) == "tr")
+ {
+ this.putValueToField(prevElem);
+ this.addOutClass(this.actualHighlightedElem);
+ this.addHoverClass(prevElem);
+ this.actualHighlightedElem = prevElem;
+ }
+ }
+ else
+ {
+ var table = dojo.html.getFirstAncestorByTag(this.actualHighlightedElem,"table");
+
+ if(table)
+ {
+ this.previousPage(table);
+ this.addOutClass(this.actualHighlightedElem);
+ this.actualHighlightedElem = this.getLastRowElem(this.popUp);
+ this.putValueToField(this.actualHighlightedElem);
+ this.addHoverClass(this.actualHighlightedElem);
+ }
+ else
+ dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
+ }
+ }
+ else
+ {
+ this.firstHighlightedElem = null;
+ this.actualHighlightedElem = null;
+
+ dojo.io.bind
+ ({
+ url: url,
+ handle: function(type, data, evt)
+ {
+ dojo.debug("after response");
+ //if(data) dojo.debug(data);
+
+ if(type == "load" && data)
+ {
+ dojo.debug("response successful");
+ var tablePagesArray = dojo.html.createNodesFromText(data);
+ var collection = tableSuggest.tablePagesCollection;
+
+ var firstPage = null;
+ var firstPageField = null;
+
+ dojo.dom.removeChildren(tableSuggest.popUp);
+
+ collection.clear();
+
+ for(k=0;k<tablePagesArray.length;k++)
+ {
+ if(k==0)
+ {
+ firstPage = tablePagesArray[k];
+ firstPageField = tablePagesArray[k+1];
+ dojo.dom.insertAtPosition(firstPage, tableSuggest.popUp, "first");
+ dojo.dom.insertAtPosition(firstPageField, tableSuggest.popUp, "last");
+ k++;
+
+ if(firstPage.rows && firstPage.rows.length == 2) {
+ var row = firstPage.rows[1];
+ tableSuggest.putValueToField(row);
+ }
+ }
+ else
+ {
+ collection.add(tablePagesArray[k]);
+ }
+ }
+
+ tableSuggest.handleIFrame();
+ }
+ else if(type == "error")
+ {
+ dojo.debug("error during response");
+ //dojo.debug(data);
+ // here, data is our error object
+ }
+ },
+ mimetype: "text/plain"
+ });
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.nextPage = function(thisPageField)
+ {
+ var collLength = this.tablePagesCollection.count;
+
+ if (collLength && collLength > 0)
+ {
+ var nextPage = this.tablePagesCollection.item(0);
+ var nextPageField = this.tablePagesCollection.item(1);
+
+ this.tablePagesCollection.removeAt(0);
+ this.tablePagesCollection.removeAt(0);
+
+ var thisPage = dojo.dom.prevElement(thisPageField);
+
+ dojo.dom.removeChildren(this.popUp);
+
+ dojo.dom.insertAtPosition(nextPage, this.popUp, "first");
+ dojo.dom.insertAtPosition(nextPageField, this.popUp, "last");
+
+ this.tablePagesCollection.add(thisPage);
+ this.tablePagesCollection.add(thisPageField);
+
+ this.handleIFrame();
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.previousPage = function(thisPage)
+ {
+ var collLength = this.tablePagesCollection.count;
+
+ if (collLength && collLength > 0)
+ {
+ var prevPageField = this.tablePagesCollection.item(collLength - 1);
+ var prevPage = this.tablePagesCollection.item(collLength - 2);
+
+ this.tablePagesCollection.removeAt(collLength - 1);
+ this.tablePagesCollection.removeAt(collLength - 2);
+
+ var thisPageField = dojo.dom.nextElement(thisPage);
+ this.tablePagesCollection.insert(0, thisPageField);
+ this.tablePagesCollection.insert(0, thisPage);
+
+ dojo.dom.removeChildren(this.popUp);
+ dojo.dom.insertAtPosition(prevPage, this.popUp, "first");
+ dojo.dom.insertAtPosition(prevPageField, this.popUp, "last");
+
+ this.handleIFrame();
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.getFirstRowElem = function()
+ {
+ var table = dojo.dom.firstElement(this.popUp);
+ if (table) {
+ var tbody = table.childNodes[1];
+ var firstRowElem = dojo.dom.firstElement(tbody);
+ return firstRowElem;
+ } else return null;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.getLastRowElem = function()
+ {
+ var table = dojo.dom.firstElement(this.popUp);
+ if(table) {
+ var tbody = table.childNodes[1];
+ var lastRowElem = dojo.dom.lastElement(tbody);
+ return lastRowElem;
+ } else return null;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.addHoverClass = function(elem)
+ {
+ dojo.html.removeClass(elem,"tableSuggestOut");
+ dojo.html.addClass(elem,"tableSuggestHover");
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.addOutClass = function(elem)
+ {
+ dojo.html.removeClass(elem,"tableSuggestHover");
+ dojo.html.addClass(elem,"tableSuggestOut");
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.requestBetweenKeyUpEvents = function(millisBetweenKeyPress)
+ {
+ var currentTime = new Date();
+
+ if( (currentTime - this.lastKeyPressTime) > millisBetweenKeyPress)
+ {
+ dojo.debug(currentTime - this.lastKeyPressTime);
+ this.lastKeyPressTime = currentTime;
+ return true;
+ }
+ else
+ {
+ dojo.debug(currentTime - this.lastKeyPressTime);
+ this.lastKeyPressTime = currentTime;
+ return false;
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.handleIFrame = function()
+ {
+ if (dojo.render.html.ie)
+ {
+ if (!this.iframe)
+ {
+ this.iframe = document.createElement("<iframe>");
+ this.iframe.frameborder = '0';
+ this.iframe.src = 'about:blank';
+ var s = this.iframe.style;
+ s.position = "absolute";
+ s.zIndex = 2;
+ var popUpParent = this.popUp.parentNode;
+ dojo.dom.insertAtPosition(this.iframe, popUpParent, "first");
+ }
+
+ var popUpStyleHeight = this.popUp.style.height;
+ var popUpHeight = dojo.style.getOuterHeight(this.popUp);
+ var popUpContentHeight = dojo.style.getOuterHeight(this.popUp.childNodes[0]);
+ var popUpContentWidth = dojo.style.getOuterWidth(this.popUp.childNodes[0]);
+
+ if(popUpStyleHeight == "" || popUpHeight < popUpContentHeight)
+ this.iframe.style.height = popUpHeight;
+ else
+ this.iframe.style.height = popUpContentHeight;
+
+ if(popUpStyleHeight != "" && popUpContentHeight > popUpHeight)
+ this.iframe.style.width = popUpContentWidth+13;
+ else
+ this.iframe.style.width = popUpContentWidth;
+ }
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.lastKeyUpEvent = function()
+ {
+ //dojo.lang.setTimeout('',4000);
+ var currentTime = new Date();
+ dojo.debug("last keyUpEvent?");
+ dojo.debug(currentTime - this.lastKeyPressTime);
+ if( (currentTime - this.lastKeyPressTime) > 250)
+ {
+ dojo.debug("was last keyUpEvent");
+ return true;
+ }
+ else return false;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.resetSettings = function()
+ {
+ if(this.popUp)
+ dojo.dom.removeChildren(this.popUp);
+
+ if(this.iframe && this.popUp)
+ this.popUp.parentNode.removeChild(this.popUp.parentNode.childNodes[0])
+
+ this.firstHighlightedElem = null;
+ this.actualHighlightedElem = null;
+ this.iframe = null;
+ this.requestLocker = false;
+ this.scrollingRow = 0;
+ };
+
+ org_apache_myfaces_TableSuggest.prototype.decideRequest = function(clientId, tableSuggest, ajaxUrl,
+ millisBetweenKeyUps, startChars, event)
+ {
+ if( !this.requestLocker && (this.requestBetweenKeyUpEvents(millisBetweenKeyUps) || this.lastKeyUpEvent()) )
+ {
+ this.requestLocker = true;
+
+ this.inputField = dojo.byId(clientId);
+ this.popUp = dojo.byId(clientId+"_auto_complete");
+ var inputValue = this.inputField.value;
+ var url = ajaxUrl + inputValue;
+
+ if(startChars)
+ {
+ if(inputValue.length >= startChars)
+ this.handleRequestResponse(url, tableSuggest, event.keyCode);
+ }
+ else if(inputValue != "" )
+ this.handleRequestResponse(url, tableSuggest, event.keyCode);
+
+ if(inputValue == "" )
+ this.resetSettings();
+
+ this.requestLocker = false;
+ }
+ };
+
+}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/input_suggest_ajax_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/input_suggest_ajax_attributes.xml?rev=390674&r1=390673&r2=390674&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/input_suggest_ajax_attributes.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/input_suggest_ajax_attributes.xml Sat Apr 1 06:32:18 2006
@@ -1,102 +1,4 @@
<attribute>
- <name>suggestedItemsMethod</name>
- <required>true</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>Reference to the method which returns the suggested items</description>
-</attribute>
-
-<attribute>
- <name>maxSuggestedItems</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>optional attribute to identify the max size of suggested Values</description>
-</attribute>
-
-<attribute>
- <name>delay</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>The AJAX Request is triggered after a given delay. In milliseconds.</description>
-</attribute>
-
-<attribute>
- <name>startRequest</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>The AJAX Request is only triggered if the number of chars typed in is
- equal or greater than this given value.
- </description>
-</attribute>
-
-<attribute>
- <name>layout</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description></description>
-</attribute>
-
-<attribute>
- <name>popupStyle</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>Style for the window with a suggested list of items;pop up for each incoming Ajax response</description>
-</attribute>
-
-<attribute>
- <name>popupStyleClass</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>StyleClass for the window with a suggested list of items;pop up for each incoming Ajax response</description>
-</attribute>
-
-<attribute>
- <name>tableStyleClass</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>StyleClass for the suggested table.</description>
-</attribute>
-
-<attribute>
- <name>nextPageFieldClass</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>StyleClass for the div field which steps to next page</description>
-</attribute>
-
-<attribute>
- <name>columnHoverClass</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>StyleClass for a onmouseover event of the suggested columns</description>
-</attribute>
-
-<attribute>
- <name>columnOutClass</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>StyleClass for a onmouseout event of the suggested columns</description>
-</attribute>
-
-<attribute>
- <name>popupId</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>Id for the pop up window</description>
-</attribute>
-
-<attribute>
<name>listId</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
@@ -135,14 +37,3 @@
<type>java.lang.String</type>
<description>Id for the pop up window</description>
</attribute>
-
-<attribute>
- <name>var</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>Same principle as it is in dataTable. SuggestedItemsMethod returns
- a list of objects, where the variables can be accessed with the alias after the
- dot of the var.
- </description>
-</attribute>
\ No newline at end of file
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/suggest_ajax_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/suggest_ajax_attributes.xml?rev=390674&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/suggest_ajax_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/suggest_ajax_attributes.xml Sat Apr 1 06:32:18 2006
@@ -0,0 +1,54 @@
+&standard_input_text_attributes;
+&ext_forceId_attribute;
+&alt_location_attributes;
+&html_input_suggest_attributes;
+&display_value_only_attributes;
+&user_role_attributes;
+
+<attribute>
+ <name>suggestedItemsMethod</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Reference to the method which returns the suggested items</description>
+</attribute>
+
+<attribute>
+ <name>maxSuggestedItems</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>optional attribute to identify the max size of suggested Values</description>
+</attribute>
+
+<attribute>
+ <name>layout</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description></description>
+</attribute>
+
+<attribute>
+ <name>popupStyle</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Style for the window with a suggested list of items;pop up for each incoming Ajax response</description>
+</attribute>
+
+<attribute>
+ <name>popupStyleClass</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>StyleClass for the window with a suggested list of items;pop up for each incoming Ajax response</description>
+</attribute>
+
+<attribute>
+ <name>popupId</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Id for the pop up window</description>
+</attribute>
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml?rev=390674&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/table_suggest_ajax_attributes.xml Sat Apr 1 06:32:18 2006
@@ -0,0 +1,62 @@
+<attribute>
+ <name>betweenKeyUp</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>If the time between two keyup events is lower than this given value,
+ the ajax request will not be fired. In milliseconds. Prevents stressing the server with too much user inputs
+ </description>
+</attribute>
+
+<attribute>
+ <name>startRequest</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>The AJAX Request is only triggered if the number of chars typed in is
+ equal or greater than this given value.
+ </description>
+</attribute>
+
+<attribute>
+ <name>tableStyleClass</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>StyleClass for the suggested table.</description>
+</attribute>
+
+<attribute>
+ <name>nextPageFieldClass</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>StyleClass for the div field which steps to next page</description>
+</attribute>
+
+<attribute>
+ <name>columnHoverClass</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>StyleClass for a onmouseover event of the suggested columns</description>
+</attribute>
+
+<attribute>
+ <name>columnOutClass</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>StyleClass for a onmouseout event of the suggested columns</description>
+</attribute>
+
+<attribute>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Same principle as it can be found in dataTable. SuggestedItemsMethod returns
+ a list of objects, where the class variables can be accessed with the alias after the
+ dot of the var.
+ </description>
+</attribute>
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=390674&r1=390673&r2=390674&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Sat Apr 1 06:32:18 2006
@@ -124,6 +124,8 @@
<!ENTITY html_script_attributes SYSTEM "entities/html_script_attributes.xml">
<!ENTITY ui_state_changed_notifier_attributes SYSTEM "entities/ui_state_changed_notifier_attributes.xml">
<!ENTITY input_suggest_ajax_attributes SYSTEM "entities/input_suggest_ajax_attributes.xml">
+<!ENTITY table_suggest_ajax_attributes SYSTEM "entities/table_suggest_ajax_attributes.xml">
+<!ENTITY suggest_ajax_attributes SYSTEM "entities/suggest_ajax_attributes.xml">
]>
<taglib>
@@ -197,19 +199,26 @@
<!-- inputsuggestajax -->
<tag>
<name>inputSuggestAjax</name>
- <tag-class>org.apache.myfaces.custom.inputsuggestajax.InputSuggestAjaxTag</tag-class>
+ <tag-class>org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjaxTag</tag-class>
<body-content>JSP</body-content>
- <description>Provides an input textbox with "suggest" functionality, using a remote connection to the server. The difference to inputSuggest is that a custom drop down is rendered.</description>
- &standard_input_text_attributes;
- &ext_forceId_attribute;
- &alt_location_attributes;
- &html_input_suggest_attributes;
- &display_value_only_attributes;
- &user_role_attributes;
+ <description>Provides an input textbox with "suggest" functionality, using an ajax request
+ to the server.</description>
&input_suggest_ajax_attributes;
+ &suggest_ajax_attributes;
+ </tag>
+
+ <!-- tablesuggestajax -->
+ <tag>
+ <name>tableSuggestAjax</name>
+ <tag-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.TableSuggestAjaxTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>Provides an input textbox with "suggest" functionality, using an ajax request
+ to the server. The popUp contains a table where each column value can be set to a specific dom node (through dom node id).</description>
+ &table_suggest_ajax_attributes;
+ &suggest_ajax_attributes;
</tag>
- <!-- focus -->
+ <!-- focus -->
<tag>
<name>focus</name>
<tag-class>org.apache.myfaces.custom.focus.HtmlFocusTag</tag-class>
@@ -933,7 +942,7 @@
<tag>
<name>outputText</name>
- <tag-class>org.apache.myfaces.custom.inputsuggestajax.HtmlOutputTextTag</tag-class>
+ <tag-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.HtmlOutputTextTag</tag-class>
<body-content>JSP</body-content>
<display-name>outputText component</display-name>
<description>Extending the outputText component in order to introduce the for attribute.</description>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java?rev=390674&r1=390673&r2=390674&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/Address.java Sat Apr 1 06:32:18 2006
@@ -21,12 +21,14 @@
String city,
long zip,String state)
{
- _streetNumber = streetNumber;
+ _streetNumber = streetNumber;
_streetName = streetName;
_city = city;
_state = state;
_zip = zip;
}
+
+
public int getStreetNumber()
{
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java?rev=390674&r1=390673&r2=390674&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputSuggestAjax/InputSuggestAjaxBean.java Sat Apr 1 06:32:18 2006
@@ -27,6 +27,8 @@
*/
public class InputSuggestAjaxBean
{
+ private String suggestValue = null;
+
public List getAddressList(String cityFragment)
{
List addressList = new ArrayList();
@@ -45,30 +47,38 @@
{
List addressList = new ArrayList();
- addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
- addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
- addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
- addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
- addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
- addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
- addressList.add(new Address(11,"noname",cityFragment+"max",15,"KL"));
- addressList.add(new Address(12,"max",cityFragment+"nomax",14,"SJ"));
- addressList.add(new Address(13,"phil",cityFragment+"detroit",13,"NW"));
- addressList.add(new Address(14,"new",cityFragment+"LA",12,"IL"));
- addressList.add(new Address(15,"san",cityFragment+"san",11,"NY"));
- addressList.add(new Address(16,"san",cityFragment+"muster",16,"MH"));
- addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
- addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
- addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
- addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
- addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
- addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
- addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
- addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
- addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
- addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
- addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
- addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
+ if (cityFragment.startsWith("as"))
+ {
+ addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
+ addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
+ addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
+ addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
+ addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
+ addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
+ addressList.add(new Address(11,"noname",cityFragment+"max",15,"KL"));
+ addressList.add(new Address(12,"max",cityFragment+"nomax",14,"SJ"));
+ addressList.add(new Address(13,"phil",cityFragment+"detroit",13,"NW"));
+ addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
+ addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
+ addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
+ addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
+ addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
+ addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
+ addressList.add(new Address(11,"noname",cityFragment+"max",15,"KL"));
+ addressList.add(new Address(12,"max",cityFragment+"nomax",14,"SJ"));
+ addressList.add(new Address(13,"phil",cityFragment+"detroit",13,"NW"));
+ }
+ else
+ {
+ addressList.add(new Address(11,"noname",cityFragment+"nocity",15,"KL"));
+ addressList.add(new Address(12,"max",cityFragment+"muster",14,"SJ"));
+ addressList.add(new Address(13,"phil",cityFragment+"philadelphia",13,"NW"));
+ addressList.add(new Address(14,"new",cityFragment+"new york",12,"IL"));
+ addressList.add(new Address(15,"san",cityFragment+"san francisco",11,"NY"));
+ addressList.add(new Address(16,"san",cityFragment+"san diego",16,"MH"));
+ addressList.add(new Address(11,"noname",cityFragment+"max",15,"KL"));
+ addressList.add(new Address(12,"max",cityFragment+"nomax",14,"SJ"));
+ }
return addressList;
}
@@ -94,5 +104,15 @@
}
return li;
+ }
+
+ public String getSuggestValue()
+ {
+ return suggestValue;
+ }
+
+ public void setSuggestValue(String suggestValue)
+ {
+ this.suggestValue = suggestValue;
}
}
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=390674&r1=390673&r2=390674&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Sat Apr 1 06:32:18 2006
@@ -48,9 +48,10 @@
<h:outputText value="Input Suggest"/>
<h:panelGrid style="padding-left:25px">
- <h:outputLink value="inputSuggestAjax.jsf" ><f:verbatim>InputSuggestAjax (with tableSuggest feature)</f:verbatim></h:outputLink>
- <h:outputLink value="inputAjax.jsf" ><f:verbatim>AJAX Form Components - server side validation through ajax </f:verbatim></h:outputLink>
- <h:outputLink value="inputSuggest.jsf" ><f:verbatim>Input Suggest</f:verbatim></h:outputLink>
+ <h:outputLink value="inputSuggestAjax.jsf" ><f:verbatim>InputSuggestAjax - Suggested items list through Ajax</f:verbatim></h:outputLink>
+ <h:outputLink value="tableSuggestAjax.jsf" ><f:verbatim>TableSuggestAjax - Suggested table through Ajax (choosing a row puts column values to specific dom nodes) </f:verbatim></h:outputLink>
+ <h:outputLink value="inputAjax.jsf" ><f:verbatim>AJAX Form Components - server side validation through ajax </f:verbatim></h:outputLink>
+ <h:outputLink value="inputSuggest.jsf" ><f:verbatim>Input Suggest - Suggest without Ajax</f:verbatim></h:outputLink>
</h:panelGrid>
<h:outputText value="Schedule"/>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp?rev=390674&r1=390673&r2=390674&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputSuggestAjax.jsp Sat Apr 1 06:32:18 2006
@@ -30,104 +30,20 @@
<f:view>
- <s:dojoInitializer require="dojo.widget.Editor" debug="true"/>
- <s:dojoInitializer require="dojo.widget.DebugConsole" />
- <s:dojoInitializer require="dojo.widget.ResizeHandle" />
-
<h:form>
<f:verbatim><br/><br/></f:verbatim>
- <h:panelGrid columns="4">
+ <h:panelGrid columns="5">
<h:outputText value="default suggest"/>
- <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}"/>
+ <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}" value="#{inputSuggestAjax.suggestValue}"/>
<h:outputText value="suggest with limited suggested items"/>
- <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}" maxSuggestedItems="2" />
- </h:panelGrid>
- <f:verbatim><br/><br/><br/></f:verbatim>
- <h:panelGrid columns="2">
- <h:panelGrid columns="6">
- <f:verbatim> City Field TableSuggest <br/> (Paginator) </f:verbatim>
- <s:inputSuggestAjax var="address" id="cityField" startRequest="2"
- nextPageFieldClass="ajaxNextTablePageField"
- columnOutClass="tableSuggestOut" columnHoverClass="tableSuggestHover"
- suggestedItemsMethod="#{inputSuggestAjax.getAddressList}"
- maxSuggestedItems="10" tableStyleClass="ajaxTable">
- <t:column>
- <f:facet name="header">
- <s:outputText value="city"/>
- </f:facet>
- <s:outputText for="cityField" label="#{address.city}"/>
- </t:column>
- <t:column>
- <f:facet name="header">
- <s:outputText value="street"/>
- </f:facet>
- <s:outputText for="streetNameField" label="#{address.streetName}"/>
- </t:column>
- <t:column>
- <f:facet name="header">
- <s:outputText value="state"/>
- </f:facet>
- <s:outputText forValue="stateField" label="#{address.state}" value="#{address.zip}"/>
- </t:column>
- </s:inputSuggestAjax>
- <f:verbatim> City Field TableSuggest <br/> (Scrolling) </f:verbatim>
- <s:inputSuggestAjax var="address" id="cityField2" tableStyleClass="ajaxTable"
- columnOutClass="tableSuggestOut" columnHoverClass="tableSuggestHover"
- maxSuggestedItems="50" popupStyle="overflow:auto;height:200px;"
- suggestedItemsMethod="#{inputSuggestAjax.getAddressList}">
- <t:column>
- <s:outputText for="cityField2" label="#{address.city}"/>
- </t:column>
- <t:column>
- <s:outputText for="streetNameField" label="#{address.streetName}"/>
- </t:column>
- <t:column>
- <s:outputText forValue="stateField" label="#{address.state}" value="#{address.zip}"/>
- </t:column>
- </s:inputSuggestAjax>
- <f:verbatim> City Field TableSuggest <br/> (Default) </f:verbatim>
- <s:inputSuggestAjax var="address" id="cityField1" tableStyleClass="ajaxTable"
- columnOutClass="tableSuggestOut" columnHoverClass="tableSuggestHover"
- suggestedItemsMethod="#{inputSuggestAjax.getAddressList}">
- <t:column>
- <f:facet name="header">
- <s:outputText value="city"/>
- </f:facet>
- <s:outputText for="cityField1" label="#{address.city}"/>
- </t:column>
- <t:column>
- <f:facet name="header">
- <s:outputText value="street"/>
- </f:facet>
- <s:outputText for="streetNameField" label="#{address.streetName}"/>
- </t:column>
- <t:column>
- <f:facet name="header">
- <s:outputText value="state"/>
- </f:facet>
- <s:outputText forValue="stateField" label="#{address.state}" value="#{address.zip}"/>
- </t:column>
- </s:inputSuggestAjax>
- </h:panelGrid>
- <h:panelGrid>
- <h:outputText value="Street"/>
- <t:inputText id="streetNameField" />
- <h:outputText value="State"/>
- <t:selectOneMenu id="stateField">
- <f:selectItem value="" itemLabel="NY" itemValue="11"/>
- <f:selectItem value="" itemLabel="IL" itemValue="12"/>
- <f:selectItem value="" itemLabel="NW" itemValue="13"/>
- <f:selectItem value="" itemLabel="SJ" itemValue="14"/>
- <f:selectItem value="" itemLabel="KL" itemValue="15"/>
- <f:selectItem value="" itemLabel="MH" itemValue="16"/>
- </t:selectOneMenu>
- </h:panelGrid>
+ <s:inputSuggestAjax suggestedItemsMethod="#{inputSuggestAjax.getItems}" maxSuggestedItems="2" />
+
+ <h:commandButton/>
</h:panelGrid>
- <f:verbatim><br/><br/><br/><br/><br/></f:verbatim>
- <s:dojoInitializer debugConsole="true"/>
+
</h:form>
</f:view>
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp?rev=390674&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/tableSuggestAjax.jsp Sat Apr 1 06:32:18 2006
@@ -0,0 +1,108 @@
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
+
+<html>
+
+<%@include file="inc/head.inc" %>
+
+<!--
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+//-->
+
+<body>
+
+<f:view>
+
+ <h:form>
+
+ <f:verbatim><br/><br/><br/><br/></f:verbatim>
+
+ <h:panelGrid columns="2">
+ <h:panelGrid columns="4">
+ <f:verbatim> City Field TableSuggest <br/> (Paginator) <br/> Suggest starts with 2. char </f:verbatim>
+ <s:tableSuggestAjax var="address" id="cityField" startRequest="2"
+ nextPageFieldClass="ajaxNextTablePageField"
+ value="#{inputSuggestAjax.suggestValue}"
+ columnOutClass="tableSuggestOut" columnHoverClass="tableSuggestHover"
+ suggestedItemsMethod="#{inputSuggestAjax.getAddressList}"
+ maxSuggestedItems="10" tableStyleClass="ajaxTable">
+ <t:column>
+ <f:facet name="header">
+ <s:outputText value="city"/>
+ </f:facet>
+ <s:outputText for="cityField" label="#{address.city}"/>
+ </t:column>
+ <t:column>
+ <f:facet name="header">
+ <s:outputText value="street"/>
+ </f:facet>
+ <s:outputText for="streetNameField" label="#{address.streetName}"/>
+ </t:column>
+ <t:column>
+ <f:facet name="header">
+ <s:outputText value="state"/>
+ </f:facet>
+ <s:outputText forValue="stateField" label="#{address.state}" value="#{address.zip}"/>
+ </t:column>
+ </s:tableSuggestAjax>
+ <f:verbatim> City Field TableSuggest <br/> (Scrolling) <br/> If first chars are "as" scrolling list appears </f:verbatim>
+ <s:tableSuggestAjax var="address" id="cityField2" tableStyleClass="ajaxTable"
+ nextPageFieldClass="ajaxNextTablePageField"
+ columnOutClass="tableSuggestOut" columnHoverClass="tableSuggestHover"
+ maxSuggestedItems="50" popupStyle="position:absolute; z-index:100000; overflow:auto;height:200px;"
+ suggestedItemsMethod="#{inputSuggestAjax.getAddressList}">
+ <t:column>
+ <s:outputText for="cityField2" label="#{address.city}"/>
+ </t:column>
+ <t:column>
+ <s:outputText for="streetNameField" label="#{address.streetName}"/>
+ </t:column>
+ <t:column>
+ <s:outputText forValue="stateField" label="#{address.state}" value="#{address.zip}"/>
+ </t:column>
+ </s:tableSuggestAjax>
+ </h:panelGrid>
+ <h:panelGrid>
+ <h:commandButton/>
+ <h:outputText value="Street"/>
+ <t:inputText id="streetNameField" />
+ <h:outputText value="State"/>
+ <t:selectOneMenu id="stateField">
+ <f:selectItem value="" itemLabel="NY" itemValue="11"/>
+ <f:selectItem value="" itemLabel="IL" itemValue="12"/>
+ <f:selectItem value="" itemLabel="NW" itemValue="13"/>
+ <f:selectItem value="" itemLabel="SJ" itemValue="14"/>
+ <f:selectItem value="" itemLabel="KL" itemValue="15"/>
+ <f:selectItem value="" itemLabel="MH" itemValue="16"/>
+ </t:selectOneMenu>
+ </h:panelGrid>
+ </h:panelGrid>
+ <f:verbatim><br/><br/><br/><br/><br/></f:verbatim>
+ <s:dojoInitializer debugConsole="true"/>
+ </h:form>
+
+</f:view>
+
+<%@include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>
+