You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/05/04 21:49:53 UTC

svn commit: r399841 - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/ajaxchildcombobox/ resources-facesconfig/META-INF/ resources/org/apache/myfaces/custom/ajaxchildcombobox/ resources/org/apache/myfaces/custom/ajaxchi...

Author: imario
Date: Thu May  4 12:49:51 2006
New Revision: 399841

URL: http://svn.apache.org/viewcvs?rev=399841&view=rev
Log:
TOMAHAWK-408: very nice stuff, thanks to sharath reddy for this component.

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js   (with props)
Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java?rev=399841&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java Thu May  4 12:49:51 2006
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004-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.
+ */
+package org.apache.myfaces.custom.ajaxchildcombobox;
+
+import org.apache.myfaces.custom.ajax.api.AjaxComponent;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import javax.faces.component.html.HtmlSelectOneMenu;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+
+/**
+ * This component is to be used in conjunction with a regular combo box or list box. 
+ * When the selected value of the latter changes, it executes an ajax call to the 
+ * specified method to refresh its contents based on the new selected value. 
+ * 
+ * @author Sharath Reddy
+ */
+public class AjaxChildComboBox extends HtmlSelectOneMenu implements AjaxComponent
+{
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.AjaxChildComboBox";
+    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.AjaxChildComboBox";
+        
+    private MethodBinding _ajaxSelectItemsMethod;
+    //This is not a 'Parent' in terms of the component heirarchy; This is the component 
+    //whose 'onchange' event triggers a refresh.
+    private String _parentComboBox;
+
+    public AjaxChildComboBox()
+    {
+        super();
+        setRendererType(AjaxChildComboBox.DEFAULT_RENDERER_TYPE);
+    }
+
+    public Object saveState(FacesContext context)
+    {
+        Object[] values = new Object[3];
+        values[0] = super.saveState(context);
+        values[1] = saveAttachedState(context, _ajaxSelectItemsMethod);
+        values[2] = _parentComboBox;
+        return values;
+    }
+
+    public void restoreState(FacesContext context, Object state)
+    {
+        Object values[] = (Object[])state;
+        super.restoreState(context, values[0]);
+        _ajaxSelectItemsMethod = (MethodBinding) restoreAttachedState(context, values[1]);
+        _parentComboBox = (String) values[2];
+    }
+    
+    public void encodeAjax(FacesContext context)
+            throws IOException
+    {
+        
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+        Renderer renderer = getRenderer(context);
+        if (renderer != null && renderer instanceof AjaxRenderer)
+        {
+            ((AjaxRenderer) renderer).encodeAjax(context, this);
+        }
+    }
+
+    public void decodeAjax(FacesContext context)
+    {
+        //Do Nothing
+    }
+
+    public void setAjaxSelectItemsMethod(MethodBinding ajaxSelectItemsMethod)
+    {
+       _ajaxSelectItemsMethod = ajaxSelectItemsMethod;
+    }
+
+    public MethodBinding getAjaxSelectItemsMethod()
+    {
+        return _ajaxSelectItemsMethod;
+    }
+    
+    public void setParentComboBox(String parentComboBox) 
+    {
+        this._parentComboBox = parentComboBox;
+    }
+    
+    public String getParentComboBox() 
+    {
+        return this._parentComboBox;
+    }
+    
+    /**
+     * We cannot verify that the result of converting the newly submitted value 
+     * is <i>equal</i> to the value property of one of the child SelectItem
+     * objects. This is because the contents of the child combo box could have 
+     * been reloaded by a change in the parent combo box. 
+     * 
+     * @see javax.faces.component.UIInput#validateValue(javax.faces.context.FacesContext, java.lang.Object)
+     */
+    protected void validateValue(FacesContext context, Object value)
+    {
+        return;
+      // selected value must match to one of the available options
+      /*  if (!_SelectItemsUtil.matchValue(context, value, new _SelectItemsIterator(this), converter))
+        {
+            _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID,
+                            new Object[] {getId()});
+            setValid(false);
+      }*/
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBox.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java?rev=399841&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java Thu May  4 12:49:51 2006
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2004-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.
+ */
+package org.apache.myfaces.custom.ajaxchildcombobox;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.taglib.html.ext.HtmlSelectOneMenuTag;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+/**
+ * JSP tag for AjaxChildComboBox component
+ * @author Sharath Reddy
+ */
+public class AjaxChildComboBoxTag extends HtmlSelectOneMenuTag
+{
+    private final static Class[] DEFAULT_SIGNATURE = new Class[]{String.class};
+  
+    private static Log log = LogFactory.getLog(AjaxChildComboBoxTag.class);
+
+    private String _parentComboBox;
+    private String _ajaxSelectItemsMethod;
+  
+    public String getComponentType() {
+        return AjaxChildComboBox.COMPONENT_TYPE;
+    }
+
+    public String getRendererType() {
+        return AjaxChildComboBox.DEFAULT_RENDERER_TYPE;
+    }
+
+    public void release() {
+        super.release();
+        _ajaxSelectItemsMethod = null;
+        _parentComboBox = null;
+    }
+
+    protected void setProperties(UIComponent component) {
+
+        super.setProperties(component);
+        AjaxChildComboBoxTag.setAjaxSelectItemsMethodProperty(getFacesContext(),
+        		component, _ajaxSelectItemsMethod);
+        setStringProperty(component, "parentComboBox", _parentComboBox);
+    }
+
+    public static void setAjaxSelectItemsMethodProperty(FacesContext context,
+                                                       UIComponent component,
+                                                       String ajaxSelectItemsMethod)
+    {
+                            
+        if (isValueReference(ajaxSelectItemsMethod))
+        {
+            MethodBinding mb = context.getApplication().
+                createMethodBinding(ajaxSelectItemsMethod, AjaxChildComboBoxTag.DEFAULT_SIGNATURE);
+            ((AjaxChildComboBox)component).setAjaxSelectItemsMethod(mb);
+        }
+        else
+        {
+            log.error("Invalid expression " + ajaxSelectItemsMethod);
+        }
+    }
+    
+    public void setAjaxSelectItemsMethod(String ajaxSelectItemsMethod)
+    {
+        _ajaxSelectItemsMethod = ajaxSelectItemsMethod;
+    }
+    
+    public void setParentComboBox(String parentComboBox) 
+    {
+        this._parentComboBox = parentComboBox;
+    }
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AjaxChildComboBoxTag.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java?rev=399841&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java Thu May  4 12:49:51 2006
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2004-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.
+ */
+package org.apache.myfaces.custom.ajaxchildcombobox;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.dojo.DojoConfig;
+import org.apache.myfaces.custom.dojo.DojoUtils;
+import org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.MethodBinding;
+import javax.faces.model.SelectItem;
+import javax.servlet.ServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * Renderer for component HtmlAjaxChildComboBox
+ * 
+ * @author Sharath Reddy
+ */
+public class HtmlAjaxChildComboBoxRenderer extends HtmlMenuRenderer implements AjaxRenderer
+{
+    private static final String BEGIN_OPTION = "<option>";
+    private static final String END_OPTION = "</option>";
+    private static final String BEGIN_OPTION_TEXT = "<optionText>";
+    private static final String END_OPTION_TEXT = "</optionText>";
+    private static final String BEGIN_OPTION_VALUE = "<optionValue>";
+    private static final String END_OPTION_VALUE = "</optionValue>";
+        
+    public static final int DEFAULT_MAX_SUGGESTED_ITEMS = 200;
+ 
+    private static Log log = LogFactory.getLog(HtmlAjaxChildComboBoxRenderer.class);
+    
+    // Adds the javascript files needed by Dojo and the custom javascript for
+	// this
+    // component
+    private void encodeJavascript(FacesContext context, UIComponent component)
+                                                                        throws IOException
+    {
+        String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+        DojoUtils.addMainInclude(context, component, javascriptLocation, new DojoConfig());
+        DojoUtils.addRequire(context, component, "dojo.event.*");
+        DojoUtils.addRequire(context, component, "dojo.io.bind");
+        
+        AddResource addResource = AddResourceFactory.getInstance(context);
+                
+        addResource.addJavaScriptAtPosition(context, 
+                AddResource.HEADER_BEGIN, AjaxChildComboBox.class, "javascript/ajaxChildComboBox.js");
+    }
+
+    public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+    {
+        RendererUtils.checkParamValidity(context, component, AjaxChildComboBox.class);
+        
+        AjaxChildComboBox childComboBox = (AjaxChildComboBox) component;
+        
+        super.encodeEnd(context, component);
+        
+        String clientId = component.getClientId(context);
+        String url = getActionUrl(context);
+        
+        UIComponent parentComboBox = this.getParentComboBox(childComboBox);
+        if (parentComboBox == null) 
+        {
+            log.error("Could not find parent combo box for AjaxChildComboBox " + 
+                    childComboBox.getClientId(context));
+            return;
+        }
+                
+        encodeJavascript(context,component);
+                        
+        ResponseWriter writer = context.getResponseWriter();
+        
+        // Begin: Write out the javascript that hooks up this component with the
+		// parent combo-box
+        writer.startElement(HTML.SCRIPT_ELEM, component);
+        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+        
+        writer.write("var parentCombo = document.getElementById('" + 
+                parentComboBox.getClientId(context) + "');");
+        HtmlRendererUtils.writePrettyLineSeparator(context);
+        writer.write("dojo.event.connect(parentCombo, 'onchange', function(evt) { ");
+        HtmlRendererUtils.writePrettyLineSeparator(context);
+        writer.write("var targetElement = evt.target;");
+        writer.write("var targetValue = targetElement.options[targetElement.selectedIndex].value;");
+        HtmlRendererUtils.writePrettyLineSeparator(context);
+        writer.write("reloadChildComboBox('" + url + "','" + clientId + "', targetValue);");
+        HtmlRendererUtils.writePrettyLineSeparator(context);
+        writer.write("});");
+        writer.endElement(HTML.SCRIPT_ELEM);
+        // End: Javascript
+    }
+                                                
+    
+    // creates the XML response that is sent back to the browser
+    public void encodeAjax(FacesContext context, UIComponent uiComponent)
+        throws IOException
+    {
+    	
+    	String parentValue = (String) context.getExternalContext().
+            getRequestParameterMap().get("parentValue");
+                
+        ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
+        PrintWriter writer = response.getWriter();
+              
+        StringBuffer xml = new StringBuffer();
+        
+        MethodBinding mb = ((AjaxChildComboBox) uiComponent).getAjaxSelectItemsMethod();
+        SelectItem [] options = (SelectItem[]) 
+            mb.invoke(context,new Object[]{ parentValue} );
+        
+        for (int i = 0; i < options.length; i++)
+        {
+            xml.append(BEGIN_OPTION);
+            xml.append(BEGIN_OPTION_TEXT).append(options[i].getLabel()).append(END_OPTION_TEXT);
+            xml.append(BEGIN_OPTION_VALUE).append(options[i].getValue()).append(END_OPTION_VALUE);
+            xml.append(END_OPTION);
+        }        
+    
+        writer.write(xml.toString());
+        
+    }
+    
+    private UIComponent getParentComboBox(AjaxChildComboBox comboBox) 
+    {
+        String parentId = comboBox.getParentComboBox();
+        
+        UIComponent parentComboBox = comboBox.findComponent(parentId);
+        if (parentComboBox != null) return parentComboBox;
+        
+        // try searching from the very root of the component tree
+        return comboBox.findComponent(UINamingContainer.SEPARATOR_CHAR + parentId);
+    }
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?rev=399841&r1=399840&r2=399841&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Thu May  4 12:49:51 2006
@@ -34,6 +34,11 @@
     <component-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.TableSuggestAjax</component-class>
   </component>
 
+  <component>
+    <component-type>org.apache.myfaces.AjaxChildComboBox</component-type>
+    <component-class>org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBox</component-class>
+  </component>
+
   <component>
 	<component-type>org.apache.myfaces.HtmlOutputTextFor</component-type>
 	<component-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.HtmlOutputText</component-class>
@@ -227,6 +232,12 @@
       <renderer-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.TableSuggestAjaxRenderer</renderer-class>
     </renderer>
 
+    <renderer>
+      <component-family>javax.faces.SelectOne</component-family>
+      <renderer-type>org.apache.myfaces.AjaxChildComboBox</renderer-type>
+      <renderer-class>org.apache.myfaces.custom.ajaxchildcombobox.HtmlAjaxChildComboBoxRenderer</renderer-class>
+    </renderer>
+
     <renderer>
       <component-family>javax.faces.Command</component-family>
       <renderer-type>org.apache.myfaces.CommandButtonAjax</renderer-type>

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js?rev=399841&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js Thu May  4 12:49:51 2006
@@ -0,0 +1,28 @@
+function reloadChildComboBox(url, componentId, parentValue) {
+    	
+    dojo.io.bind({
+        url: url,
+        content: {
+	    	affectedAjaxComponent: componentId,
+                parentValue: parentValue
+	    },
+        load: function(type, data, evt){ 
+            
+            var childCombo = document.getElementsByName(componentId)[0];
+            childCombo.options.length = 0;
+	    var data = data.getElementsByTagName('option');
+            for (i = 0; i < data.length; i++) {
+            	var label = data[i].childNodes[0].firstChild.nodeValue;
+                var value = data[i].childNodes[1].firstChild.nodeValue;
+                var option = new Option(label, value);    	       
+                try {
+                	childCombo.add(option,null);
+		} catch(e) {        
+			childCombo.add(option, -1);
+		}
+            }
+        },
+        mimetype: "text/xml"
+    });
+
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajaxchildcombobox/resource/javascript/ajaxChildComboBox.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=399841&r1=399840&r2=399841&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 Thu May  4 12:49:51 2006
@@ -212,6 +212,33 @@
         &suggest_ajax_attributes;
     </tag>
 
+    <!-- Ajax child combobox  -->
+    <tag>
+        <name>ajaxChildComboBox</name>
+        <tag-class>org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBoxTag</tag-class>
+        <body-content>JSP</body-content>
+        <description>
+            Refreshes contents through an ajax call when the parent combo box's value is changed 
+        </description>
+        &standard_select_one_listbox_attributes;
+        &ext_escape_attribute;
+        &user_role_attributes;
+        &ext_forceId_attribute;
+        &display_value_only_attributes;
+        <attribute>
+	    <name>ajaxSelectItemsMethod</name>
+	    <required>true</required>
+	    <rtexprvalue>false</rtexprvalue>
+	    <description>Method to call via ajax to reload the combo box</description>
+	</attribute>
+        <attribute>
+	    <name>parentComboBox</name>
+	    <required>false</required>
+	    <rtexprvalue>false</rtexprvalue>
+	    <description>id of the parent combo box</description>
+	</attribute>
+    </tag>
+
     <!-- tablesuggestajax -->
 	<tag>
 		<name>tableSuggestAjax</name>
@@ -1047,6 +1074,7 @@
 		&html_timed_notifier_attributes;
 	</tag>
 
+
 	<!-- conversation -->
 	<tag>
 		<name>startConversation</name>
@@ -1074,7 +1102,4 @@
 		&standard_conversation_attributes;
 		&conversation_attributes;
 	</tag>
-	
-	
-	
 </taglib>