[richfaces-svn-commits] JBoss Rich Faces SVN: r607 - in trunk/richfaces/suggestionbox/src: main/java/org/richfaces/component and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed May 2 09:42:43 EDT 2007


Author: a.izobov
Date: 2007-05-02 09:42:43 -0400 (Wed, 02 May 2007)
New Revision: 607

Removed:
   trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java
   trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java
Modified:
   trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml
   trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
   trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
Log:
RF-112 fixed

Modified: trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml
===================================================================
--- trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml	2007-05-02 13:29:05 UTC (rev 606)
+++ trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml	2007-05-02 13:42:43 UTC (rev 607)
@@ -123,13 +123,13 @@
             </description>
         </property>
 
-
+        
         <property>
             <name>onsubmit</name>
             <classname>java.lang.String</classname>
             <description>JavaScript code for call before submission of ajax event.</description>
         </property>
-
+        
         <property>
             <name>selectedClass</name>
             <classname>java.lang.String</classname>
@@ -299,7 +299,6 @@
             <classname>java.lang.String</classname>
             <description>align</description>
         </property>
-
         <property>
             <name>zindex</name>
             <classname>int</classname>
@@ -308,5 +307,11 @@
             </description>
             <defaultvalue>200</defaultvalue>
         </property>
+        <property hidden="true">
+            <name>submitedValue</name>
+            <classname>java.lang.Object</classname>
+            <description>submitedValue</description>
+        </property>
+        
     </component>
 </components>

Deleted: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java	2007-05-02 13:29:05 UTC (rev 606)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java	2007-05-02 13:42:43 UTC (rev 607)
@@ -1,74 +0,0 @@
-/**
- * License Agreement.
- *
- *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007  Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- */
-
-package org.richfaces.component;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Event implementation for SuggestionBox component.
- */
-public class SuggestionEvent extends javax.faces.event.ActionEvent {
-
-    /**
-     * Serial Version UID.
-     */
-    private static final long serialVersionUID = 3192468135298986660L;
-
-    /**
-     * Submitted value.
-     */
-    private Object submittedValue;
-
-    /**
-     * Constructor.
-     *
-     * @param component {@link javax.faces.component.UIComponent}
-     * @param value     The submitted value to set
-     */
-    public SuggestionEvent(final UIComponent component, final Object value) {
-        super(component);
-        this.submittedValue = value;
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param component {@link javax.faces.component.UIComponent}
-     */
-    public SuggestionEvent(final UIComponent component) {
-        super(component);
-    }
-
-    /**
-     * @return Returns the submittedValie.
-     */
-    public final Object getSubmittedValue() {
-        return this.submittedValue;
-    }
-
-    /**
-     * @param value The submittedValie to set.
-     */
-    public final void setSubmittedValue(final Object value) {
-        this.submittedValue = value;
-    }
-}

Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java	2007-05-02 13:29:05 UTC (rev 606)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java	2007-05-02 13:42:43 UTC (rev 607)
@@ -83,6 +83,10 @@
      *
      * @return for value from local variable or value bindings
      */
+    public abstract Object getSubmitedValue();
+
+    public abstract void setSubmitedValue(Object v);
+
     public abstract String getFor();
 
     /**
@@ -249,7 +253,7 @@
 
     /**
      * Getter for submitted.
-     *
+     * 
      * @return TRUE if submited
      */
     public boolean isSubmitted() {
@@ -270,39 +274,12 @@
     public abstract void setZindex(int zindex);
 
     /* (non-Javadoc)
-      * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
-      */
-    public final void queueEvent(final FacesEvent event) {
-        if (event instanceof SuggestionEvent) {
-            if (isImmediate()) {
-                event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
-            } else if (isBypassUpdates()) {
-                event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
-            } else {
-                event.setPhaseId(PhaseId.INVOKE_APPLICATION);
-            }
-        }
-        super.queueEvent(event);
-    }
-
-
-    /* (non-Javadoc)
      * @see javax.faces.component.UIData#broadcast(javax.faces.event.FacesEvent)
      */
     public final void broadcast(final FacesEvent event)
             throws AbortProcessingException {
         super.broadcast(event);
-        if (event instanceof SuggestionEvent) {
-            SuggestionEvent suggestionEvent = (SuggestionEvent) event;
-            Object value = suggestionEvent.getSubmittedValue();
-            MethodBinding suggestingAction = getSuggestionAction();
-            if (null != suggestingAction) {
-                // TODO - use converter
-                setValue(suggestingAction.invoke(
-                        getFacesContext(), new Object[]{value}));
-                getFacesContext().renderResponse();
-            }
-        } else if (event instanceof AjaxEvent) {
+        if (event instanceof AjaxEvent) {
             FacesContext context = getFacesContext();
             AjaxRendererUtils.addRegionsFromComponent(this, context);
             AjaxRendererUtils.addRegionByName(context, this, this.getId());

Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java	2007-05-02 13:29:05 UTC (rev 606)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java	2007-05-02 13:42:43 UTC (rev 607)
@@ -36,7 +36,6 @@
 import org.ajax4jsf.framework.util.javascript.JSFunction;
 import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
 import org.richfaces.component.AjaxSuggestionEvent;
-import org.richfaces.component.SuggestionEvent;
 import org.richfaces.component.UISuggestionBox;
 
 import javax.faces.FacesException;
@@ -46,6 +45,7 @@
 import javax.faces.component.UIData;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.faces.el.MethodBinding;
 import javax.faces.event.FacesEvent;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -138,8 +138,7 @@
                 paramName = "inputvalue";
             }
             Object elementValue = requestParameterMap.get(paramName);
-            FacesEvent event = new SuggestionEvent(component, elementValue);
-            component.queueEvent(event);
+            ((UISuggestionBox)component).setSubmitedValue(elementValue);
             component.queueEvent(
                     new AjaxSuggestionEvent(component, elementValue));
         }
@@ -248,6 +247,13 @@
             throws IOException {
         UISuggestionBox suggestionBox = (UISuggestionBox) component;
         if (suggestionBox.isSubmitted()) {
+            Object value = suggestionBox.getSubmitedValue();
+            MethodBinding suggestingAction = suggestionBox.getSuggestionAction();
+            if (null != suggestingAction) {
+                // TODO - use converter
+                suggestionBox.setValue(suggestingAction.invoke(
+                        context, new Object[]{value}));
+            }
             body.encode(getTemplateContext(context, suggestionBox));
             // Replace rendered area ID from component to suggestion table
             suggestionBox.setRowIndex(-1);

Deleted: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java	2007-05-02 13:29:05 UTC (rev 606)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java	2007-05-02 13:42:43 UTC (rev 607)
@@ -1,72 +0,0 @@
-/**
- * License Agreement.
- *
- *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007  Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- */
-
-package org.richfaces.component;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-/**
- * Unit test for SuggestionEvent.
- */
-public class SuggestionEventTest extends AbstractAjax4JsfTestCase {
-
-    private SuggestionEvent event1;
-    private SuggestionEvent event2;
-    private UISuggestionBox sb;
-
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public SuggestionEventTest(String testName) {
-        super(testName);
-    }
-
-    /* (non-Javadoc)
-     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
-     */
-    public void setUp() throws Exception {
-        super.setUp();
-
-        sb = (UISuggestionBox)application.createComponent("org.richfaces.SuggestionBox");
-        event1 = new SuggestionEvent(sb);
-        event2 = new SuggestionEvent(sb, "VALUE2");
-    }
-
-    /* (non-Javadoc)
-     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
-     */
-    public void tearDown() throws Exception {
-        super.tearDown();
-        event1 = null;
-        event2 = null;
-        sb = null;
-    }
-
-    public void testEvent() throws Exception {
-        assertNull(event1.getSubmittedValue());
-        event1.setSubmittedValue("VALUE1");
-        assertEquals("VALUE1", event1.getSubmittedValue());
-
-        assertEquals("VALUE2", event2.getSubmittedValue());
-    }
-}




More information about the richfaces-svn-commits mailing list