You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2006/08/01 19:44:01 UTC
svn commit: r427657 [33/42] - in /myfaces:
core/trunk/api/src/main/java/javax/faces/component/
core/trunk/api/src/test/java/javax/faces/
core/trunk/api/src/test/java/javax/faces/application/
core/trunk/api/src/test/java/javax/faces/component/ core/trun...
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestRenderer.java Tue Aug 1 10:43:28 2006
@@ -1,424 +1,424 @@
-/*
- * Copyright 2005 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.suggest;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UISelectItems;
-import javax.faces.component.ValueHolder;
-import javax.faces.component.html.HtmlInputText;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-
-import org.apache.myfaces.component.html.ext.HtmlInputHidden;
-import org.apache.myfaces.renderkit.html.util.AddResource;
-import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-
-/**
- * Basic HTML Renderer for the inputSuggest component.
- *
- * @author Sean Schofield
- * @author Matt Blum
- * @version $Revision: $ $Date: $
- */
-public class InputSuggestRenderer
- extends Renderer
-{
- private String NEW_TEXT_KEY = "-1";
-
- public boolean getRendersChildren()
- {
- // must return "true" so that the UISelectItem child has been added before encode() is called
- return true;
- }
-
- public void decode(FacesContext context, UIComponent component)
- {
-
- if (isDisabledOrReadOnly(component))
- {
- return;
- }
-
- Map params = context.getExternalContext().getRequestParameterMap();
- String text = (String) params.get(getTextId(component, context));
- String choice = (String) params.get(getChoiceId(component, context));
- if (choice != null)
- {
- ( (EditableValueHolder) component).setSubmittedValue(choice);
-
- if (choice.equals(NEW_TEXT_KEY))
- {
- Map choices = getChoices(component);
- choices.put(NEW_TEXT_KEY, text);
- }
- }
- }
-
- public void encodeBegin(FacesContext context, UIComponent component) throws
- IOException
- {
-
- if (!component.isRendered())
- {
- return;
- }
-
- // Get the current value
- String value = (String) ( (EditableValueHolder) component).
- getSubmittedValue();
- if (value == null)
- {
- value = (String) ( (ValueHolder) component).getValue();
- }
-
- String text = null;
- Map choices = getChoices(component);
- if (value != null && choices != null)
- {
- text = (String) choices.get(value);
- }
-
- ResponseWriter out = context.getResponseWriter();
- renderInputField(out, text, getTextId(component, context), component);
-
- // render hidden input field containing the user's choice
- HtmlInputHidden hiddenChoice = new HtmlInputHidden();
- hiddenChoice.setId(getChoiceId(component, context));
- hiddenChoice.setValue(value);
- hiddenChoice.getAttributes().put(JSFAttr.FORCE_ID_ATTR, Boolean.TRUE);
- /** @todo use new encode recursive helper method once available */
- hiddenChoice.encodeBegin(context);
- hiddenChoice.encodeEnd(context);
-
- encodeSuggestions(context, out, choices,
- getSuggestionsId(component, context), component);
- encodeStyles(component, context);
- encodeJavascript(component, context);
- }
-
- private void renderInputField(ResponseWriter out, String text,
- String clientId, UIComponent component) throws
- IOException
- {
-
- out.startElement("input", component);
- out.writeAttribute("name", clientId, null);
- out.writeAttribute("id", clientId, null);
-
- if (text != null)
- {
- out.writeAttribute("value", text, "value");
- }
- else
- {
- out.writeAttribute("value", "", "value");
- }
-
- component.getAttributes().put("autocomplete","off");
-
- HtmlRendererUtils.renderHTMLAttributes(out,
- component, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if((component instanceof HtmlInputText) && ((HtmlInputText) component).isDisabled())
- {
- out.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
- }
-
- out.endElement("input");
- }
-
- private void encodeSuggestions(FacesContext context, ResponseWriter out,
- Map choices, String clientId,
- UIComponent component) throws IOException
- {
- //String choiceId = getChoiceId(component, context);
- /** @todo have the div class be the one specified by user or default of ACDiv */
-
- out.startElement(HTML.DIV_ELEM, component);
- out.writeAttribute(HTML.ID_ATTR, clientId, null);
-
- Iterator i = choices.keySet().iterator();
- while (i.hasNext())
- {
- String choice = (String) i.next();
- String text = (String) choices.get(choice);
- out.startElement(HTML.DIV_ELEM, null);
- out.writeAttribute(HTML.ID_ATTR,
- component.getClientId(context) + "_choice" +
- choice, null);
- out.writeAttribute(HTML.CLASS_ATTR, "ACdiv", null);
- out.writeText(text, null);
- out.endElement(HTML.DIV_ELEM);
- }
-
- out.endElement(HTML.DIV_ELEM);
- }
-
- /**
- * Returns true if one or both of the HTML attributes "disabled"
- * or "readonly" are set to true.
- */
- private boolean isDisabledOrReadOnly(UIComponent component)
- {
- boolean disabled = false;
- boolean readOnly = false;
-
- Object disabledAttr = component.getAttributes().get("disabled");
- if (disabledAttr != null)
- {
- disabled = disabledAttr.equals(Boolean.TRUE);
- }
- Object readOnlyAttr = component.getAttributes().get("readonly");
- if (readOnlyAttr != null)
- {
- readOnly = readOnlyAttr.equals(Boolean.TRUE);
- }
- return disabled || readOnly;
- }
-
- private Map getChoices(UIComponent component)
- {
- // Get the choices
- Object choices = null;
- Iterator i = component.getChildren().iterator();
- while (i.hasNext())
- {
- UIComponent kid = (UIComponent) i.next();
- // Should handle UISelectItem as well
- if (kid instanceof UISelectItems)
- {
- choices = ( (UISelectItems) kid).getValue();
- }
- }
-
- /** @todo selectItems may not necessarily be a map */
-
-// if (choices instanceof Map)
-// {
- return (Map) choices;
-// }
-// else if (choices instanceof Collection)
-// {
-//
-// }
-// else if (choices instanceof Object[])
-// {
-//
-// }
-// else if (choices instanceof SelectItem)
-// {
-//
-// }
-//
-// throw new IllegalArgumentException(
-// "Unsupported object type used for choices.");
- }
-
-
-// (this is not called from anywhere)
-// /**
-// * Helper method for getting the boolean value of an attribute. If the attribute is not specified,
-// * then return the default value.
-// *
-// * @param component The component for which the attributes are to be checked.
-// * @param attributeName The name of the boolean attribute.
-// * @param defaultValue The default value of the attribute (to be returned if no value found).
-// * @return boolean
-// */
-// private boolean getBoolean(UIComponent component, String attributeName,
-// boolean defaultValue)
-// {
-// Boolean booleanAttr = (Boolean) component.getAttributes().get(
-// attributeName);
-//
-// if (booleanAttr == null)
-// {
-// return defaultValue;
-// }
-// else
-// {
-// return booleanAttr.booleanValue();
-// }
-// }
-
- /**
- * Encodes necessary style information.
- *
- * @param component UIComponent
- * @param context FacesContext
- * @throws IOException
- */
- private void encodeStyles(UIComponent component, FacesContext context) throws
- IOException
- {
- ResponseWriter out = context.getResponseWriter();
-
- AddResource addResource = AddResourceFactory.getInstance(context);
- String styleLocation = (String) component.getAttributes().get(JSFAttr.
- STYLE_LOCATION);
- if (styleLocation == null)
- {
- addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, InputSuggestRenderer.class,
- "css/suggest.css");
- }
- else
- {
- addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/suggest.css");
- }
- }
-
- /**
- * Encodes necessary javascript functions.
- *
- * @param component UIComponent
- * @param context FacesContext
- * @throws IOException
- */
- private void encodeJavascript(UIComponent component, FacesContext context) throws
- IOException
- {
- ResponseWriter out = context.getResponseWriter();
-
- AddResource addResource = AddResourceFactory.getInstance(context);
- String javascriptLocation = (String) component.getAttributes().get(
- JSFAttr.JAVASCRIPT_LOCATION);
- if (javascriptLocation == null)
- {
- addResource.addJavaScriptHere(context, InputSuggestRenderer.class,
- "javascript/suggest.js");
- }
- else
- {
- addResource.addJavaScriptHere(context, javascriptLocation + "/suggest.js");
- }
-
- // now add javascript that depends on the component and cannot be part of javascript file
- out.startElement(HTML.SCRIPT_ELEM, null);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
-
- String textId = getTextId(component, context);
- String choiceId = getChoiceId(component, context);
- String suggestionsId = getSuggestionsId(component, context);
-
- // can't use ':', '|' or '.' chars in javascript variable name
- String modifiedTextId = textId.replace(':', '_');
- modifiedTextId = modifiedTextId.replace('|', '_');
- modifiedTextId = modifiedTextId.replace('.', '_');
-
- /** @todo make these values dependent on component attributes */
- out.writeText("\nvar " + modifiedTextId +
- "Row = -1; // this should always be initialized to -1\n", null);
- out.writeText("var " + modifiedTextId +
- "RowDiv = null; // this should always be initialized to null\n", null);
- out.writeText("var " + modifiedTextId +
- "MinRow = 0; // this should always be initialized to 0\n", null);
- out.writeText("var ACrowHeight = 15;\n", null);
- out.writeText("var ACfield = document.getElementById('" + textId +
- "');\n", null);
- out.writeText("var " + modifiedTextId + "Scroll = true;\n", null);
- out.writeText("var " + modifiedTextId + "CaseSensitive = false;\n", null);
- out.writeText("var " + modifiedTextId + "DisplayRows = 5;\n", null);
- out.writeText("var " + modifiedTextId +
- "Div = document.getElementById('" + suggestionsId +
- "');\n", null);
- out.writeText("var " + modifiedTextId + "HiddenFldId = '" + choiceId +
- "';\n", null);
- out.writeText("var " + modifiedTextId + "NormalClass = 'ACdiv';\n", null);
- out.writeText("var " + modifiedTextId +
- "HighlightClass = 'AChighlighted';\n", null);
- out.writeText("ACfield.onfocus = new Function('" + modifiedTextId +
- "Div.style.visibility = \"visible\"');\n", null);
- out.writeText("ACfield.onblur = new Function('blurACfld(this)');\n", null);
- out.writeText("ACfield.onkeyup = new Function(\"event\", \"return handleACkeyUp(this, event)\");\n", null);
- out.writeText("ACfield.onkeydown = new Function(\"event\", \"return handleACkeyDown(this, event)\");\n", null);
- out.writeText("var " + modifiedTextId + "Options = " + modifiedTextId +
- "Div.getElementsByTagName(\"DIV\");\n", null);
- out.writeText(modifiedTextId +
- "Div.onscroll = new Function(\"setACfieldFocus('" +
- textId + "')\");\n", null);
-
- out.writeText("var optLen = " + modifiedTextId + "Options.length;\n", null);
- out.writeText("for (var ii=0; ii<optLen; ii++) {\n", null);
- out.writeText(modifiedTextId +
- "Options[ii].style.height = ACrowHeight + 'px';\n", null);
- out.writeText(modifiedTextId +
- "Options[ii].onmouseover = new Function(\"highlightACDiv(this, '" +
- textId +
- "', \" + ii + \")\");\n", null);
- out.writeText(modifiedTextId +
- "Options[ii].onmouseout = new Function(\"unHighlightACDiv(this, '" +
- textId + "')\");\n", null);
- out.writeText(modifiedTextId +
- "Options[ii].onmousedown = new Function(\"selectACDiv('" +
- textId + "')\");\n", null);
- out.writeText("}\n", null);
-
- out.writeText("if (navigator.appVersion.toLowerCase().indexOf('msie') != -1 && " +
- "navigator.userAgent.toLowerCase().indexOf('opera') == -1)\n", null);
- out.writeText("document.writeln('<iframe id=\"" + modifiedTextId + "Shim\" src=\"javascript:false;\" " +
- "scrolling=\"no\" frameborder=\"0\" style=\"position:absolute; top:0px; left:0px;\">" +
- "</iframe>');\n", null);
-
-// out.writeText("var backingBean_inputFieldScroll = true;\n", null);
-// out.writeText("var backingBean_inputFieldCaseSensitive = false;\n", null);
-// out.writeText("var backingBean_inputFieldDisplayRows = 5;\n", null);
-// out.writeText("var backingBean_inputFieldDiv = document.getElementById('" + suggestionsId + "');\n", null);
-// out.writeText("var backingBean_inputFieldNormalClass = 'ACdiv';\n", null);
-// out.writeText("var backingBean_inputFieldHighlightClass = 'AChighlighted';\n", null);
-// out.writeText("ACfield.onfocus = new Function('backingBean_inputFieldDiv.style.visibility = \"visible\"');\n", null);
-// out.writeText("ACfield.onblur = new Function('backingBean_inputFieldDiv.style.visibility = \"hidden\"');\n", null);
-// out.writeText("ACfield.onkeyup = new Function(\"event\", \"return handleACkeyUp(this, event)\");\n", null);
-// out.writeText("ACfield.onkeydown = new Function(\"event\", \"return handleACkeyDown(this, event)\");\n", null);
-// out.writeText("var backingBean_inputFieldOptions = backingBean_inputFieldDiv.getElementsByTagName(\"DIV\");\n", null);
-// out.writeText("backingBean_inputFieldDiv.onscroll = new Function(\"setACfieldFocus('" + textId + "')\");\n", null);
-//
-// out.writeText("var optLen = backingBean_inputFieldOptions.length;\n", null);
-// out.writeText("for (var ii=0; ii<optLen; ii++) {\n", null);
-// out.writeText("backingBean_inputFieldOptions[ii].style.height = ACrowHeight + 'px';\n", null);
-// out.writeText("backingBean_inputFieldOptions[ii].onmouseover = new Function(\"highlightACDiv(this, '" + textId +
-// "', \" + ii + \")\");\n", null);
-// out.writeText("backingBean_inputFieldOptions[ii].onmouseout = new Function(\"unHighlightACDiv(this, '" + textId + "')\");\n", null);
-// out.writeText("backingBean_inputFieldOptions[ii].onmousedown = new Function(\"selectACDiv('" + textId + "')\");\n", null);
-// out.writeText("}\n", null);
-
- out.endElement(HTML.SCRIPT_ELEM);
-
- }
-
- private String getTextId(UIComponent component, FacesContext context)
- {
- return (component.getId() + "_text");
- }
-
- private String getChoiceId(UIComponent component, FacesContext context)
- {
- return (component.getId() + "_choice");
- }
-
- private String getSuggestionsId(UIComponent component, FacesContext context)
- {
- return ("AC" + getTextId(component, context));
- }
-}
+/*
+ * Copyright 2005 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.suggest;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UISelectItems;
+import javax.faces.component.ValueHolder;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.apache.myfaces.component.html.ext.HtmlInputHidden;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+
+/**
+ * Basic HTML Renderer for the inputSuggest component.
+ *
+ * @author Sean Schofield
+ * @author Matt Blum
+ * @version $Revision: $ $Date: $
+ */
+public class InputSuggestRenderer
+ extends Renderer
+{
+ private String NEW_TEXT_KEY = "-1";
+
+ public boolean getRendersChildren()
+ {
+ // must return "true" so that the UISelectItem child has been added before encode() is called
+ return true;
+ }
+
+ public void decode(FacesContext context, UIComponent component)
+ {
+
+ if (isDisabledOrReadOnly(component))
+ {
+ return;
+ }
+
+ Map params = context.getExternalContext().getRequestParameterMap();
+ String text = (String) params.get(getTextId(component, context));
+ String choice = (String) params.get(getChoiceId(component, context));
+ if (choice != null)
+ {
+ ( (EditableValueHolder) component).setSubmittedValue(choice);
+
+ if (choice.equals(NEW_TEXT_KEY))
+ {
+ Map choices = getChoices(component);
+ choices.put(NEW_TEXT_KEY, text);
+ }
+ }
+ }
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws
+ IOException
+ {
+
+ if (!component.isRendered())
+ {
+ return;
+ }
+
+ // Get the current value
+ String value = (String) ( (EditableValueHolder) component).
+ getSubmittedValue();
+ if (value == null)
+ {
+ value = (String) ( (ValueHolder) component).getValue();
+ }
+
+ String text = null;
+ Map choices = getChoices(component);
+ if (value != null && choices != null)
+ {
+ text = (String) choices.get(value);
+ }
+
+ ResponseWriter out = context.getResponseWriter();
+ renderInputField(out, text, getTextId(component, context), component);
+
+ // render hidden input field containing the user's choice
+ HtmlInputHidden hiddenChoice = new HtmlInputHidden();
+ hiddenChoice.setId(getChoiceId(component, context));
+ hiddenChoice.setValue(value);
+ hiddenChoice.getAttributes().put(JSFAttr.FORCE_ID_ATTR, Boolean.TRUE);
+ /** @todo use new encode recursive helper method once available */
+ hiddenChoice.encodeBegin(context);
+ hiddenChoice.encodeEnd(context);
+
+ encodeSuggestions(context, out, choices,
+ getSuggestionsId(component, context), component);
+ encodeStyles(component, context);
+ encodeJavascript(component, context);
+ }
+
+ private void renderInputField(ResponseWriter out, String text,
+ String clientId, UIComponent component) throws
+ IOException
+ {
+
+ out.startElement("input", component);
+ out.writeAttribute("name", clientId, null);
+ out.writeAttribute("id", clientId, null);
+
+ if (text != null)
+ {
+ out.writeAttribute("value", text, "value");
+ }
+ else
+ {
+ out.writeAttribute("value", "", "value");
+ }
+
+ component.getAttributes().put("autocomplete","off");
+
+ HtmlRendererUtils.renderHTMLAttributes(out,
+ component, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+
+ if((component instanceof HtmlInputText) && ((HtmlInputText) component).isDisabled())
+ {
+ out.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
+ }
+
+ out.endElement("input");
+ }
+
+ private void encodeSuggestions(FacesContext context, ResponseWriter out,
+ Map choices, String clientId,
+ UIComponent component) throws IOException
+ {
+ //String choiceId = getChoiceId(component, context);
+ /** @todo have the div class be the one specified by user or default of ACDiv */
+
+ out.startElement(HTML.DIV_ELEM, component);
+ out.writeAttribute(HTML.ID_ATTR, clientId, null);
+
+ Iterator i = choices.keySet().iterator();
+ while (i.hasNext())
+ {
+ String choice = (String) i.next();
+ String text = (String) choices.get(choice);
+ out.startElement(HTML.DIV_ELEM, null);
+ out.writeAttribute(HTML.ID_ATTR,
+ component.getClientId(context) + "_choice" +
+ choice, null);
+ out.writeAttribute(HTML.CLASS_ATTR, "ACdiv", null);
+ out.writeText(text, null);
+ out.endElement(HTML.DIV_ELEM);
+ }
+
+ out.endElement(HTML.DIV_ELEM);
+ }
+
+ /**
+ * Returns true if one or both of the HTML attributes "disabled"
+ * or "readonly" are set to true.
+ */
+ private boolean isDisabledOrReadOnly(UIComponent component)
+ {
+ boolean disabled = false;
+ boolean readOnly = false;
+
+ Object disabledAttr = component.getAttributes().get("disabled");
+ if (disabledAttr != null)
+ {
+ disabled = disabledAttr.equals(Boolean.TRUE);
+ }
+ Object readOnlyAttr = component.getAttributes().get("readonly");
+ if (readOnlyAttr != null)
+ {
+ readOnly = readOnlyAttr.equals(Boolean.TRUE);
+ }
+ return disabled || readOnly;
+ }
+
+ private Map getChoices(UIComponent component)
+ {
+ // Get the choices
+ Object choices = null;
+ Iterator i = component.getChildren().iterator();
+ while (i.hasNext())
+ {
+ UIComponent kid = (UIComponent) i.next();
+ // Should handle UISelectItem as well
+ if (kid instanceof UISelectItems)
+ {
+ choices = ( (UISelectItems) kid).getValue();
+ }
+ }
+
+ /** @todo selectItems may not necessarily be a map */
+
+// if (choices instanceof Map)
+// {
+ return (Map) choices;
+// }
+// else if (choices instanceof Collection)
+// {
+//
+// }
+// else if (choices instanceof Object[])
+// {
+//
+// }
+// else if (choices instanceof SelectItem)
+// {
+//
+// }
+//
+// throw new IllegalArgumentException(
+// "Unsupported object type used for choices.");
+ }
+
+
+// (this is not called from anywhere)
+// /**
+// * Helper method for getting the boolean value of an attribute. If the attribute is not specified,
+// * then return the default value.
+// *
+// * @param component The component for which the attributes are to be checked.
+// * @param attributeName The name of the boolean attribute.
+// * @param defaultValue The default value of the attribute (to be returned if no value found).
+// * @return boolean
+// */
+// private boolean getBoolean(UIComponent component, String attributeName,
+// boolean defaultValue)
+// {
+// Boolean booleanAttr = (Boolean) component.getAttributes().get(
+// attributeName);
+//
+// if (booleanAttr == null)
+// {
+// return defaultValue;
+// }
+// else
+// {
+// return booleanAttr.booleanValue();
+// }
+// }
+
+ /**
+ * Encodes necessary style information.
+ *
+ * @param component UIComponent
+ * @param context FacesContext
+ * @throws IOException
+ */
+ private void encodeStyles(UIComponent component, FacesContext context) throws
+ IOException
+ {
+ ResponseWriter out = context.getResponseWriter();
+
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ String styleLocation = (String) component.getAttributes().get(JSFAttr.
+ STYLE_LOCATION);
+ if (styleLocation == null)
+ {
+ addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, InputSuggestRenderer.class,
+ "css/suggest.css");
+ }
+ else
+ {
+ addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/suggest.css");
+ }
+ }
+
+ /**
+ * Encodes necessary javascript functions.
+ *
+ * @param component UIComponent
+ * @param context FacesContext
+ * @throws IOException
+ */
+ private void encodeJavascript(UIComponent component, FacesContext context) throws
+ IOException
+ {
+ ResponseWriter out = context.getResponseWriter();
+
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ String javascriptLocation = (String) component.getAttributes().get(
+ JSFAttr.JAVASCRIPT_LOCATION);
+ if (javascriptLocation == null)
+ {
+ addResource.addJavaScriptHere(context, InputSuggestRenderer.class,
+ "javascript/suggest.js");
+ }
+ else
+ {
+ addResource.addJavaScriptHere(context, javascriptLocation + "/suggest.js");
+ }
+
+ // now add javascript that depends on the component and cannot be part of javascript file
+ out.startElement(HTML.SCRIPT_ELEM, null);
+ out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+
+ String textId = getTextId(component, context);
+ String choiceId = getChoiceId(component, context);
+ String suggestionsId = getSuggestionsId(component, context);
+
+ // can't use ':', '|' or '.' chars in javascript variable name
+ String modifiedTextId = textId.replace(':', '_');
+ modifiedTextId = modifiedTextId.replace('|', '_');
+ modifiedTextId = modifiedTextId.replace('.', '_');
+
+ /** @todo make these values dependent on component attributes */
+ out.writeText("\nvar " + modifiedTextId +
+ "Row = -1; // this should always be initialized to -1\n", null);
+ out.writeText("var " + modifiedTextId +
+ "RowDiv = null; // this should always be initialized to null\n", null);
+ out.writeText("var " + modifiedTextId +
+ "MinRow = 0; // this should always be initialized to 0\n", null);
+ out.writeText("var ACrowHeight = 15;\n", null);
+ out.writeText("var ACfield = document.getElementById('" + textId +
+ "');\n", null);
+ out.writeText("var " + modifiedTextId + "Scroll = true;\n", null);
+ out.writeText("var " + modifiedTextId + "CaseSensitive = false;\n", null);
+ out.writeText("var " + modifiedTextId + "DisplayRows = 5;\n", null);
+ out.writeText("var " + modifiedTextId +
+ "Div = document.getElementById('" + suggestionsId +
+ "');\n", null);
+ out.writeText("var " + modifiedTextId + "HiddenFldId = '" + choiceId +
+ "';\n", null);
+ out.writeText("var " + modifiedTextId + "NormalClass = 'ACdiv';\n", null);
+ out.writeText("var " + modifiedTextId +
+ "HighlightClass = 'AChighlighted';\n", null);
+ out.writeText("ACfield.onfocus = new Function('" + modifiedTextId +
+ "Div.style.visibility = \"visible\"');\n", null);
+ out.writeText("ACfield.onblur = new Function('blurACfld(this)');\n", null);
+ out.writeText("ACfield.onkeyup = new Function(\"event\", \"return handleACkeyUp(this, event)\");\n", null);
+ out.writeText("ACfield.onkeydown = new Function(\"event\", \"return handleACkeyDown(this, event)\");\n", null);
+ out.writeText("var " + modifiedTextId + "Options = " + modifiedTextId +
+ "Div.getElementsByTagName(\"DIV\");\n", null);
+ out.writeText(modifiedTextId +
+ "Div.onscroll = new Function(\"setACfieldFocus('" +
+ textId + "')\");\n", null);
+
+ out.writeText("var optLen = " + modifiedTextId + "Options.length;\n", null);
+ out.writeText("for (var ii=0; ii<optLen; ii++) {\n", null);
+ out.writeText(modifiedTextId +
+ "Options[ii].style.height = ACrowHeight + 'px';\n", null);
+ out.writeText(modifiedTextId +
+ "Options[ii].onmouseover = new Function(\"highlightACDiv(this, '" +
+ textId +
+ "', \" + ii + \")\");\n", null);
+ out.writeText(modifiedTextId +
+ "Options[ii].onmouseout = new Function(\"unHighlightACDiv(this, '" +
+ textId + "')\");\n", null);
+ out.writeText(modifiedTextId +
+ "Options[ii].onmousedown = new Function(\"selectACDiv('" +
+ textId + "')\");\n", null);
+ out.writeText("}\n", null);
+
+ out.writeText("if (navigator.appVersion.toLowerCase().indexOf('msie') != -1 && " +
+ "navigator.userAgent.toLowerCase().indexOf('opera') == -1)\n", null);
+ out.writeText("document.writeln('<iframe id=\"" + modifiedTextId + "Shim\" src=\"javascript:false;\" " +
+ "scrolling=\"no\" frameborder=\"0\" style=\"position:absolute; top:0px; left:0px;\">" +
+ "</iframe>');\n", null);
+
+// out.writeText("var backingBean_inputFieldScroll = true;\n", null);
+// out.writeText("var backingBean_inputFieldCaseSensitive = false;\n", null);
+// out.writeText("var backingBean_inputFieldDisplayRows = 5;\n", null);
+// out.writeText("var backingBean_inputFieldDiv = document.getElementById('" + suggestionsId + "');\n", null);
+// out.writeText("var backingBean_inputFieldNormalClass = 'ACdiv';\n", null);
+// out.writeText("var backingBean_inputFieldHighlightClass = 'AChighlighted';\n", null);
+// out.writeText("ACfield.onfocus = new Function('backingBean_inputFieldDiv.style.visibility = \"visible\"');\n", null);
+// out.writeText("ACfield.onblur = new Function('backingBean_inputFieldDiv.style.visibility = \"hidden\"');\n", null);
+// out.writeText("ACfield.onkeyup = new Function(\"event\", \"return handleACkeyUp(this, event)\");\n", null);
+// out.writeText("ACfield.onkeydown = new Function(\"event\", \"return handleACkeyDown(this, event)\");\n", null);
+// out.writeText("var backingBean_inputFieldOptions = backingBean_inputFieldDiv.getElementsByTagName(\"DIV\");\n", null);
+// out.writeText("backingBean_inputFieldDiv.onscroll = new Function(\"setACfieldFocus('" + textId + "')\");\n", null);
+//
+// out.writeText("var optLen = backingBean_inputFieldOptions.length;\n", null);
+// out.writeText("for (var ii=0; ii<optLen; ii++) {\n", null);
+// out.writeText("backingBean_inputFieldOptions[ii].style.height = ACrowHeight + 'px';\n", null);
+// out.writeText("backingBean_inputFieldOptions[ii].onmouseover = new Function(\"highlightACDiv(this, '" + textId +
+// "', \" + ii + \")\");\n", null);
+// out.writeText("backingBean_inputFieldOptions[ii].onmouseout = new Function(\"unHighlightACDiv(this, '" + textId + "')\");\n", null);
+// out.writeText("backingBean_inputFieldOptions[ii].onmousedown = new Function(\"selectACDiv('" + textId + "')\");\n", null);
+// out.writeText("}\n", null);
+
+ out.endElement(HTML.SCRIPT_ELEM);
+
+ }
+
+ private String getTextId(UIComponent component, FacesContext context)
+ {
+ return (component.getId() + "_text");
+ }
+
+ private String getChoiceId(UIComponent component, FacesContext context)
+ {
+ return (component.getId() + "_choice");
+ }
+
+ private String getSuggestionsId(UIComponent component, FacesContext context)
+ {
+ return ("AC" + getTextId(component, context));
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestTag.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestTag.java Tue Aug 1 10:43:28 2006
@@ -1,55 +1,55 @@
-/*
- * Copyright 2005 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.suggest;
-
-import javax.faces.component.UIComponent;
-
-import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlInputTagBase;
-
-/**
- * @author Sean Schofield
- * @author Matt Blum
- * @version $Revision: $ $Date: $
- */
-public class InputSuggestTag extends HtmlInputTagBase
-{
-
- public String getComponentType() {
- return "javax.faces.HtmlInputText";
- }
-
- public String getRendererType() {
- return "org.apache.myfaces.InputSuggest";
- }
-
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
-
-// FacesContext context = getFacesContext();
-// if (_value != null)
-// {
-// if (isValueReference(_value))
-// {
-// ValueBinding vb = context.getApplication().createValueBinding(_value);
-// component.setValueBinding("value", vb);
-// }
-// else
-// {
-// component.getAttributes().put("value", _value);
-// }
-// }
- }
-}
+/*
+ * Copyright 2005 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.suggest;
+
+import javax.faces.component.UIComponent;
+
+import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlInputTagBase;
+
+/**
+ * @author Sean Schofield
+ * @author Matt Blum
+ * @version $Revision: $ $Date: $
+ */
+public class InputSuggestTag extends HtmlInputTagBase
+{
+
+ public String getComponentType() {
+ return "javax.faces.HtmlInputText";
+ }
+
+ public String getRendererType() {
+ return "org.apache.myfaces.InputSuggest";
+ }
+
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+
+// FacesContext context = getFacesContext();
+// if (_value != null)
+// {
+// if (isValueReference(_value))
+// {
+// ValueBinding vb = context.getApplication().createValueBinding(_value);
+// component.setValueBinding("value", vb);
+// }
+// else
+// {
+// component.getAttributes().put("value", _value);
+// }
+// }
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggest/InputSuggestTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjax.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjax.java Tue Aug 1 10:43:28 2006
@@ -1,186 +1,186 @@
-/*
- * 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.suggestajax;
-
-import org.apache.myfaces.component.html.ext.HtmlInputText;
-import org.apache.myfaces.custom.ajax.api.AjaxComponent;
-import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-import javax.faces.render.Renderer;
-import java.io.IOException;
-
-/**
- * @author Gerald Muellan
- * Date: 25.03.2006
- * Time: 17:06:04
- */
-public class SuggestAjax extends HtmlInputText implements AjaxComponent
-{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.SuggestAjax";
- public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SuggestAjax";
-
- private MethodBinding _suggestedItemsMethod;
-
- private String _popupId;
- private String _popupStyleClass;
- private String _popupStyle;
- private String _charset;
- private String _layout;
-
- private Integer _maxSuggestedItems;
-
- public SuggestAjax()
- {
- super();
-
- setRendererType(SuggestAjax.DEFAULT_RENDERER_TYPE);
- }
-
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[8];
- values[0] = super.saveState(context);
- values[1] = saveAttachedState(context, _suggestedItemsMethod);
- values[2] = _popupId;
- values[3] = _popupStyleClass;
- values[4] = _popupStyle;
- values[5] = _layout;
- values[6] = _maxSuggestedItems;
- values[7] = _charset;
-
- return values;
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[])state;
- super.restoreState(context, values[0]);
- _suggestedItemsMethod = (MethodBinding) restoreAttachedState(context, values[1]);
- _popupId = (String) values[2];
- _popupStyleClass = (String) values[3];
- _popupStyle = (String) values[4];
- _layout = (String) values[5];
- _maxSuggestedItems = (Integer) values[6];
- _charset = (String) values[7];
- }
-
- 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)
- {
-
- }
-
- public void encodeChildren(FacesContext context) throws IOException
- {
- super.encodeChildren(context);
- }
-
- public String getLayout()
- {
- if (_layout != null)
- return _layout;
- ValueBinding vb = getValueBinding("layout");
- return vb != null ? vb.getValue(getFacesContext()).toString() : "default";
- }
-
- public void setLayout(String layout)
- {
- _layout = layout;
- }
-
- public void setSuggestedItemsMethod(MethodBinding suggestedItemsMethod)
- {
- _suggestedItemsMethod = suggestedItemsMethod;
- }
-
- public MethodBinding getSuggestedItemsMethod()
- {
- return _suggestedItemsMethod;
- }
-
- public String getPopupId()
- {
- if (_popupId != null)
- return _popupId;
- ValueBinding vb = getValueBinding("popupId");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setPopupId(String popupId)
- {
- _popupId = popupId;
- }
-
- public String getPopupStyleClass()
- {
- if (_popupStyleClass != null)
- return _popupStyleClass;
- ValueBinding vb = getValueBinding("popupStyleClass");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setPopupStyleClass(String popupStyleClass)
- {
- _popupStyleClass = popupStyleClass;
- }
-
- public String getPopupStyle()
- {
- if (_popupStyle != null)
- return _popupStyle;
- ValueBinding vb = getValueBinding("popupStyle");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setPopupStyle(String popupStyle)
- {
- _popupStyle = popupStyle;
- }
-
- public Integer getMaxSuggestedItems() {
- if (_maxSuggestedItems != null)
- return _maxSuggestedItems;
- ValueBinding vb = getValueBinding("maxSuggestedItems");
- return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
- }
-
- public void setMaxSuggestedItems(Integer suggestedItems) {
- _maxSuggestedItems = suggestedItems;
- }
-
- public String getCharset() {
- return _charset;
- }
-
- public void setCharset(String charset) {
- _charset = charset;
- }
-
-}
+/*
+ * 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.suggestajax;
+
+import org.apache.myfaces.component.html.ext.HtmlInputText;
+import org.apache.myfaces.custom.ajax.api.AjaxComponent;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+
+/**
+ * @author Gerald Muellan
+ * Date: 25.03.2006
+ * Time: 17:06:04
+ */
+public class SuggestAjax extends HtmlInputText implements AjaxComponent
+{
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.SuggestAjax";
+ public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SuggestAjax";
+
+ private MethodBinding _suggestedItemsMethod;
+
+ private String _popupId;
+ private String _popupStyleClass;
+ private String _popupStyle;
+ private String _charset;
+ private String _layout;
+
+ private Integer _maxSuggestedItems;
+
+ public SuggestAjax()
+ {
+ super();
+
+ setRendererType(SuggestAjax.DEFAULT_RENDERER_TYPE);
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[8];
+ values[0] = super.saveState(context);
+ values[1] = saveAttachedState(context, _suggestedItemsMethod);
+ values[2] = _popupId;
+ values[3] = _popupStyleClass;
+ values[4] = _popupStyle;
+ values[5] = _layout;
+ values[6] = _maxSuggestedItems;
+ values[7] = _charset;
+
+ return values;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _suggestedItemsMethod = (MethodBinding) restoreAttachedState(context, values[1]);
+ _popupId = (String) values[2];
+ _popupStyleClass = (String) values[3];
+ _popupStyle = (String) values[4];
+ _layout = (String) values[5];
+ _maxSuggestedItems = (Integer) values[6];
+ _charset = (String) values[7];
+ }
+
+ 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)
+ {
+
+ }
+
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ super.encodeChildren(context);
+ }
+
+ public String getLayout()
+ {
+ if (_layout != null)
+ return _layout;
+ ValueBinding vb = getValueBinding("layout");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : "default";
+ }
+
+ public void setLayout(String layout)
+ {
+ _layout = layout;
+ }
+
+ public void setSuggestedItemsMethod(MethodBinding suggestedItemsMethod)
+ {
+ _suggestedItemsMethod = suggestedItemsMethod;
+ }
+
+ public MethodBinding getSuggestedItemsMethod()
+ {
+ return _suggestedItemsMethod;
+ }
+
+ public String getPopupId()
+ {
+ if (_popupId != null)
+ return _popupId;
+ ValueBinding vb = getValueBinding("popupId");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setPopupId(String popupId)
+ {
+ _popupId = popupId;
+ }
+
+ public String getPopupStyleClass()
+ {
+ if (_popupStyleClass != null)
+ return _popupStyleClass;
+ ValueBinding vb = getValueBinding("popupStyleClass");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setPopupStyleClass(String popupStyleClass)
+ {
+ _popupStyleClass = popupStyleClass;
+ }
+
+ public String getPopupStyle()
+ {
+ if (_popupStyle != null)
+ return _popupStyle;
+ ValueBinding vb = getValueBinding("popupStyle");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setPopupStyle(String popupStyle)
+ {
+ _popupStyle = popupStyle;
+ }
+
+ public Integer getMaxSuggestedItems() {
+ if (_maxSuggestedItems != null)
+ return _maxSuggestedItems;
+ ValueBinding vb = getValueBinding("maxSuggestedItems");
+ return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setMaxSuggestedItems(Integer suggestedItems) {
+ _maxSuggestedItems = suggestedItems;
+ }
+
+ public String getCharset() {
+ return _charset;
+ }
+
+ public void setCharset(String charset) {
+ _charset = charset;
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjax.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java Tue Aug 1 10:43:28 2006
@@ -1,88 +1,88 @@
-/*
- * 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.suggestajax;
-
-import org.apache.myfaces.custom.ajax.api.AjaxDecodePhaseListener;
-import org.apache.myfaces.custom.ajax.api.AjaxSuggestRenderer;
-import org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer;
-import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Gerald Muellan
- * @author Martin Marinschek
- * @version $Revision: 177984 $ $Date: 2005-05-23 19:39:37 +0200 (Mon, 23 May 2005) $
- */
-public class SuggestAjaxRenderer extends HtmlTextRenderer implements AjaxSuggestRenderer
-{
- public static final int DEFAULT_MAX_SUGGESTED_ITEMS = 200;
-
- public Collection getSuggestedItems(FacesContext context, UIComponent uiComponent)
- {
- RendererUtils.checkParamValidity(context, uiComponent, SuggestAjax.class);
-
- SuggestAjax suggestAjax = (SuggestAjax) uiComponent;
-
- //getting the suggested items
- MethodBinding mb = suggestAjax.getSuggestedItemsMethod();
- Integer maxSuggestedCount = suggestAjax.getMaxSuggestedItems();
-
- Collection suggesteds;
-
- if (maxSuggestedCount != null
- && maxSuggestedCount.intValue() > 0)
- {
- try
- {
- suggesteds = (Collection) mb.invoke(context,new Object[]{
- AjaxDecodePhaseListener.getValueForComponent(context, uiComponent),
- maxSuggestedCount});
- }
- catch(MethodNotFoundException dummy)
- {
- suggesteds = (List) mb.invoke(context,new Object[]{
- AjaxDecodePhaseListener.getValueForComponent(context, uiComponent)});
- }
- }
- else
- {
- try
- {
- suggesteds = (List) mb.invoke(context,new Object[]{
- AjaxDecodePhaseListener.getValueForComponent(context, uiComponent)});
- }
- catch(MethodNotFoundException dummy)
- {
- suggesteds = (Collection) mb.invoke(context,new Object[]{
- AjaxDecodePhaseListener.getValueForComponent(context, uiComponent),
- new Integer( DEFAULT_MAX_SUGGESTED_ITEMS )});
- }
- }
-
- return suggesteds;
- }
-
- public void decode(FacesContext facesContext, UIComponent component)
- {
- super.decode(facesContext, component);
- }
-}
+/*
+ * 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.suggestajax;
+
+import org.apache.myfaces.custom.ajax.api.AjaxDecodePhaseListener;
+import org.apache.myfaces.custom.ajax.api.AjaxSuggestRenderer;
+import org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.MethodNotFoundException;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Gerald Muellan
+ * @author Martin Marinschek
+ * @version $Revision: 177984 $ $Date: 2005-05-23 19:39:37 +0200 (Mon, 23 May 2005) $
+ */
+public class SuggestAjaxRenderer extends HtmlTextRenderer implements AjaxSuggestRenderer
+{
+ public static final int DEFAULT_MAX_SUGGESTED_ITEMS = 200;
+
+ public Collection getSuggestedItems(FacesContext context, UIComponent uiComponent)
+ {
+ RendererUtils.checkParamValidity(context, uiComponent, SuggestAjax.class);
+
+ SuggestAjax suggestAjax = (SuggestAjax) uiComponent;
+
+ //getting the suggested items
+ MethodBinding mb = suggestAjax.getSuggestedItemsMethod();
+ Integer maxSuggestedCount = suggestAjax.getMaxSuggestedItems();
+
+ Collection suggesteds;
+
+ if (maxSuggestedCount != null
+ && maxSuggestedCount.intValue() > 0)
+ {
+ try
+ {
+ suggesteds = (Collection) mb.invoke(context,new Object[]{
+ AjaxDecodePhaseListener.getValueForComponent(context, uiComponent),
+ maxSuggestedCount});
+ }
+ catch(MethodNotFoundException dummy)
+ {
+ suggesteds = (List) mb.invoke(context,new Object[]{
+ AjaxDecodePhaseListener.getValueForComponent(context, uiComponent)});
+ }
+ }
+ else
+ {
+ try
+ {
+ suggesteds = (List) mb.invoke(context,new Object[]{
+ AjaxDecodePhaseListener.getValueForComponent(context, uiComponent)});
+ }
+ catch(MethodNotFoundException dummy)
+ {
+ suggesteds = (Collection) mb.invoke(context,new Object[]{
+ AjaxDecodePhaseListener.getValueForComponent(context, uiComponent),
+ new Integer( DEFAULT_MAX_SUGGESTED_ITEMS )});
+ }
+ }
+
+ return suggesteds;
+ }
+
+ public void decode(FacesContext facesContext, UIComponent component)
+ {
+ super.decode(facesContext, component);
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxTag.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxTag.java Tue Aug 1 10:43:28 2006
@@ -1,145 +1,145 @@
-/*
- * 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.suggestajax;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjax;
-import org.apache.myfaces.taglib.html.ext.HtmlInputTextTag;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-/**
- * @author Gerald Muellan
- * Date: 25.03.2006
- * Time: 17:05:58
- */
-public class SuggestAjaxTag extends HtmlInputTextTag
-{
- private final static Class[] DEFAULT_SIGNATURE = new Class[]{String.class};
- private final static Class[] SUGGEST_ITEM_SIGNATURE = new Class[]{String.class, Integer.class};
-
- private static Log log = LogFactory.getLog(SuggestAjaxTag.class);
-
- private String _suggestedItemsMethod;
- private String _maxSuggestedItems;
-
- private String _popupId;
- private String _popupStyleClass;
- private String _popupStyle;
- private String _charset;
- private String _layout;
-
- public String getComponentType() {
- return InputSuggestAjax.COMPONENT_TYPE;
- }
-
- public String getRendererType() {
- return InputSuggestAjax.DEFAULT_RENDERER_TYPE;
- }
-
- public void release() {
-
- super.release();
-
- _suggestedItemsMethod = null;
- _maxSuggestedItems = null;
- _popupId = null;
- _popupStyleClass = null;
- _popupStyle = null;
- _layout = null;
- _charset = null;
-
- }
-
- protected void setProperties(UIComponent component) {
-
- super.setProperties(component);
-
- setIntegerProperty(component,"maxSuggestedItems", _maxSuggestedItems);
-
- SuggestAjaxTag.setSuggestedItemsMethodProperty(getFacesContext(),component,_suggestedItemsMethod);
- setStringProperty(component,"popupId",_popupId);
- setStringProperty(component,"popupStyleClass",_popupStyleClass);
- setStringProperty(component,"popupStyle",_popupStyle);
- setStringProperty(component,"layout",_layout);
- setStringProperty(component,"charset",_charset);
- }
-
- public static void setSuggestedItemsMethodProperty(FacesContext context,
- UIComponent component,
- String suggestedItemsMethod)
- {
- if (suggestedItemsMethod != null)
- {
- if (!(component instanceof SuggestAjax))
- {
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no InputSuggestAjax");
- }
- if (isValueReference(suggestedItemsMethod))
- {
- if (((SuggestAjax)component).getMaxSuggestedItems()!=null) {
- MethodBinding mb = context.getApplication().createMethodBinding(suggestedItemsMethod, SuggestAjaxTag.SUGGEST_ITEM_SIGNATURE);
- ((SuggestAjax)component).setSuggestedItemsMethod(mb);
- } else {
- MethodBinding mb = context.getApplication().createMethodBinding(suggestedItemsMethod, SuggestAjaxTag.DEFAULT_SIGNATURE);
- ((SuggestAjax)component).setSuggestedItemsMethod(mb);
- }
- }
- else
- {
- SuggestAjaxTag.log.error("Invalid expression " + suggestedItemsMethod);
- }
- }
- }
-
- // setter methodes to populate the components properites
- public void setLayout(String layout)
- {
- _layout = layout;
- }
-
- public void setSuggestedItemsMethod(String suggestedItemsMethod)
- {
- _suggestedItemsMethod = suggestedItemsMethod;
- }
-
- public void setPopupId(String popupId)
- {
- _popupId = popupId;
- }
-
- public void setPopupStyleClass(String popupStyleClass)
- {
- _popupStyleClass = popupStyleClass;
- }
-
- public void setPopupStyle(String popupStyle)
- {
- _popupStyle = popupStyle;
- }
-
- public void setMaxSuggestedItems(String maxSuggestedItems) {
- _maxSuggestedItems = (maxSuggestedItems);
- }
-
- public void setCharset(String charset) {
- _charset = charset;
- }
-
-}
+/*
+ * 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.suggestajax;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjax;
+import org.apache.myfaces.taglib.html.ext.HtmlInputTextTag;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+/**
+ * @author Gerald Muellan
+ * Date: 25.03.2006
+ * Time: 17:05:58
+ */
+public class SuggestAjaxTag extends HtmlInputTextTag
+{
+ private final static Class[] DEFAULT_SIGNATURE = new Class[]{String.class};
+ private final static Class[] SUGGEST_ITEM_SIGNATURE = new Class[]{String.class, Integer.class};
+
+ private static Log log = LogFactory.getLog(SuggestAjaxTag.class);
+
+ private String _suggestedItemsMethod;
+ private String _maxSuggestedItems;
+
+ private String _popupId;
+ private String _popupStyleClass;
+ private String _popupStyle;
+ private String _charset;
+ private String _layout;
+
+ public String getComponentType() {
+ return InputSuggestAjax.COMPONENT_TYPE;
+ }
+
+ public String getRendererType() {
+ return InputSuggestAjax.DEFAULT_RENDERER_TYPE;
+ }
+
+ public void release() {
+
+ super.release();
+
+ _suggestedItemsMethod = null;
+ _maxSuggestedItems = null;
+ _popupId = null;
+ _popupStyleClass = null;
+ _popupStyle = null;
+ _layout = null;
+ _charset = null;
+
+ }
+
+ protected void setProperties(UIComponent component) {
+
+ super.setProperties(component);
+
+ setIntegerProperty(component,"maxSuggestedItems", _maxSuggestedItems);
+
+ SuggestAjaxTag.setSuggestedItemsMethodProperty(getFacesContext(),component,_suggestedItemsMethod);
+ setStringProperty(component,"popupId",_popupId);
+ setStringProperty(component,"popupStyleClass",_popupStyleClass);
+ setStringProperty(component,"popupStyle",_popupStyle);
+ setStringProperty(component,"layout",_layout);
+ setStringProperty(component,"charset",_charset);
+ }
+
+ public static void setSuggestedItemsMethodProperty(FacesContext context,
+ UIComponent component,
+ String suggestedItemsMethod)
+ {
+ if (suggestedItemsMethod != null)
+ {
+ if (!(component instanceof SuggestAjax))
+ {
+ throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no InputSuggestAjax");
+ }
+ if (isValueReference(suggestedItemsMethod))
+ {
+ if (((SuggestAjax)component).getMaxSuggestedItems()!=null) {
+ MethodBinding mb = context.getApplication().createMethodBinding(suggestedItemsMethod, SuggestAjaxTag.SUGGEST_ITEM_SIGNATURE);
+ ((SuggestAjax)component).setSuggestedItemsMethod(mb);
+ } else {
+ MethodBinding mb = context.getApplication().createMethodBinding(suggestedItemsMethod, SuggestAjaxTag.DEFAULT_SIGNATURE);
+ ((SuggestAjax)component).setSuggestedItemsMethod(mb);
+ }
+ }
+ else
+ {
+ SuggestAjaxTag.log.error("Invalid expression " + suggestedItemsMethod);
+ }
+ }
+ }
+
+ // setter methodes to populate the components properites
+ public void setLayout(String layout)
+ {
+ _layout = layout;
+ }
+
+ public void setSuggestedItemsMethod(String suggestedItemsMethod)
+ {
+ _suggestedItemsMethod = suggestedItemsMethod;
+ }
+
+ public void setPopupId(String popupId)
+ {
+ _popupId = popupId;
+ }
+
+ public void setPopupStyleClass(String popupStyleClass)
+ {
+ _popupStyleClass = popupStyleClass;
+ }
+
+ public void setPopupStyle(String popupStyle)
+ {
+ _popupStyle = popupStyle;
+ }
+
+ public void setMaxSuggestedItems(String maxSuggestedItems) {
+ _maxSuggestedItems = (maxSuggestedItems);
+ }
+
+ public void setCharset(String charset) {
+ _charset = charset;
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java Tue Aug 1 10:43:28 2006
@@ -1,143 +1,143 @@
-/*
- * 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.
- */
-package org.apache.myfaces.custom.suggestajax.inputsuggestajax;
-
-import org.apache.myfaces.custom.suggestajax.SuggestAjax;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import java.io.IOException;
-
-/**
- * @author Gerald Muellan (latest modification by $Author: svieujot $)
- * @author Martin Marinschek
- *
- * @version $Revision: 169662 $ $Date: 2005-05-11 19:57:24 +0200 (Wed, 11 May 2005) $
- */
-
-public class InputSuggestAjax extends SuggestAjax
-{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.InputSuggestAjax";
- public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.InputSuggestAjax";
-
- private String _listId;
- private String _listStyleClass;
- private String _listStyle;
-
- private String _listItemStyleClass;
- private String _listItemStyle;
-
- public InputSuggestAjax()
- {
- super();
-
- setRendererType(DEFAULT_RENDERER_TYPE);
- }
-
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[6];
- values[0] = super.saveState(context);
- values[1] = _listId;
- values[2] = _listStyleClass;
- values[3] = _listStyle;
- values[4] = _listItemStyleClass;
- values[5] = _listItemStyle;
-
- return values;
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[])state;
- super.restoreState(context, values[0]);
- _listId = (String) values[1];
- _listStyleClass = (String) values[2];
- _listStyle = (String) values[3];
- _listItemStyleClass = (String) values[4] ;
- _listItemStyle = (String) values[5];
- }
-
- public void encodeChildren(FacesContext context) throws IOException
- {
- super.encodeChildren(context);
- }
-
- public String getListId()
- {
- if (_listId != null)
- return _listId;
- ValueBinding vb = getValueBinding("listId");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setListId(String listId)
- {
- _listId = listId;
- }
-
- public String getListStyleClass()
- {
- if (_listStyleClass != null)
- return _listStyleClass;
- ValueBinding vb = getValueBinding("listStyleClass");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setListStyleClass(String listStyleClass)
- {
- _listStyleClass = listStyleClass;
- }
-
- public String getListStyle()
- {
- if (_listStyle != null)
- return _listStyle;
- ValueBinding vb = getValueBinding("listStyle");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setListStyle(String listStyle)
- {
- _listStyle = listStyle;
- }
-
- public String getListItemStyleClass()
- {
- if (_listItemStyleClass != null)
- return _listItemStyleClass;
- ValueBinding vb = getValueBinding("listItemStyleClass");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setListItemStyleClass(String listItemStyleClass)
- {
- _listItemStyleClass = listItemStyleClass;
- }
-
- public String getListItemStyle()
- {
- if (_listItemStyle != null)
- return _listItemStyle;
- ValueBinding vb = getValueBinding("listItemStyle");
- return vb != null ? vb.getValue(getFacesContext()).toString() : null;
- }
-
- public void setListItemStyle(String listItemStyle)
- {
- _listItemStyle = listItemStyle;
- }
-}
+/*
+ * 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.
+ */
+package org.apache.myfaces.custom.suggestajax.inputsuggestajax;
+
+import org.apache.myfaces.custom.suggestajax.SuggestAjax;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import java.io.IOException;
+
+/**
+ * @author Gerald Muellan (latest modification by $Author: svieujot $)
+ * @author Martin Marinschek
+ *
+ * @version $Revision: 169662 $ $Date: 2005-05-11 19:57:24 +0200 (Wed, 11 May 2005) $
+ */
+
+public class InputSuggestAjax extends SuggestAjax
+{
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.InputSuggestAjax";
+ public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.InputSuggestAjax";
+
+ private String _listId;
+ private String _listStyleClass;
+ private String _listStyle;
+
+ private String _listItemStyleClass;
+ private String _listItemStyle;
+
+ public InputSuggestAjax()
+ {
+ super();
+
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[6];
+ values[0] = super.saveState(context);
+ values[1] = _listId;
+ values[2] = _listStyleClass;
+ values[3] = _listStyle;
+ values[4] = _listItemStyleClass;
+ values[5] = _listItemStyle;
+
+ return values;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _listId = (String) values[1];
+ _listStyleClass = (String) values[2];
+ _listStyle = (String) values[3];
+ _listItemStyleClass = (String) values[4] ;
+ _listItemStyle = (String) values[5];
+ }
+
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ super.encodeChildren(context);
+ }
+
+ public String getListId()
+ {
+ if (_listId != null)
+ return _listId;
+ ValueBinding vb = getValueBinding("listId");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setListId(String listId)
+ {
+ _listId = listId;
+ }
+
+ public String getListStyleClass()
+ {
+ if (_listStyleClass != null)
+ return _listStyleClass;
+ ValueBinding vb = getValueBinding("listStyleClass");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setListStyleClass(String listStyleClass)
+ {
+ _listStyleClass = listStyleClass;
+ }
+
+ public String getListStyle()
+ {
+ if (_listStyle != null)
+ return _listStyle;
+ ValueBinding vb = getValueBinding("listStyle");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setListStyle(String listStyle)
+ {
+ _listStyle = listStyle;
+ }
+
+ public String getListItemStyleClass()
+ {
+ if (_listItemStyleClass != null)
+ return _listItemStyleClass;
+ ValueBinding vb = getValueBinding("listItemStyleClass");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setListItemStyleClass(String listItemStyleClass)
+ {
+ _listItemStyleClass = listItemStyleClass;
+ }
+
+ public String getListItemStyle()
+ {
+ if (_listItemStyle != null)
+ return _listItemStyle;
+ ValueBinding vb = getValueBinding("listItemStyle");
+ return vb != null ? vb.getValue(getFacesContext()).toString() : null;
+ }
+
+ public void setListItemStyle(String listItemStyle)
+ {
+ _listItemStyle = listItemStyle;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjax.java
------------------------------------------------------------------------------
svn:eol-style = native