Author: nbelaevski
Date: 2007-03-27 15:54:16 -0400 (Tue, 27 Mar 2007)
New Revision: 179
Added:
trunk/richfaces-samples/suggestionbox-sample/src/main/java/org/richfaces/AjaxListener.java
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java
Modified:
trunk/richfaces-samples/suggestionbox-sample/src/main/webapp/pages/index.jsp
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-25 fixed. Changes:
1. UISuggestionBox now implements AjaxSource
2. AjaxSuggestionEvent providing submittedValue and handling for it have been added
3. Ajax listener printing submitted value added to test case
Added:
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java
===================================================================
---
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java
(rev 0)
+++
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java 2007-03-27
19:54:16 UTC (rev 179)
@@ -0,0 +1,71 @@
+/**
+ * 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;
+
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+
+public class AjaxSuggestionEvent extends AjaxEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 9212067213575185754L;
+ /**
+ *
+ */
+ private Object _submittedValue;
+
+ /**
+ * @param component
+ * @param submittedValie
+ */
+ public AjaxSuggestionEvent(UIComponent component, Object submittedValue) {
+ super(component);
+ // TODO Auto-generated constructor stub
+ this._submittedValue = submittedValue;
+ }
+
+ /**
+ * @param component
+ */
+ public AjaxSuggestionEvent(UIComponent component) {
+ super(component);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @return Returns the submittedValie.
+ */
+ public Object getSubmittedValue() {
+ return this._submittedValue;
+ }
+
+ /**
+ * @param submittedValie The submittedValie to set.
+ */
+ public void setSubmittedValue(Object submittedValue) {
+ this._submittedValue = submittedValue;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
---
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-03-27
19:34:43 UTC (rev 178)
+++
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-03-27
19:54:16 UTC (rev 179)
@@ -24,6 +24,8 @@
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxSource;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,7 +43,7 @@
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.5 $ $Date: 2007/03/01 22:37:50 $
*/
-public abstract class UISuggestionBox extends UIData implements AjaxComponent {
+public abstract class UISuggestionBox extends UIData implements AjaxComponent, AjaxSource
{
private static Log log = LogFactory.getLog(UISuggestionBox.class);
@@ -155,5 +157,17 @@
}
}
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
+
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+ }
+
+
}
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-03-27
19:34:43 UTC (rev 178)
+++
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-03-27
19:54:16 UTC (rev 179)
@@ -36,6 +36,7 @@
import org.ajax4jsf.framework.skin.SkinFactory;
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;
@@ -105,7 +106,7 @@
Object elementValue = requestParameterMap.get(paramName);
FacesEvent event = new SuggestionEvent(component, elementValue);
component.queueEvent(event);
- component.queueEvent(new AjaxEvent(component));
+ component.queueEvent(new AjaxSuggestionEvent(component, elementValue));
}
}
Added:
trunk/richfaces-samples/suggestionbox-sample/src/main/java/org/richfaces/AjaxListener.java
===================================================================
---
trunk/richfaces-samples/suggestionbox-sample/src/main/java/org/richfaces/AjaxListener.java
(rev 0)
+++
trunk/richfaces-samples/suggestionbox-sample/src/main/java/org/richfaces/AjaxListener.java 2007-03-27
19:54:16 UTC (rev 179)
@@ -0,0 +1,28 @@
+/**
+ *
+ */
+package org.richfaces;
+
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.richfaces.component.AjaxSuggestionEvent;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.03.2007
+ *
+ */
+public class AjaxListener implements org.ajax4jsf.framework.ajax.AjaxListener {
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxListener#processAjax(org.ajax4jsf.framework.ajax.AjaxEvent)
+ */
+ public void processAjax(AjaxEvent event) {
+ System.out.println("AjaxListener.processAjax()");
+ if (event instanceof AjaxSuggestionEvent) {
+ AjaxSuggestionEvent ajaxSuggestionEvent = (AjaxSuggestionEvent) event;
+
+ System.out.println("Submitted value: " +
ajaxSuggestionEvent.getSubmittedValue());
+ }
+ }
+
+}
Modified: trunk/richfaces-samples/suggestionbox-sample/src/main/webapp/pages/index.jsp
===================================================================
---
trunk/richfaces-samples/suggestionbox-sample/src/main/webapp/pages/index.jsp 2007-03-27
19:34:43 UTC (rev 178)
+++
trunk/richfaces-samples/suggestionbox-sample/src/main/webapp/pages/index.jsp 2007-03-27
19:54:16 UTC (rev 179)
@@ -48,6 +48,8 @@
height="#{suggestionBox.height}"
shadowDepth="#{suggestionBox.shadowDepth}"
cellpadding="#{suggestionBox.cellpadding}">
+
+ <a4j:ajaxListener type="org.richfaces.AjaxListener"/>
<h:column>
<h:outputText value="#{result.text}"/>
</h:column>
Show replies by date