myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r928739 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/internal/component/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/sca...
Date Mon, 29 Mar 2010 12:03:07 GMT
Author: bommel
Date: Mon Mar 29 12:03:07 2010
New Revision: 928739

URL: http://svn.apache.org/viewvc?rev=928739&view=rev
Log:
(TOBAGO-865) simplify ajax

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/UIInputBase.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/InTagDeclaration.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/UIInputBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/UIInputBase.java?rev=928739&r1=928738&r2=928739&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/UIInputBase.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/UIInputBase.java
Mon Mar 29 12:03:07 2010
@@ -18,17 +18,13 @@ package org.apache.myfaces.tobago.intern
  */
 
 import org.apache.myfaces.tobago.component.SupportsMarkup;
-import org.apache.myfaces.tobago.internal.ajax.AjaxComponent;
-import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
-import org.apache.myfaces.tobago.internal.ajax.AjaxResponseRenderer;
 import org.apache.myfaces.tobago.layout.LayoutComponent;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 
 import javax.faces.context.FacesContext;
-import java.io.IOException;
 
 public abstract class UIInputBase extends javax.faces.component.UIInput
-    implements AjaxComponent, SupportsMarkup, LayoutComponent {
+    implements SupportsMarkup, LayoutComponent {
 
   // TODO can this removed?
   public void updateModel(FacesContext facesContext) {
@@ -37,14 +33,6 @@ public abstract class UIInputBase extend
     }
   }
 
-  public void encodeAjax(FacesContext facesContext) throws IOException {
-    AjaxInternalUtils.encodeAjaxComponent(facesContext, this);
-  }
-
-  public int getAjaxResponseCode() {
-    return AjaxResponseRenderer.CODE_SUCCESS;
-  }
-
   public abstract Integer getTabIndex();
 
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/InTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/InTagDeclaration.java?rev=928739&r1=928738&r2=928739&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/InTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/InTagDeclaration.java
Mon Mar 29 12:03:07 2010
@@ -45,8 +45,7 @@ import org.apache.myfaces.tobago.taglib.
     uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.UIInputBase",
     rendererType = RendererTypes.IN,
     allowedChildComponenents = "NONE",
-    interfaces = { "org.apache.myfaces.tobago.internal.ajax.AjaxComponent", 
-        "org.apache.myfaces.tobago.component.InputSuggest" },
+    interfaces =  "org.apache.myfaces.tobago.component.InputSuggest",
     facets = {
     @Facet(name = Facets.CHANGE,
         description =

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?rev=928739&r1=928738&r2=928739&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
Mon Mar 29 12:03:07 2010
@@ -23,7 +23,6 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UIInput;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
-import org.apache.myfaces.tobago.internal.ajax.AjaxRenderer;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
 import org.apache.myfaces.tobago.internal.component.UIInputBase;
 import org.apache.myfaces.tobago.model.AutoSuggestExtensionItem;
@@ -49,7 +48,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-public class InRenderer extends InputRendererBase implements AjaxRenderer {
+public class InRenderer extends InputRendererBase {
 
   private static final Log LOG = LogFactory.getLog(InRenderer.class);
 
@@ -81,95 +80,103 @@ public class InRenderer extends InputRen
       LOG.error("Wrong type: Need " + UIInputBase.class.getName() + ", but was " + component.getClass().getName());
       return;
     }
-    UIInputBase input = (UIInputBase) component;
 
-    String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
+    String clientId = component.getClientId(facesContext);
+    AbstractUIPage page = ComponentUtils.findPage(component);
+    if (clientId.equals(page.getActionId())) {
+      // this is a inputSuggest
+      encodeAjax(facesContext, component);
+    } else {
 
-    String currentValue = getCurrentValue(facesContext, input);
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("currentValue = '" + currentValue + "'");
-    }
-    String type = ComponentUtils.getBooleanAttribute(input,
-        Attributes.PASSWORD) ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
+      UIInputBase input = (UIInputBase) component;
 
-    // Todo: check for valid binding
-    boolean renderAjaxSuggest = false;
-    if (input instanceof UIInput) {
-     renderAjaxSuggest = ((UIInput) input).getSuggestMethod() != null;
-    }
-    String id = input.getClientId(facesContext);
-    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-    writer.startElement(HtmlConstants.INPUT, input);
-    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
-    writer.writeNameAttribute(id);
-    writer.writeIdAttribute(id);
-    if (currentValue != null) {
-      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
-    }
-    if (title != null) {
-      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
-    }
-    int maxLength = 0;
-    for (Validator validator : input.getValidators()) {
-      if (validator instanceof LengthValidator) {
-        LengthValidator lengthValidator = (LengthValidator) validator;
-        maxLength = lengthValidator.getMaximum();
-      }
-    }
-    if (maxLength > 0) {
-      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
-    }
-    writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input,
Attributes.READONLY));
-    writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input,
Attributes.DISABLED));
-    Integer tabIndex = input.getTabIndex();
-    if (tabIndex != null) {
-      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
-    }
-    Style style = new Style(facesContext, input);
-    writer.writeStyleAttribute(style);
-
-    applyExtraStyle(facesContext, input, currentValue);
-    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
-    writer.writeClassAttribute();
-    /*if (component instanceof UIInputBase) {
-      String onchange = HtmlUtils.generateOnchange((UIInputBase) component, facesContext);
-      if (onchange != null) {
-        // TODO: create and use utility method to write attributes without quoting
-    //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
-      }
-    } */
-    writer.endElement(HtmlConstants.INPUT);
-
-    HtmlRendererUtils.checkForCommandFacet(input, facesContext, writer);
-
-    boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
-    String rendererName = HtmlRendererUtils.getRendererName(facesContext, input);
-    if (required && !renderAjaxSuggest) {
-      final String[] cmds = {
-          "new Tobago.In(\"" + id + "\", true ,\"" + StyleClasses.PREFIX + rendererName +
"\"  );"
-      };
-
-      HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
-    }
-
-    // focus
-    HtmlRendererUtils.renderFocusId(facesContext, input);
-
-    // input suggest
-    if (renderAjaxSuggest) {
-
-      final String[] cmds = {
-          "new Tobago.AutocompleterAjax(",
-          "    '" + id + "',",
-          "    " + required + ",",
-          "    '" + StyleClasses.PREFIX + rendererName + "',",
-          "    { });"
-      };
+      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
+
+      String currentValue = getCurrentValue(facesContext, input);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("currentValue = '" + currentValue + "'");
+      }
+      String type = ComponentUtils.getBooleanAttribute(input,
+          Attributes.PASSWORD) ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
+
+      // Todo: check for valid binding
+      boolean renderAjaxSuggest = false;
+      if (input instanceof UIInput) {
+        renderAjaxSuggest = ((UIInput) input).getSuggestMethod() != null;
+      }
+      String id = input.getClientId(facesContext);
+      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+      writer.startElement(HtmlConstants.INPUT, input);
+      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
+      writer.writeNameAttribute(id);
+      writer.writeIdAttribute(id);
+      if (currentValue != null) {
+        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
+      }
+      if (title != null) {
+        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
+      }
+      int maxLength = 0;
+      for (Validator validator : input.getValidators()) {
+        if (validator instanceof LengthValidator) {
+          LengthValidator lengthValidator = (LengthValidator) validator;
+          maxLength = lengthValidator.getMaximum();
+        }
+      }
+      if (maxLength > 0) {
+        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
+      }
+      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input,
Attributes.READONLY));
+      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input,
Attributes.DISABLED));
+      Integer tabIndex = input.getTabIndex();
+      if (tabIndex != null) {
+        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
+      }
+      Style style = new Style(facesContext, input);
+      writer.writeStyleAttribute(style);
+
+      applyExtraStyle(facesContext, input, currentValue);
+      HtmlRendererUtils.renderDojoDndItem(component, writer, true);
+      writer.writeClassAttribute();
+      /*if (component instanceof UIInputBase) {
+       String onchange = HtmlUtils.generateOnchange((UIInputBase) component, facesContext);
+       if (onchange != null) {
+         // TODO: create and use utility method to write attributes without quoting
+     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
+       }
+     } */
+      writer.endElement(HtmlConstants.INPUT);
+
+      HtmlRendererUtils.checkForCommandFacet(input, facesContext, writer);
+
+      boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
+      String rendererName = HtmlRendererUtils.getRendererName(facesContext, input);
+      if (required && !renderAjaxSuggest) {
+        final String[] cmds = {
+            "new Tobago.In(\"" + id + "\", true ,\"" + StyleClasses.PREFIX + rendererName
+ "\"  );"
+        };
+
+        HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
+      }
+
+      // focus
+      HtmlRendererUtils.renderFocusId(facesContext, input);
+
+      // input suggest
+      if (renderAjaxSuggest) {
+
+        final String[] cmds = {
+            "new Tobago.AutocompleterAjax(",
+            "    '" + id + "',",
+            "    " + required + ",",
+            "    '" + StyleClasses.PREFIX + rendererName + "',",
+            "    { });"
+        };
 
 //      HtmlRendererUtils.writeStyleLoader(facesContext, STYLES);
-      HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPTS, cmds);
+        HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPTS, cmds);
+      }
     }
-
   }
 
   protected void applyExtraStyle(FacesContext facesContext, UIInputBase input, String currentValue)
{
@@ -181,14 +188,12 @@ public class InRenderer extends InputRen
     }
   }
 
-  public void encodeAjax(FacesContext context, UIComponent component) throws IOException
{
+  private void encodeAjax(FacesContext context, UIComponent component) throws IOException
{
     if (!(component instanceof UIInputBase)) {
       LOG.error("Wrong type: Need " + UIInputBase.class.getName() + ", but was " + component.getClass().getName());
       return;
     }
 
-    AjaxInternalUtils.checkParamValidity(context, component, UIInput.class);
-
     UIInputBase input = (UIInputBase) component;
 
     MethodBinding mb;

Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java?rev=928739&r1=928738&r2=928739&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
Mon Mar 29 12:03:07 2010
@@ -21,8 +21,6 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UIBox;
 import org.apache.myfaces.tobago.component.UIToolBar;
-import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
-import org.apache.myfaces.tobago.internal.ajax.AjaxRenderer;
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.BoxRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Style;
@@ -38,7 +36,7 @@ import javax.faces.context.FacesContext;
 import java.io.IOException;
 import java.util.Map;
 
-public class BoxRenderer extends BoxRendererBase implements AjaxRenderer {
+public class BoxRenderer extends BoxRendererBase {
 
   @Override
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException
{
@@ -165,13 +163,4 @@ without shadow
     RenderUtil.encode(facesContext, toolbar);
     writer.endElement(HtmlConstants.DIV);
   }
-
-  public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException
{
-    AjaxInternalUtils.checkParamValidity(facesContext, component, UIPanel.class);
-    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
-    encodeBox(facesContext, writer, (UIBox) component);
-    component.encodeChildren(facesContext);
-    facesContext.responseComplete();
-  }
 }

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java?rev=928739&r1=928738&r2=928739&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
(original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
Mon Mar 29 12:03:07 2010
@@ -332,20 +332,13 @@ public class CreateComponentAnnotationVi
       }
       renderer.add(className);
       RendererInfo info = new RendererInfo(declaration.getQualifiedName(), className, rendererType);
-      boolean ajaxEnabled =
-          Arrays.asList(componentTag.interfaces()).contains("org.apache.myfaces.tobago.internal.ajax.AjaxComponent");
       if (componentTag.isLayout()) {
         info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractLayoutRendererWrapper");
-      } else if (ajaxEnabled) {
-        info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractAjaxRendererBaseWrapper");
       } else if (componentTag.isTransparentForLayout()) {
         info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractRendererBaseWrapper");
       } else {
         info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractLayoutableRendererBaseWrapper");
       }
-      if (ajaxEnabled) {
-        info.addInterface("org.apache.myfaces.tobago.internal.ajax.AjaxRenderer");
-      }
       StringTemplate stringTemplate = rendererStringTemplateGroup.getInstanceOf("renderer");
       stringTemplate.setAttribute("renderInfo", info);
       writeFile(info, stringTemplate);



Mime
View raw message