Author: jjamrich
Date: 2011-08-01 14:42:52 -0400 (Mon, 01 Aug 2011)
New Revision: 22578
Added:
modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
Log:
Fix valueChangeListener attr in rich:editor
rich:editor is supposed to edit text longer than few chars.
Created handling method for tracking valueChange event with logging only
less than 20 chars per value.
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-08-01
16:29:56 UTC (rev 22577)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-08-01
18:42:52 UTC (rev 22578)
@@ -430,6 +430,26 @@
public void changeEventListener(ValueChangeEvent event) {
logToPage("*2 value changed: " + event.getOldValue() + " ->
" + event.getNewValue());
}
+
+
+ /** A value change listener that logs to the page old and new value.
+ * But if event value was longer that 20 chars, only first 20 chars will
+ * be logged
+ *
+ * @param event
+ * an event representing the activation of a user interface component
+ */
+ public void valueChangeListenerImproved(ValueChangeEvent event) {
+
+ String oldVal = event.getOldValue() != null ? event.getOldValue().toString() :
null;
+ String newVal = event.getNewValue() != null ? event.getNewValue().toString() :
null;
+
+ logToPage("*3 value changed: "
+ + (oldVal != null && oldVal.length() > 21 ? oldVal.substring(0,
20) : oldVal != null ? oldVal : "null")
+ + " -> "
+ + (newVal != null && newVal.length() > 21 ? newVal.substring(0,
20) : newVal != null ? newVal : "null")
+ );
+ }
public boolean getExecuteChecker() {
return true;
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01
16:29:56 UTC (rev 22577)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richEditor/simple.xhtml 2011-08-01
18:42:52 UTC (rev 22578)
@@ -55,7 +55,7 @@
title="#{richEditorBean.attributes['title'].value}"
toolbar="#{richEditorBean.attributes['toolbar'].value}"
value="#{richEditorBean.attributes['value'].value}"
-
valueChangeListener="#{richEditorBean.attributes['valueChangeListener'].value}"
+
valueChangeListener="#{richBean.valueChangeListenerImproved}"
width="#{richEditorBean.attributes['width'].value}"
/>
<br/>
Added:
modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java
===================================================================
---
modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/RichBeanTestCase.java 2011-08-01
18:42:52 UTC (rev 22578)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer;
+
+import javax.faces.event.ValueChangeEvent;
+
+import org.junit.Test;
+import org.richfaces.tests.metamer.bean.RichBean;
+
+/**
+ * Tests for RichBean testing methods
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class RichBeanTestCase {
+
+ /**
+ * Test method for {@link
org.richfaces.tests.metamer.bean.RichBean#valueChangeListenerImproved(javax.faces.event.ValueChangeEvent)}.
+ */
+ @Test
+ public void testValueChangeListenerImproved() {
+
+ RichBean rb = new RichBean();
+ String oldValue = "";
+ String newValue = "";
+
+ ValueChangeEvent changeEvent = new ValueChangeEvent(null, oldValue, newValue);
+
+ rb.valueChangeListenerImproved(changeEvent);
+
+ }
+
+}