You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/06/30 10:03:35 UTC

[myfaces-tobago] branch master updated: refactor: remove deprecated code: suggestMethod

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b903d6  refactor: remove deprecated code: suggestMethod
0b903d6 is described below

commit 0b903d60fc69174f7e4344cd989142db6111ce32
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Wed Jun 30 11:43:46 2021 +0200

    refactor: remove deprecated code: suggestMethod
---
 .../myfaces/tobago/component/Attributes.java       |  2 -
 .../myfaces/tobago/component/InputSuggest.java     | 29 --------
 .../myfaces/tobago/component/InputSuggest2.java    | 27 -------
 .../internal/component/AbstractUISuggest.java      |  3 +-
 .../renderkit/renderer/SuggestRenderer.java        | 31 ++------
 .../taglib/component/SuggestTagDeclaration.java    | 19 -----
 .../15-suggest-method/Suggest_Method.test.js       | 82 ----------------------
 .../15-suggest-method/Suggest_Method.xhtml         | 53 --------------
 8 files changed, 8 insertions(+), 238 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
index b771662..4a054f3 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
@@ -399,8 +399,6 @@ public enum Attributes {
   statePreview,
   step,
   style,
-  suggestMethod,
-  suggestMethodExpression,
   switchType,
   tabChangeListener,
   tabChangeListenerExpression,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/InputSuggest.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/InputSuggest.java
deleted file mode 100644
index 0555ec6..0000000
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/InputSuggest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.tobago.component;
-
-import javax.el.MethodExpression;
-
-public interface InputSuggest {
-
-  MethodExpression getSuggestMethodExpression();
-
-  void setSuggestMethodExpression(MethodExpression suggestExpression);
-}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/InputSuggest2.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/InputSuggest2.java
deleted file mode 100644
index 3aefa0e..0000000
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/InputSuggest2.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.tobago.component;
-
-/**
- * @deprecated since 4.0.0
- */
-@Deprecated
-public interface InputSuggest2 extends InputSuggest {
-}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java
index 71d5cd7..969e7c4 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISuggest.java
@@ -19,7 +19,6 @@
 
 package org.apache.myfaces.tobago.internal.component;
 
-import org.apache.myfaces.tobago.component.InputSuggest;
 import org.apache.myfaces.tobago.model.SuggestFilter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,7 +33,7 @@ import java.lang.invoke.MethodHandles;
  * {@link org.apache.myfaces.tobago.internal.taglib.component.SuggestTagDeclaration}
  */
 public abstract class AbstractUISuggest
-    extends UIComponentBase implements InputSuggest, ClientBehaviorHolder {
+    extends UIComponentBase implements ClientBehaviorHolder {
 
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SuggestRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SuggestRenderer.java
index c02e643..649fe95 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SuggestRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SuggestRenderer.java
@@ -35,7 +35,6 @@ import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.el.MethodExpression;
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
@@ -71,35 +70,19 @@ public class SuggestRenderer<T extends AbstractUISuggest> extends RendererBase<T
   @Override
   public void encodeBeginInternal(final FacesContext facesContext, final T component) throws IOException {
     final AbstractUIInput input = ComponentUtils.findAncestor(component, AbstractUIInput.class);
-    final MethodExpression suggestMethodExpression = component.getSuggestMethodExpression();
 
     int totalCount = component.getTotalCount();
     final String[] array;
 
-    if (suggestMethodExpression != null && input != null) { // old way (deprecated)
-      final AutoSuggestItems autoSuggestItems
-          = createAutoSuggestItems(suggestMethodExpression.invoke(facesContext.getELContext(), new Object[]{input}));
-      final List<AutoSuggestItem> items = autoSuggestItems.getItems();
+    final List<SelectItem> items = SelectItemUtils.getItemList(facesContext, component);
 
-      if (totalCount == -1 || items.size() < totalCount) {
-        totalCount = items.size();
-      }
-
-      array = new String[totalCount];
-      for (int i = 0; i < totalCount; i++) {
-        array[i] = items.get(i).getLabel();
-      }
-    } else {
-      final List<SelectItem> items = SelectItemUtils.getItemList(facesContext, component);
-
-      if (totalCount == -1 || items.size() < totalCount) {
-        totalCount = items.size();
-      }
+    if (totalCount == -1 || items.size() < totalCount) {
+      totalCount = items.size();
+    }
 
-      array = new String[totalCount];
-      for (int i = 0; i < totalCount; i++) {
-        array[i] = items.get(i).getLabel();
-      }
+    array = new String[totalCount];
+    for (int i = 0; i < totalCount; i++) {
+      array[i] = items.get(i).getLabel();
     }
 
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
index 4bb12ed..d188fa2 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
@@ -19,7 +19,6 @@
 
 package org.apache.myfaces.tobago.internal.taglib.component;
 
-import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
 import org.apache.myfaces.tobago.apt.annotation.Tag;
 import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
@@ -61,24 +60,6 @@ import javax.faces.component.UIInput;
 public interface SuggestTagDeclaration extends HasIdBindingAndRendered {
 
   /**
-   * {@link javax.el.MethodExpression} which generates a list of suggested input values based on
-   * the currently entered text, which could be retrieved via getSubmittedValue() on the UIIn.
-   * The expression has to evaluate to a public method which has a javax.faces.component.UIInput parameter
-   * and returns a List&lt;String&gt;, a List&lt;org.apache.myfaces.tobago.model.AutoSuggestItem&gt;
-   * or a org.apache.myfaces.tobago.model.AutoSuggestItems.
-   *
-   * @deprecated since 3.0.0.
-   * Please use an <code>&lt;tc:selectItems&gt;</code> tag or a list of <code>&lt;tc:selectItem&gt;</code> tags.
-   */
-  @Deprecated
-  @TagAttribute
-  @UIComponentTagAttribute(type = {},
-      expression = DynamicExpression.METHOD_EXPRESSION_REQUIRED,
-      methodSignature = "javax.faces.component.UIInput",
-      methodReturnType = "java.lang.Object")
-  void setSuggestMethod(String suggestMethod);
-
-  /**
    * Minimum number of characters to type before the list will be requested.
    * If the value is 0, there will be send an initial list to the client.
    * So, if you set <pre>update="false"</pre> this value should be 0.
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/35-deprecated/15-suggest-method/Suggest_Method.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/35-deprecated/15-suggest-method/Suggest_Method.test.js
deleted file mode 100644
index 65abc4a..0000000
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/35-deprecated/15-suggest-method/Suggest_Method.test.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
-
-it("not implemented yet", function (done) {
-  let test = new JasmineTestTool(done);
-  test.do(() => fail("must be fixed first"));
-  test.start();
-});
-
-/*
-import {querySelectorAllFn, querySelectorFn} from "/script/tobago-test.js";
-import {TobagoTestTool} from "/tobago/test/tobago-test-tool.js";
-
-QUnit.test("Deprecated: 'Ma'", function (assert) {
-  let inputString = "Ma";
-  let expectedLength = 4;
-
-  let inFn = querySelectorFn("#page\\:mainForm\\:deprecated\\:\\:field");
-  let suggestionsFn = getSuggestions("#page\\:mainForm\\:deprecated");
-
-  let TTT = new TobagoTestTool(assert);
-  TTT.action(function () {
-    inFn().value = inputString;
-    inFn().dispatchEvent(new Event("input", {bubbles: true}));
-  });
-  TTT.waitForResponse();
-  TTT.asserts(expectedLength + 1, function () {
-    assert.equal(suggestionsFn().length, expectedLength);
-    for (let i = 0; i < expectedLength; i++) {
-      assert.ok(suggestionsFn().item(i).querySelector("strong").textContent.toUpperCase().indexOf(inputString.toUpperCase()) >= 0);
-    }
-  });
-  TTT.startTest();
-});
-
-QUnit.test("Replacement: 'Ma'", function (assert) {
-  let inputString = "Ma";
-  let expectedLength = 4;
-
-  let inFn = querySelectorFn("#page\\:mainForm\\:replacement\\:\\:field");
-  let suggestionsFn = getSuggestions("#page\\:mainForm\\:replacement");
-
-  let TTT = new TobagoTestTool(assert);
-  TTT.action(function () {
-    inFn().value = inputString;
-    inFn().dispatchEvent(new Event("input", {bubbles: true}));
-  });
-  TTT.waitForResponse();
-  TTT.asserts(expectedLength + 1, function () {
-    assert.equal(suggestionsFn().length, expectedLength);
-    for (let i = 0; i < expectedLength; i++) {
-      assert.ok(suggestionsFn().item(i).querySelector("strong").textContent.toUpperCase().indexOf(inputString.toUpperCase()) >= 0);
-    }
-  });
-  TTT.startTest();
-});
-
-function escapeClientId(clientId) {
-  return '#' + clientId.replace(/([:\.])/g, '\\$1');
-}
-
-function getSuggestions(id) {
-  return querySelectorAllFn(escapeClientId(
-      querySelectorFn(id + " tobago-suggest")().id + "::popup") + " .tt-suggestion");
-}
-*/
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/35-deprecated/15-suggest-method/Suggest_Method.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/35-deprecated/15-suggest-method/Suggest_Method.xhtml
deleted file mode 100644
index 46307d8..0000000
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/35-deprecated/15-suggest-method/Suggest_Method.xhtml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-
-<ui:composition template="/main.xhtml"
-                xmlns="http://www.w3.org/1999/xhtml"
-                xmlns:tc="http://myfaces.apache.org/tobago/component"
-                xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
-  <p>The <code>suggestMethod</code> attribute of <code class="language-markup">&lt;tc:suggest/></code>
-    is deprecated.
-    Please use <code class="language-markup">&lt;tc:selectItems/></code> instead.
-    For more examples please have a look at the
-    <tc:link label="Suggest" outcome="/content/20-component/010-input/20-suggest/Suggest.xhtml"/>
-    section.</p>
-
-  <tc:section label="Deprecated">
-    <demo-highlight language="markup">&lt;tc:in label="Language">
-  &lt;tc:suggest totalCount="10" suggestMethod="\#{suggestController.getInputSuggestItems}"/>
-&lt;/tc:in></demo-highlight>
-    <tc:in id="deprecated" label="Language">
-      <tc:suggest totalCount="10" suggestMethod="#{suggestController.getInputSuggestItems}"/>
-    </tc:in>
-  </tc:section>
-
-  <tc:section label="Replacement">
-    <demo-highlight language="markup">&lt;tc:in label="Language">
-  &lt;tc:suggest totalCount="10" query="\#{suggestController.query}">
-    &lt;tc:selectItems value="\#{suggestController.solarObjects}" var="name" itemValue="\#{name}"/>
-  &lt;/tc:suggest>
-&lt;/tc:in></demo-highlight>
-    <tc:in id="replacement" label="Language">
-      <tc:suggest totalCount="10" query="#{suggestController.query}">
-        <tc:selectItems value="#{suggestController.solarObjects}" var="name" itemValue="#{name}"/>
-      </tc:suggest>
-    </tc:in>
-  </tc:section>
-</ui:composition>