JBoss Rich Faces SVN: r6808 - trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-03-14 09:14:03 -0400 (Fri, 14 Mar 2008)
New Revision: 6808
Modified:
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js
Log:
fix input position after select
Modified: trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js
===================================================================
--- trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js 2008-03-14 13:01:01 UTC (rev 6807)
+++ trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js 2008-03-14 13:14:03 UTC (rev 6808)
@@ -59,5 +59,14 @@
if (this.iframe) {
this.iframe.style.width = correction;
}
+ },
+
+ hide : function() {
+ this.resetState();
+ if (this.iframe) {
+ this.iframe.hide();
+ }
+ var component = this.listParent.parentNode;
+ this.listParent.hide();
}
});
16 years, 10 months
JBoss Rich Faces SVN: r6807 - in trunk/samples/richfaces-demo/src/main/webapp/richfaces: modalPanel and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2008-03-14 09:01:01 -0400 (Fri, 14 Mar 2008)
New Revision: 6807
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/componentControl/examples/mpusage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/modalPanel/usage.xhtml
Log:
http://jira.jboss.com/jira/browse/RF-2136
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/componentControl/examples/mpusage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/componentControl/examples/mpusage.xhtml 2008-03-14 11:53:28 UTC (rev 6806)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/componentControl/examples/mpusage.xhtml 2008-03-14 13:01:01 UTC (rev 6807)
@@ -20,8 +20,10 @@
<br/>
<h:outputText value="Closure link (X) works also through Component Control"></h:outputText>
</rich:modalPanel>
+ <rich:spacer height="10px" width="100%"/>
<h:outputLink value="#" id="link">
Show Modal Panel
<rich:componentControl for="panel" attachTo="link" operation="show" event="onclick"/>
</h:outputLink>
+ <rich:spacer height="10px" width="100%"/>
</f:subview>
\ No newline at end of file
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/modalPanel/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/modalPanel/usage.xhtml 2008-03-14 11:53:28 UTC (rev 6806)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/modalPanel/usage.xhtml 2008-03-14 13:01:01 UTC (rev 6807)
@@ -24,6 +24,19 @@
</ui:include>
</div>
+ <p>
+ Modal Panel could be also managed with <b>rich:componentControl</b> component.
+ Next example shows the code which should be used:
+ </p>
+ <div class="sample-container">
+
+ <ui:include src="/richfaces/componentControl/examples/mpusage.xhtml"/>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath" value="/richfaces/componentControl/examples/mpusage.xhtml"/>
+ <ui:param name="openlabel" value="View Page Source" />
+ </ui:include>
+
+ </div>
<p>The modal panel has an absolute layout.There is no reason to put in on the page
where it is called.If you want to perform submits from this modal panel, you should have a separate form inside it.
In this case, the panel must be declared outside of the other form on the same page.
16 years, 10 months
JBoss Rich Faces SVN: r6806 - trunk/samples/dropdownmenu-sample/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: vbaranov
Date: 2008-03-14 07:53:28 -0400 (Fri, 14 Mar 2008)
New Revision: 6806
Modified:
trunk/samples/dropdownmenu-sample/src/main/webapp/pages/test.jsp
Log:
Update test for http://jira.jboss.com/jira/browse/RF-2102
Modified: trunk/samples/dropdownmenu-sample/src/main/webapp/pages/test.jsp
===================================================================
--- trunk/samples/dropdownmenu-sample/src/main/webapp/pages/test.jsp 2008-03-14 11:49:30 UTC (rev 6805)
+++ trunk/samples/dropdownmenu-sample/src/main/webapp/pages/test.jsp 2008-03-14 11:53:28 UTC (rev 6806)
@@ -21,8 +21,7 @@
<tr>
<td>
<h:form>
-
- <ddm:dropDownMenu value="File">
+ <ddm:dropDownMenu value="File" event="onmouseover">
<mc:menuItem submitMode="ajax" value="New"/>
<mc:menuItem submitMode="ajax" value="Open"/>
@@ -33,11 +32,17 @@
</mc:menuGroup>
<mc:menuItem submitMode="ajax" value="Close"/>
+
+ <mc:menuItem submitMode="none">
+ <h:outputLink value="www.jboss.org">
+ <h:outputText value="jboss"/>
+ </h:outputLink>
+ </mc:menuItem>
+
<mc:menuSeparator id="menuSeparator11" />
<mc:menuItem submitMode="ajax" value="Exit"/>
</ddm:dropDownMenu>
-
</h:form>
</td>
</tr>
16 years, 10 months
JBoss Rich Faces SVN: r6805 - in trunk/ui/menu-components/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: vbaranov
Date: 2008-03-14 07:49:30 -0400 (Fri, 14 Mar 2008)
New Revision: 6805
Modified:
trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2102
Modified: trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2008-03-14 11:49:23 UTC (rev 6804)
+++ trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2008-03-14 11:49:30 UTC (rev 6805)
@@ -971,7 +971,7 @@
RichFaces.Menu.Layers.LMPopUpL(this.id, false);
// if (this.eventOnClose) this.eventOnClose();
},
- asDropDown: function(topLevel, onEvt, offEvt, options){
+ asDropDown: function(topLevel, bindElementId, onEvt, offEvt, options){
this.options = options || {};
if (this.options.ongroupactivate){
this.eventOnGroupActivate = this.options.ongroupactivate.bindAsEventListener(this);
@@ -1017,30 +1017,30 @@
}
offEvt = this.eventJsToPrototype(offEvt);
- var addBinding = function(eventName, handler) {
- var binding = new RichFaces.Menu.Layer.Binding(topLevel, eventName, handler);
+ var addBinding = function(elementId, eventName, handler) {
+ var binding = new RichFaces.Menu.Layer.Binding(elementId, eventName, handler);
this.bindings.push(binding);
binding.refresh();
}.bind(this);
if (onEvt == 'mouseover') {
- addBinding(onEvt, function(e) {
+ addBinding(topLevel, onEvt, function(e) {
menuOn.call(this, e);
mouseover.call(this, e);
}.bindAsEventListener(this));
} else {
- addBinding(onEvt, menuOn.bindAsEventListener(this));
- addBinding('mouseover', mouseover.bindAsEventListener(this));
+ addBinding(bindElementId, onEvt, menuOn.bindAsEventListener(this));
+ addBinding(topLevel, 'mouseover', mouseover.bindAsEventListener(this));
}
if (offEvt == 'mouseout') {
- addBinding(offEvt, function(e) {
+ addBinding(topLevel, offEvt, function(e) {
menuOff.call(this, e);
mouseout.call(this, e);
}.bindAsEventListener(this));
} else {
- addBinding(offEvt, menuOff.bindAsEventListener(this));
- addBinding('mouseout', mouseout.bindAsEventListener(this));
+ addBinding(bindElementId, offEvt, menuOff.bindAsEventListener(this));
+ addBinding(topLevel, 'mouseout', mouseout.bindAsEventListener(this));
}
RichFaces.Menu.Layers.horizontals[this.id] = topLevel;
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2008-03-14 11:49:23 UTC (rev 6804)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2008-03-14 11:49:30 UTC (rev 6805)
@@ -67,7 +67,7 @@
$('#{clientId}:icon').className='dr-menu-icon dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected #{component.attributes['iconClass']}';
Element.addClassName($('#{clientId}:anchor'), 'rich-menu-item-label-selected');"
style="#{menuItemStyle}"
- onclick="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled #{component.attributes['styleClass']}'; #{onselect} #{onclick}; Event.stop(event);"
+ onclick="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled #{component.attributes['styleClass']}'; #{onselect} #{onclick};"
onmouseup="Event.stop(event); #{component.attributes['onmouseup']}">
<f:call name="utils.encodeAttributes">
<f:parameter value="onmousedown,onmousemove" />
16 years, 10 months
JBoss Rich Faces SVN: r6804 - in trunk/ui/dropdown-menu/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: vbaranov
Date: 2008-03-14 07:49:23 -0400 (Fri, 14 Mar 2008)
New Revision: 6804
Modified:
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2102
Modified: trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2008-03-14 11:45:29 UTC (rev 6803)
+++ trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2008-03-14 11:49:23 UTC (rev 6804)
@@ -75,6 +75,7 @@
buffer.append(".");
function = new JSFunction("asDropDown");
function.addParameter(component.getClientId(context));
+ function.addParameter(component.getClientId(context) + "_span");
String evt = (String) component.getAttributes().get("event");
if(evt == null || evt.trim().length() == 0){
evt = "onmouseover";
Modified: trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
--- trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2008-03-14 11:45:29 UTC (rev 6803)
+++ trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2008-03-14 11:49:23 UTC (rev 6804)
@@ -39,7 +39,7 @@
</jsp:scriptlet> <span class="dr-label-text-decor rich-label-text-decor"> <u:insertFacet
name="label" /> </span> <jsp:scriptlet>
<![CDATA[} else {]]>
- </jsp:scriptlet> <span class="dr-label-text-decor rich-label-text-decor">#{component.attributes['value']}</span>
+ </jsp:scriptlet> <span id="#{clientId}_span" class="dr-label-text-decor rich-label-text-decor">#{component.attributes['value']}</span>
<jsp:scriptlet>
<![CDATA[}]]>
</jsp:scriptlet>
16 years, 10 months
JBoss Rich Faces SVN: r6802 - trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/tree.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2008-03-14 07:30:05 -0400 (Fri, 14 Mar 2008)
New Revision: 6802
Modified:
trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/tree/data.txt
Log:
http://jira.jboss.com/jira/browse/RF-2090
Modified: trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/tree/data.txt
===================================================================
--- trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/tree/data.txt 2008-03-14 11:15:48 UTC (rev 6801)
+++ trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/tree/data.txt 2008-03-14 11:30:05 UTC (rev 6802)
@@ -1,5 +1,5 @@
-Yes Sir,I Can Boogie Baccara Grand Collection 6750318 242 1 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 220 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\01 Yes Sir,I Can Boogie.m4a
-Soryy,i`m A Lady Baccara Grand Collection 7643797 266 2 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 227 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\02 Soryy,i`m A Lady.m4a
+Yes Sir, I Can Boogie Baccara Grand Collection 6750318 242 1 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 220 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\01 Yes Sir, I Can Boogie.m4a
+Sory, i`m A Lady Baccara Grand Collection 7643797 266 2 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 227 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\02 Soryy,i`m A Lady.m4a
A Quien Le Importa Baccara Grand Collection 7649974 270 3 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 224 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\03 A Quien Le Importa.m4a
The Devil Send You To Laredo Baccara Grand Collection 6084233 222 4 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 216 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\04 The Devil Send You To Laredo.m4a
Ni Mas Ni Menos Baccara Grand Collection 5323998 219 5 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 192 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\05 Ni Mas Ni Menos.m4a
@@ -11,7 +11,7 @@
Me Tienes Desenganada Baccara Grand Collection 6989122 238 11 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 232 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\11 Me Tienes Desenganada.m4a
El Porompompero Baccara Grand Collection 6711469 236 12 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 225 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\12 El Porompompero.m4a
Yes Sir, I Can Boogie Baccara Grand Collection 4820326 255 13 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 149 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\13 Yes Sir, I Can Boogie.m4a
-Sorry,i`m A Lady Baccara Grand Collection 5844870 217 14 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 213 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\14 Sorry,i`m A Lady.m4a
+Sorry, i`m A Lady Baccara Grand Collection 5844870 217 14 1999 7/4/2005 2:15 PM 5/7/2005 3:36 PM 213 44100 AAC audio file www.allofmp3.com M:\My Music\Baccara\Grand Collection\14 Sorry, i`m A Lady.m4a
Brandenburg Concerto No 1-1 I Bach, Johann Sebastian Forever Classics Other 6778589 282 1996 7/4/2005 2:00 PM 4/24/2004 7:31 AM 192 44100 MPEG audio file M:\My Music\Bach, Johann Sebastian\Forever Classics\Brandenburg Concerto No 1-1 I.mp3
Brandenburg Concerto No 1-2 I Bach, Johann Sebastian Forever Classics Other 6181116 257 1996 7/4/2005 2:00 PM 4/24/2004 7:31 AM 192 44100 MPEG audio file M:\My Music\Bach, Johann Sebastian\Forever Classics\Brandenburg Concerto No 1-2 I.mp3
Brandenburg Concerto No 1-3 I Bach, Johann Sebastian Forever Classics Other 8123999 338 1996 7/4/2005 2:00 PM 4/24/2004 7:31 AM 192 44100 MPEG audio file M:\My Music\Bach, Johann Sebastian\Forever Classics\Brandenburg Concerto No 1-3 I.mp3
16 years, 10 months
JBoss Rich Faces SVN: r6801 - in trunk: cdk/generator/src/main/resources/META-INF/templates12 and 46 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-14 07:15:48 -0400 (Fri, 14 Mar 2008)
New Revision: 6801
Added:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/ConstantlyFailingLiteralValueExpression.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/EnumSupportExpressionFactoryWrapper.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/JsfMock.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/LiteralValueExpression.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockApplication.java
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm
trunk/framework/api/src/main/java/org/richfaces/model/Ordering.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java
trunk/framework/test/pom.xml
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractJspTestCase.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockMethodExpression.java
trunk/samples/inplaceInput-sample/
trunk/samples/inplaceSelect-sample/
trunk/samples/richfaces-ear-demo/ejb/
trunk/samples/richfaces-ear-demo/richfacesEAR/
trunk/samples/richfaces-ear-demo/webapp/
trunk/samples/seamEAR/
trunk/samples/seamEAR/ear/
trunk/samples/seamEAR/ejbs/
trunk/samples/seamEAR/primary-source/
trunk/samples/seamEAR/projects/logging/
trunk/samples/seamEAR/wars/seamWebapp/
trunk/ui/combobox/
trunk/ui/componentControl/
trunk/ui/contextMenu/
trunk/ui/core/
trunk/ui/dataFilterSlider/
trunk/ui/dataTable/
trunk/ui/datascroller/
trunk/ui/dropdown-menu/
trunk/ui/effect/
trunk/ui/fileUpload/
trunk/ui/gmap/
trunk/ui/inplaceInput/
trunk/ui/inplaceSelect/
trunk/ui/insert/
trunk/ui/jQuery/
trunk/ui/listShuttle/
trunk/ui/menu-components/
trunk/ui/message/
trunk/ui/modal-panel/
trunk/ui/orderingList/
trunk/ui/panelbar/
trunk/ui/panelmenu/
trunk/ui/pickList/
trunk/ui/progressBAR/
trunk/ui/scrollableDataTable/
trunk/ui/simpleTogglePanel/
trunk/ui/suggestionbox/
trunk/ui/togglePanel/
trunk/ui/toolBar/
trunk/ui/treeModel/
trunk/ui/virtualEarth/
Log:
improved tag tests
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -129,7 +129,7 @@
}
try {
- Class<?> clazz = Class.forName(className);
+ Class<?> clazz = Class.forName(className, false, loader);
if (clazz.isAssignableFrom(String.class)) {
if (number == 0) {
return "\"" + propertyName + "\"";
@@ -161,7 +161,7 @@
}
private String enumToString(Enum<?> e) {
- return e.getClass().getName() + "." + e;
+ return e.getDeclaringClass().getName() + "." + e;
}
public String getTestData(PropertyBean propertyBean) {
@@ -178,6 +178,29 @@
*/
public boolean isNativelySupported(PropertyBean propertyBean) {
String classname = propertyBean.getClassname();
- return testData.containsKey(classname) || "java.lang.String".equals(classname);
+ return testData.containsKey(classname) || isAssignabelFromString(propertyBean) || isEnum(propertyBean);
+
}
+
+ protected boolean isAssignabelFromString(PropertyBean bean) {
+ String classname = bean.getClassname();
+ Class<?> class1;
+ try {
+ class1 = Class.forName(classname, false, loader);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ return class1.isAssignableFrom(String.class);
+ }
+
+ protected boolean isEnum(PropertyBean bean) {
+ String classname = bean.getClassname();
+ Class<?> class1;
+ try {
+ class1 = Class.forName(classname, false, loader);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ return class1.isEnum();
+ }
}
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm 2008-03-14 11:15:48 UTC (rev 6801)
@@ -11,8 +11,8 @@
import ${component.classname};
/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/03 21:05:14 $
+ * @author shura (latest modification by Maksim Kaszynski)
+ * @version 3.2.0
*
*/
public class $tag.simpleClassName extends $tag.superclass {
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm 2008-03-14 11:15:48 UTC (rev 6801)
@@ -4,9 +4,13 @@
*/
package ${tag.packageName};
+import static org.easymock.classextension.EasyMock.*;
+import static org.ajax4jsf.tests.JsfMock.*;
+
#foreach($import in $imports)
import $import ;
#end
+
import javax.faces.convert.Converter ;
import javax.faces.context.FacesContext ;
import javax.faces.component.UIComponent;
@@ -42,8 +46,8 @@
import org.ajax4jsf.tests.Condition;
/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/03 21:05:14 $
+ * @author Maksim Kaszynski
+ * @since 3.2.0
*
*/
public class $tag.test.simpleClassName extends $tag.test.superclassname {
@@ -74,29 +78,6 @@
application.addConverter(this.getClass().getName(), MyConverter.class.getName());
tag = new ${tag.simpleClassName}();
tag.setPageContext(pageContext);
- tag.setParent(new UIComponentELTag(){
-
- public String getComponentType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRendererType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int doStartTag() throws JspException {
- // TODO Auto-generated method stub
- return Tag.EVAL_BODY_INCLUDE;
- }
-
- public int doEndTag() throws JspException {
- // TODO Auto-generated method stub
- return Tag.EVAL_BODY_INCLUDE;
- }
-
- });
}
@@ -109,355 +90,209 @@
#foreach( $prop in $component.properties )
#if( !$prop.existintag && !$prop.hidden)
public void ${generator.getSetterTestName($prop)}() {
- ${component.simpleClassName} component = new ${component.simpleClassName}();
+ ${component.simpleClassName} component = createNiceMock(${component.simpleClassName}.class);
#if($prop.name == 'actionListener')
- final Condition condition0 = new Condition("Expecting addActionListener call");
- final List<ActionListener> listeners = new ArrayList<ActionListener>();
- component = new ${component.simpleClassName}() {
- @Override
- public void addActionListener(ActionListener listener) {
- condition0.setTrue();
- listeners.add(listener);
- super.addActionListener(listener);
- }
- };
-
String expression = "#{bean.actionListener}";
MockMethodExpression _actionListener = new MockMethodExpression(expression, null, null);
tag.setActionListener(_actionListener);
+ component.addActionListener(meActionListener(_actionListener));
+ expectLastCall().once();
+ replay(component);
tag.setProperties(component);
- //Check addListener method is called
- evaluate(condition0);
- //Check listener was really added
- assertFalse(listeners.isEmpty());
- //Now try to invoke listener to see that underlying method expression is triggered
- ActionEvent event = new ActionEvent(component);
- for (ActionListener actionListener : listeners) {
- try {
- actionListener.processAction(event);
- } catch(Exception e) {
- //ignore any exceptions in listeners
- }
- }
- List<Object[]> invocationArgs = _actionListener.getInvocationArgs();
- assertNotNull(invocationArgs);
- assertFalse(invocationArgs.isEmpty());
- assertEquals(1, invocationArgs.size());
- Object[] objects = invocationArgs.get(0);
- assertEquals(1, objects.length);
- assertEquals(event, objects[0]);
-
+ verify(component);
+
#elseif($prop.name == 'action')
- final String expression = "#{bean.action}";
- final MockMethodExpression action = new MockMethodExpression(expression, null, null);
- final Condition conditionA = new Condition("expecting setActionExpression to be called");
- component = new ${component.simpleClassName}(){
- @Override
- public void setActionExpression(MethodExpression actionExpression) {
- assertNotNull(actionExpression);
- assertEquals(expression, actionExpression.getExpressionString());
- conditionA.setTrue();
- super.setActionExpression(actionExpression);
- }
- };
+ String expression = "#{bean.action}";
+ MockMethodExpression action = new MockMethodExpression(expression, null, null);
+ component.setActionExpression(same(action));
+ expectLastCall().once();
tag.setAction(action);
+ replay(component);
tag.setProperties(component);
- evaluate(conditionA);
+ verify(component);
#elseif($prop.name == 'valueChangeListener')
- final Condition condition0 = new Condition("Expecting addValueChangeListener call");
- final List<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
- component = new ${component.simpleClassName}() {
- @Override
- public void addValueChangeListener(ValueChangeListener listener) {
- condition0.setTrue();
- listeners.add(listener);
- super.addValueChangeListener(listener);
- }
- };
-
String expression = "#{bean.actionListener}";
MockMethodExpression valueChangeListener = new MockMethodExpression(expression, null, null);
tag.setValueChangeListener(valueChangeListener);
+ component.addValueChangeListener(meValueChangeListener(valueChangeListener));
+ expectLastCall().once();
+ replay(component);
tag.setProperties(component);
- //Check addListener method is called
- evaluate(condition0);
- //Check listener was really added
- assertFalse(listeners.isEmpty());
- //Now try to invoke listener to see that underlying method expression is triggered
- ValueChangeEvent event = new ValueChangeEvent(component, new Object(), new Object());
- for (ValueChangeListener listener : listeners) {
- try {
- listener.processValueChange(event);
- } catch(Exception e) {
- //ignore any exceptions in listeners
- }
- }
- List<Object[]> invocationArgs = valueChangeListener.getInvocationArgs();
- assertNotNull(invocationArgs);
- assertFalse(invocationArgs.isEmpty());
- assertEquals(1, invocationArgs.size());
- Object[] objects = invocationArgs.get(0);
- assertEquals(1, objects.length);
- assertEquals(event, objects[0]);
+ verify(component);
#elseif($prop.name == 'validator')
- final Condition condition0 = new Condition(
- "Expecting addValidator call");
- final List<Validator> validators = new ArrayList<Validator>();
- component = new ${component.simpleClassName}() {
- @Override
- public void addValidator(Validator validator) {
- condition0.setTrue();
- validators.add(validator);
- super.addValidator(validator);
- }
- };
-
String expression = "#{bean.validate}";
- MockMethodExpression validator = new MockMethodExpression(
- expression, null, null);
+ MockMethodExpression validator = new MockMethodExpression(expression, null, null);
tag.setValidator(validator);
+ component.addValidator(meValidator(validator));
+ expectLastCall().once();
+ replay(component);
tag.setProperties(component);
- // Check addValidator method is called
- evaluate(condition0);
- // Check validator was really added
- assertFalse(validators.isEmpty());
- // Now try to invoke validator to see that underlying method expression
- // is triggered
- Object value = new Object();
-
- for (Validator validatorItem : validators) {
- try {
- validatorItem.validate(facesContext, component, value);
- } catch (Exception e) {
- //Ignore
- }
- }
-
- List<Object[]> invocationArgs = validator.getInvocationArgs();
- assertNotNull(invocationArgs);
- assertFalse(invocationArgs.isEmpty());
- assertEquals(1, invocationArgs.size());
- Object[] objects = invocationArgs.get(0);
- assertEquals(3, objects.length);
- assertEquals(facesContext, objects[0]);
- assertEquals(component, objects[1]);
- assertEquals(value, objects[2]);
+ verify(component);
#elseif($prop.isInstanceof("javax.el.MethodExpression") || $prop.isInstanceof("javax.faces.el.MethodBinding"))
- final String expression = "#{bean.${prop.name}}";
- final MockMethodExpression _${prop.name} = new MockMethodExpression(expression, null, null);
- final Condition conditionMB = new Condition("expecting ${prop.setterName} to be called");
- component = new ${component.simpleClassName}(){
- @Override
- public void ${prop.setterName}(${prop.classname} __${prop.name}) {
- assertNotNull(__${prop.name});
- assertEquals(expression, __${prop.name}.getExpressionString());
- conditionMB.setTrue();
- super.${prop.setterName}(__${prop.name});
- }
- };
+ #if($prop.isInstanceof("javax.el.MethodExpression"))
+ #set($matcher = 'meEqToMe')
+ #else
+ #set($matcher = 'mbEqToMe')
+ #end
+ String expression = "#{bean.${prop.name}}";
+ MockMethodExpression _${prop.name} = new MockMethodExpression(expression, null, null);
+ component.${prop.setterName}(${matcher}(_${prop.name}));
+ replay(component);
tag.${prop.setterName}(_${prop.name});
tag.setProperties(component);
- evaluate(conditionMB);
+ verify(component);
#elseif($prop.isInstanceof("javax.el.ValueExpression"))
- final ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{bean.${prop.name}}", Object.class);
- final Condition conditionVE = new Condition("expecting ${prop.setterName} to be called");
- component = new ${component.simpleClassName}(){
- @Override
- public void ${prop.setterName}(ValueExpression ve) {
- assertNotNull(ve);
- if (ve.equals(expression)) {
- conditionVE.setTrue();
- }
- super.${prop.setterName}(ve);
- }
- };
- //Then test literal one
+ final ValueExpression expression = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ component.${prop.setterName}(same(expression));
+ expectLastCall().once();
+ replay(component);
tag.${prop.setterName}(expression);
tag.setProperties(component);
- evaluate(conditionVE);
+ verify(component);
#elseif($prop.isInstanceof("javax.faces.el.ValueBinding"))
- final ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{bean.${prop.name}}", Object.class);
- final Condition conditionVB = new Condition("expecting ${prop.setterName} to be called");
- component = new ${component.simpleClassName}(){
- @Override
- public void ${prop.setterName}(javax.faces.el.ValueBinding vb) {
- assertNotNull(vb);
- if (vb.getExpressionString().equals(expression.getExpressionString())) {
- conditionVB.setTrue();
- }
- super.${prop.setterName}(vb);
- }
- };
+ final ValueExpression expression = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ component.${prop.setterName}(vbEqToVe(expression));
//Then test literal one
+ expectLastCall().once();
+
+ replay(component);
tag.${prop.setterName}(expression);
tag.setProperties(component);
- evaluate(conditionVB);
+ verify(component);
#elseif($prop.el)
//el=true
- final Condition condition = new Condition("expecting setValueExpression(\"${prop.name}\") to be called");
- component = new ${component.simpleClassName}() {
- @Override
- public void setValueExpression(String name, ValueExpression binding) {
- if (name.equals("${prop.name}")) {
- condition.setTrue();
- }
- super.setValueExpression(name, binding);
- }
- };
- ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{bean.${prop.name}}", ${prop.classname}.class);
+ ValueExpression expression = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ component.setValueExpression(eq("${prop.name}"), same(expression));
+ expectLastCall().once();
+ replay(component);
tag.${prop.setterName}(expression);
tag.setProperties(component);
- evaluate(condition);
+ verify(component);
#if($prop.name == 'converter')
String converterType = this.getClass().getName();
- final Condition conditionC = new Condition("expecting call to setConverter");
- component = new ${component.simpleClassName}(){
- @Override
- public void setConverter(Converter converter) {
- assertTrue(converter instanceof MyConverter);
- conditionC.setTrue();
- super.setConverter(converter);
- }
- };
- expression = expressionFactory.createValueExpression(elContext, converterType, String.class);
+ expression = new org.ajax4jsf.tests.LiteralValueExpression(converterType);
+ reset(component);
+ component.setConverter(isA(MyConverter.class));
tag.setConverter(expression);
+ replay(component);
tag.setProperties(component);
- evaluate(conditionC);
-
+ verify(component);
#elseif(!$prop.elonly && ${testDataGenerator.isNativelySupported($prop)})
//In case of literal VE
- final Condition condition2 = new Condition("expecting ${prop.setterName} to be called");
- final ${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
- component = new ${component.simpleClassName}(){
- @Override
- public void ${prop.setterName}(${prop.classname} __${prop.name}) {
- assertEquals(__${prop.name}, _${prop.name});
- condition2.setTrue();
- super.${prop.setterName}(__${prop.name});
- }
- };
- expression = expressionFactory.createValueExpression(elContext, String.valueOf(_${prop.name}), ${prop.classname}.class);
+ ${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
+ reset(component);
+ expression = new org.ajax4jsf.tests.LiteralValueExpression(_${prop.name});
+ component.${prop.setterName}(eq(_${prop.name}));
+ expectLastCall().once();
+
tag.${prop.setterName}(expression);
+ replay(component);
tag.setProperties(component);
- evaluate(condition2);
- //Then test literal one
+ verify(component);
+
+ try {
+ //Now test evaluation of literal
+ expression = new org.ajax4jsf.tests.ConstantlyFailingLiteralValueExpression();
+ tag.${prop.setterName}(expression);
+ tag.setProperties(component);
+ fail("An exception should be thrown");
+ } catch(javax.faces.FacesException e) {
+ //It's ok to throw faces Exception, but its cause should be ELException
+ assertTrue(e.getCause() instanceof javax.el.ELException);
+ }
#end
#else
- //Case of el="false"
- final Condition condition3 = new Condition("expecting ${prop.setterName} to be called");
- final ${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
- component = new ${component.simpleClassName}(){
- @Override
- public void ${prop.setterName}(${prop.classname} __${prop.name}) {
- condition3.setTrue();
- assertEquals(__${prop.name},_${prop.name});
- super.${prop.setterName}(__${prop.name});
- }
- };
- //Then test literal one
+ ${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
+ reset(component);
+ component.${prop.setterName}(eq(_${prop.name}));
+ expectLastCall().once();
+
tag.${prop.setterName}(String.valueOf(_${prop.name}));
+ replay(component);
tag.setProperties(component);
- evaluate(condition3);
+ verify(component);
+
#end
}
#end
#end
-
-
-/**
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag && !$prop.hidden)
- #if($prop.name == "action")
- setActionProperty(comp, this._${prop.name});
- #elseif($prop.name == "actionListener")
- setActionListenerProperty(comp, this._${prop.name});
- #elseif($prop.name == "converter")
- setConverterProperty(comp, this._${prop.name});
- #elseif($prop.name == "validator")
- setValidatorProperty(comp, this._${prop.name});
- #elseif($prop.name == "valueChangeListener")
- setValueChangeListenerProperty(comp, this._${prop.name});
- #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
- if(null != this._${prop.name}){
- if (!this._${prop.name}.isLiteralText())
- {
- MethodBinding mb = new MethodBindingMethodExpressionAdaptor(this._${prop.name});
- ((${component.simpleClassName})component).${prop.setterName}(mb);
- }
- else
- {
- getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
- }
- }
- #elseif($prop.isInstanceof("javax.faces.el.ValueBinding") )
- if(null != this._${prop.name}){
- ValueBinding vb = new ValueBindingValueExpressionAdaptor(this._${prop.name});
- ((${component.simpleClassName})component).${prop.setterName}(vb);
- }
- #elseif($prop.isInstanceof("javax.el.MethodExpression") )
- if(null != this._${prop.name}){
- ((${component.simpleClassName})component).${prop.setterName}(this._${prop.name});
- }
- #else
- #if($prop.elonly)
- if(null != this._${prop.name} && this._${prop.name}.isLiteralText()){
- throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext()) +" allows only EL expressions for property ${prop.name}");
- }
- #end
-
- #if ($prop.el)
- if (this._${prop.name} != null) {
- if (this._${prop.name}.isLiteralText()) {
- try {
- #if (${prop.simpleType})
- #set ($propertyClass = ${prop.boxingClass})
- #else
- #set ($propertyClass = ${prop.classname})
- #end
-
- $propertyClass __${prop.name} = ($propertyClass) getFacesContext().
- getApplication().
- getExpressionFactory().
- coerceToType(this._${prop.name}.getExpressionString(),
- ${propertyClass}.class);
-
- #if (${prop.simpleType})
- comp.${prop.setterName}(__${prop.name}.${prop.classname}Value());
- #else
- comp.${prop.setterName}(__${prop.name});
- #end
- } catch (ELException e) {
- throw new FacesException(e);
- }
- } else {
- component.setValueExpression("${prop.name}", this._${prop.name});
- }
- }
- #else
- #if (!${prop.simpleType})
- if (this._${prop.name} != null) {
- #end
+ public void testRelease() {
+ ${component.simpleClassName} component = createMock(${component.simpleClassName}.class);
+
+ try {
+ java.lang.reflect.Method [] methodsToMock = {
+ #foreach( $prop in $component.properties )
+ #if( !$prop.existintag && !$prop.hidden)
+ ${component.simpleClassName}.class.getMethod("${prop.setterName}", ${prop.classname}.class),
+ #end
+ #end //We mock set rendered to work around easy mock's limitation
+ ${component.simpleClassName}.class.getMethod("setValueExpression", String.class, ValueExpression.class)
- comp.${prop.setterName}(this._${prop.name});
+ };
- #if (!${prop.simpleType})
- }
- #end
- #end
- #end
- #end
-#end
-*/
+ component = createMock(${component.simpleClassName}.class, methodsToMock);
+ } catch(NoSuchMethodException e) {
+ fail("NoSuchMethod" + e.getMessage());
+ }
+
+ #foreach( $prop in $component.properties )
+ #if( !$prop.existintag && !$prop.hidden)
+ //First check EL-properties (value and method expressions)
+ #if($prop.isInstanceof("javax.el.MethodExpression") || $prop.isInstanceof("javax.faces.el.MethodBinding"))
+ MethodExpression ${prop.name}Me = new org.ajax4jsf.tests.MockMethodExpression("#{bean.${prop.name}}", null, null);
+ tag.${prop.setterName}(${prop.name}Me);
+ #elseif ($prop.el)
+ ValueExpression ${prop.name}Ve = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ tag.${prop.setterName}(${prop.name}Ve);
+ #end
+ #end
+ #end
+ tag.release();
+
+ replay(component);
+ tag.setProperties(component);
+ verify(component);
+ reset(component);
+
+ //Then check for literal and non-el properties
+
+ #foreach( $prop in $component.properties )
+ #if( !$prop.existintag && !$prop.hidden)
+ //First check EL-properties (value and method expressions)
+ #if($prop.isInstanceof("javax.el.MethodExpression") || $prop.isInstanceof("javax.faces.el.MethodBinding"))
+ #if (!$prop.elonly)
+ tag.${prop.setterName}(new org.ajax4jsf.tests.MockMethodExpression("${prop.name}", null, null));
+ #end
+ #elseif ($prop.el && !$prop.elonly && ${testDataGenerator.isNativelySupported($prop)})
+ tag.${prop.setterName}(new org.ajax4jsf.tests.LiteralValueExpression(String.valueOf(${testDataGenerator.getTestVeData($prop)})));
+ #elseif (!$prop.el && ${testDataGenerator.isNativelySupported($prop)})
+ tag.${prop.setterName}(String.valueOf(${testDataGenerator.getTestVeData($prop)}));
+ #end
+ #end
+ #end
+ tag.release();
+
+ replay(component);
+
+ tag.setProperties(component);
+ verify(component);
+ }
+
+
public void testGetRendererType(){
- //assertEquals(tag.getRendererType(), $);
+ #if(${component.renderer.name})
+ assertEquals(tag.getRendererType(), "${component.renderer.name}");
+ #else
+ assertEquals(tag.getRendererType(), null);
+ #end
}
public void testGetComponentType(){
Modified: trunk/framework/api/src/main/java/org/richfaces/model/Ordering.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/Ordering.java 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/framework/api/src/main/java/org/richfaces/model/Ordering.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -5,7 +5,7 @@
*
*/
public enum Ordering {
- ASCENDING {},
- DESCENDING {},
- UNSORTED {}
+ ASCENDING,
+ DESCENDING,
+ UNSORTED
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -77,21 +77,21 @@
protected void setProperties(UIComponent component)
{
super.setProperties(component);
- component.setValueExpression(HTML.dir_ATTRIBUTE, _dir);
- component.setValueExpression(HTML.lang_ATTRIBUTE, _lang);
- component.setValueExpression(HTML.style_ATTRIBUTE, _style);
- component.setValueExpression(HTML.title_ATTRIBUTE, _title);
- component.setValueExpression(HTML.STYLE_CLASS_ATTR, _styleClass);
- component.setValueExpression(HTML.onclick_ATTRIBUTE, _onclick);
- component.setValueExpression(HTML.ondblclick_ATTRIBUTE, _ondblclick);
- component.setValueExpression(HTML.onmousedown_ATTRIBUTE, _onmousedown);
- component.setValueExpression(HTML.onmouseup_ATTRIBUTE, _onmouseup);
- component.setValueExpression(HTML.onmouseover_ATTRIBUTE, _onmouseover);
- component.setValueExpression(HTML.onmousemove_ATTRIBUTE, _onmousemove);
- component.setValueExpression(HTML.onmouseout_ATTRIBUTE, _onmouseout);
- component.setValueExpression(HTML.onkeypress_ATTRIBUTE, _onkeypress);
- component.setValueExpression(HTML.onkeydown_ATTRIBUTE, _onkeydown);
- component.setValueExpression(HTML.onkeyup_ATTRIBUTE, _onkeyup);
+ setProperty(component, HTML.dir_ATTRIBUTE, _dir);
+ setProperty(component, HTML.lang_ATTRIBUTE, _lang);
+ setProperty(component, HTML.style_ATTRIBUTE, _style);
+ setProperty(component, HTML.title_ATTRIBUTE, _title);
+ setProperty(component, HTML.STYLE_CLASS_ATTR, _styleClass);
+ setProperty(component, HTML.onclick_ATTRIBUTE, _onclick);
+ setProperty(component, HTML.ondblclick_ATTRIBUTE, _ondblclick);
+ setProperty(component, HTML.onmousedown_ATTRIBUTE, _onmousedown);
+ setProperty(component, HTML.onmouseup_ATTRIBUTE, _onmouseup);
+ setProperty(component, HTML.onmouseover_ATTRIBUTE, _onmouseover);
+ setProperty(component, HTML.onmousemove_ATTRIBUTE, _onmousemove);
+ setProperty(component, HTML.onmouseout_ATTRIBUTE, _onmouseout);
+ setProperty(component, HTML.onkeypress_ATTRIBUTE, _onkeypress);
+ setProperty(component, HTML.onkeydown_ATTRIBUTE, _onkeydown);
+ setProperty(component, HTML.onkeyup_ATTRIBUTE, _onkeyup);
}
public void setStyleClass(ValueExpression styleClass)
Modified: trunk/framework/test/pom.xml
===================================================================
--- trunk/framework/test/pom.xml 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/framework/test/pom.xml 2008-03-14 11:15:48 UTC (rev 6801)
@@ -60,13 +60,11 @@
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.2</version>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.2.1</version>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>rhino</groupId>
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -55,6 +55,7 @@
import org.ajax4jsf.tests.org.apache.shale.test.config.ConfigParser;
import org.ajax4jsf.webapp.WebXml;
import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.mock.MockApplication12;
import org.apache.shale.test.mock.MockPrintWriter;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.shale.test.mock.MockServletOutputStream;
@@ -110,6 +111,19 @@
// This method MUST BE OVERRIDEN in any subclasses - since Junit see for it in class for call
super.setUp();
+
+ /*
+ * Don't know yet how to support enums
+ *
+ * expressionFactory = new EnumSupportExpressionFactoryWrapper(application.getExpressionFactory());
+ application = new MockApplication12() {
+ @Override
+ public ExpressionFactory getExpressionFactory() {
+ return expressionFactory;
+ }
+ };
+ facesContext.setApplication(application);
+ */
// Setup FacesContext with necessary init parameters.
this.servletContext.addInitParameter(SkinFactory.SKIN_PARAMETER, getSkinName());
// setup VCP renderKit, create renderers.
@@ -185,7 +199,7 @@
ConfigParser parser = new ConfigParser();
parser.parse(parser.getPlatformURLs());
- Enumeration resources = getClass().getClassLoader().getResources("META-INF/faces-config.xml");
+ Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/faces-config.xml");
while (resources.hasMoreElements()) {
parser.parse((URL) resources.nextElement());
}
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractJspTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractJspTestCase.java 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractJspTestCase.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -10,6 +10,8 @@
import java.util.Map;
import javax.el.ELContext;
+import javax.faces.component.UIOutput;
+import javax.faces.webapp.UIComponentELTag;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.PageContext;
@@ -22,6 +24,7 @@
protected PageContext pageContext = null;
+ protected UIComponentELTag rootTag;
/**
* @param name
*/
@@ -103,12 +106,32 @@
}
}
};
+
+
+ rootTag = new UIComponentELTag() {
+
+ @Override
+ public String getComponentType() {
+ // TODO Auto-generated method stub
+ return UIOutput.COMPONENT_TYPE;
+ }
+
+ @Override
+ public String getRendererType() {
+ return null;
+ }
+
+ };
+
+ rootTag.setPageContext(pageContext);
+ rootTag.doStartTag();
}
@Override
public void tearDown() throws Exception {
pageContext = null;
+ rootTag = null;
super.tearDown();
}
}
Added: trunk/framework/test/src/main/java/org/ajax4jsf/tests/ConstantlyFailingLiteralValueExpression.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/ConstantlyFailingLiteralValueExpression.java (rev 0)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/ConstantlyFailingLiteralValueExpression.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -0,0 +1,92 @@
+/**
+ *
+ */
+package org.ajax4jsf.tests;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+
+/**
+ * Value expression failing when trying
+ * to coerce its expression string to any type
+ * Needed to test tags throw FacesException in that case
+ * @author Maksim Kaszynski
+ *
+ */
+@SuppressWarnings("serial")
+public class ConstantlyFailingLiteralValueExpression extends ValueExpression {
+
+ /* (non-Javadoc)
+ * @see javax.el.ValueExpression#getExpectedType()
+ */
+ @Override
+ public Class<?> getExpectedType() {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ValueExpression#getType(javax.el.ELContext)
+ */
+ @Override
+ public Class<?> getType(ELContext context) {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
+ */
+ @Override
+ public Object getValue(ELContext context) {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
+ */
+ @Override
+ public boolean isReadOnly(ELContext context) {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ValueExpression#setValue(javax.el.ELContext, java.lang.Object)
+ */
+ @Override
+ public void setValue(ELContext context, Object value) {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.Expression#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.Expression#getExpressionString()
+ */
+ @Override
+ public String getExpressionString() {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.Expression#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ throw new ELException("Everything is a stub here");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.Expression#isLiteralText()
+ */
+ @Override
+ public boolean isLiteralText() {
+ return true;
+ }
+
+}
Added: trunk/framework/test/src/main/java/org/ajax4jsf/tests/EnumSupportExpressionFactoryWrapper.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/EnumSupportExpressionFactoryWrapper.java (rev 0)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/EnumSupportExpressionFactoryWrapper.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package org.ajax4jsf.tests;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class EnumSupportExpressionFactoryWrapper extends ExpressionFactory {
+
+ private ExpressionFactory factory;
+ /**
+ *
+ */
+ public EnumSupportExpressionFactoryWrapper(ExpressionFactory factory) {
+ this.factory = factory;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ExpressionFactory#coerceToType(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ public Object coerceToType(Object obj, Class<?> targetType) {
+ if (targetType.isEnum()) {
+ return coerceToEnum(obj, (Class<?>) targetType);
+ }
+ return factory.coerceToType(obj, targetType);
+ }
+
+ @SuppressWarnings("unchecked")
+ private Enum<?> coerceToEnum(Object o, Class clazz) {
+ if (o == null || "".equals(o)) {
+ return null;
+ }
+
+ if (clazz.isInstance(o)) {
+ return (Enum<?>) o;
+ }
+
+ if (o instanceof String) {
+ return Enum.valueOf(clazz, (String) o);
+ }
+
+ throw new IllegalArgumentException("Cannot convert " + o + " of class " + o.getClass() + " to type " + clazz);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ExpressionFactory#createMethodExpression(javax.el.ELContext, java.lang.String, java.lang.Class, java.lang.Class<?>[])
+ */
+ @Override
+ public MethodExpression createMethodExpression(ELContext context,
+ String expression, Class<?> expectedReturnType,
+ Class<?>[] expectedParamTypes) {
+ return factory.createMethodExpression(context, expression, expectedReturnType, expectedParamTypes);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ExpressionFactory#createValueExpression(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ public ValueExpression createValueExpression(Object instance,
+ Class<?> expectedType) {
+ return factory.createValueExpression(instance, expectedType);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ExpressionFactory#createValueExpression(javax.el.ELContext, java.lang.String, java.lang.Class)
+ */
+ @Override
+ public ValueExpression createValueExpression(ELContext context,
+ String expression, Class<?> expectedType) {
+ return factory.createValueExpression(context, expression, expectedType);
+ }
+
+}
Added: trunk/framework/test/src/main/java/org/ajax4jsf/tests/JsfMock.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/JsfMock.java (rev 0)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/JsfMock.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -0,0 +1,172 @@
+/**
+ *
+ */
+package org.ajax4jsf.tests;
+
+import javax.el.Expression;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.event.ValueChangeListener;
+import javax.faces.validator.Validator;
+
+import org.easymock.IArgumentMatcher;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @author Administrator
+ *
+ */
+@SuppressWarnings("deprecation")
+public class JsfMock {
+
+ public static <T extends Expression> T expressionStringEq(T t) {
+ EasyMock.reportMatcher(new ExpressionEq(t){});
+ return null;
+ }
+
+
+ public static ValueBinding vbEqToVe(ValueExpression expression) {
+ EasyMock.reportMatcher(new ExpressionEq(expression){});
+ return null;
+ }
+
+ public static MethodBinding mbEqToMe(MethodExpression expression) {
+ EasyMock.reportMatcher(new ExpressionEq(expression){});
+ return null;
+ }
+
+ public static MethodExpression meEqToMe(MethodExpression expression) {
+ EasyMock.reportMatcher(new ExpressionEq(expression){});
+ return null;
+ }
+
+ public static Validator meValidator(MockMethodExpression expression) {
+ EasyMock.reportMatcher(new MethodValidatorMatcher(expression));
+ return null;
+ }
+
+ public static ActionListener meActionListener(MockMethodExpression expression) {
+ EasyMock.reportMatcher(new MethodActionListenerMatcher(expression));
+ return null;
+ }
+
+ public static ValueChangeListener meValueChangeListener(MockMethodExpression expression) {
+ EasyMock.reportMatcher(new MethodValueChangeListenerMatcher(expression));
+ return null;
+ }
+
+// public static ValueExpression expressionStringEq(ValueExpression expression) {
+// EasyMock.reportMatcher(new ExpressionEq(expression) {});
+// return null;
+// }
+
+ public abstract static class ExpressionEq implements IArgumentMatcher{
+ private Expression expression;
+
+ public ExpressionEq(Expression expression) {
+ super();
+ this.expression = expression;
+ }
+
+ public void appendTo(StringBuffer buffer) {
+ buffer.append("Expression expected to have expression string ")
+ .append(expression.getExpressionString());
+ }
+ public boolean matches(Object argument) {
+ if (argument instanceof Expression) {
+ Expression e2 = (Expression) argument;
+ return e2.getExpressionString().equals(expression.getExpressionString());
+ } else if (argument instanceof ValueBinding) {
+ ValueBinding binding = (ValueBinding) argument;
+ return binding.getExpressionString().equals(expression.getExpressionString());
+ } else if (argument instanceof MethodBinding) {
+ MethodBinding binding = (MethodBinding) argument;
+ return binding.getExpressionString().equals(expression.getExpressionString());
+ }
+ return false;
+ }
+ }
+
+
+
+ public static class MethodActionListenerMatcher implements IArgumentMatcher{
+ private MockMethodExpression expression;
+
+ public MethodActionListenerMatcher(MockMethodExpression expression) {
+ super();
+ this.expression = expression;
+ }
+ public void appendTo(StringBuffer buffer) {
+ buffer
+ .append("Action Listener is supposed to evaluate method")
+ .append(expression.getExpressionString());
+ }
+ public boolean matches(Object argument) {
+ if (argument instanceof ActionListener) {
+ ActionListener listener = (ActionListener) argument;
+ ActionEvent event = new ActionEvent(new UICommand());
+ listener.processAction(event);
+ return expression.lastInvocationMatched(event);
+ }
+ return false;
+ }
+ }
+
+ public static class MethodValueChangeListenerMatcher implements IArgumentMatcher{
+ private MockMethodExpression expression;
+
+ public MethodValueChangeListenerMatcher(MockMethodExpression expression) {
+ super();
+ this.expression = expression;
+ }
+ public void appendTo(StringBuffer buffer) {
+ buffer
+ .append("ValueChangeListener Listener is supposed to evaluate method")
+ .append(expression.getExpressionString());
+ }
+ public boolean matches(Object argument) {
+ if (argument instanceof ValueChangeListener) {
+ ValueChangeListener listener = (ValueChangeListener) argument;
+ ValueChangeEvent event = new ValueChangeEvent(new UIInput(), new Object(), new Object());
+ listener.processValueChange(event);
+ return expression.lastInvocationMatched(event);
+ }
+ return false;
+ }
+ }
+
+ public static class MethodValidatorMatcher implements IArgumentMatcher{
+ private MockMethodExpression expression;
+
+ public MethodValidatorMatcher(MockMethodExpression expression) {
+ super();
+ this.expression = expression;
+ }
+ public void appendTo(StringBuffer buffer) {
+ buffer
+ .append("Validator is supposed to evaluate method")
+ .append(expression.getExpressionString());
+ }
+ public boolean matches(Object argument) {
+ if (argument instanceof Validator) {
+ Validator validator = (Validator) argument;
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIComponent component = new UIInput();
+ Object value = new Object();
+ validator.validate(context, component, value);
+ return expression.lastInvocationMatched(context, component, value);
+ }
+ return false;
+ }
+ }
+
+}
Added: trunk/framework/test/src/main/java/org/ajax4jsf/tests/LiteralValueExpression.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/LiteralValueExpression.java (rev 0)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/LiteralValueExpression.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package org.ajax4jsf.tests;
+
+/**
+ * @author Administrator
+ *
+ */
+@SuppressWarnings("serial")
+public class LiteralValueExpression extends MockValueExpression {
+
+ public LiteralValueExpression(Object o) {
+ super(o);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public boolean isLiteralText() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+}
Added: trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockApplication.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockApplication.java (rev 0)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockApplication.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -0,0 +1,28 @@
+/**
+ *
+ */
+package org.ajax4jsf.tests;
+
+import javax.el.ExpressionFactory;
+
+import org.apache.shale.test.el.MockExpressionFactory;
+import org.apache.shale.test.mock.MockApplication12;
+
+/**
+ * @author Administrator
+ *
+ */
+public class MockApplication extends MockApplication12 {
+
+ private ExpressionFactory expressionFactory;
+
+ public MockApplication() {
+ expressionFactory =
+ new EnumSupportExpressionFactoryWrapper(new MockExpressionFactory());
+ }
+
+ @Override
+ public ExpressionFactory getExpressionFactory() {
+ return expressionFactory;
+ }
+}
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockMethodExpression.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockMethodExpression.java 2008-03-14 10:00:29 UTC (rev 6800)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockMethodExpression.java 2008-03-14 11:15:48 UTC (rev 6801)
@@ -4,6 +4,7 @@
package org.ajax4jsf.tests;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import javax.el.ELContext;
@@ -102,4 +103,12 @@
public void reset() {
invocationArgs.clear();
}
+
+ public boolean lastInvocationMatched(Object ...objects) {
+ if (!invocationArgs.isEmpty()) {
+ Object[] argz = invocationArgs.get(invocationArgs.size() - 1);
+ return Arrays.equals(objects, argz);
+ }
+ return false;
+ }
}
Property changes on: trunk/samples/inplaceInput-sample
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Property changes on: trunk/samples/inplaceSelect-sample
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Property changes on: trunk/samples/richfaces-ear-demo/ejb
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Property changes on: trunk/samples/richfaces-ear-demo/richfacesEAR
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.project
Property changes on: trunk/samples/richfaces-ear-demo/webapp
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Property changes on: trunk/samples/seamEAR
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/samples/seamEAR/ear
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.project
Property changes on: trunk/samples/seamEAR/ejbs
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Property changes on: trunk/samples/seamEAR/primary-source
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Property changes on: trunk/samples/seamEAR/projects/logging
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.project
.classpath
Property changes on: trunk/samples/seamEAR/wars/seamWebapp
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/ui/combobox
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
+ target
.classpath
.project
.settings
.clover
Property changes on: trunk/ui/componentControl
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/contextMenu
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
.jsdtscope
+ target
.classpath
.project
.settings
.jsdtscope
.clover
Property changes on: trunk/ui/core
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/dataFilterSlider
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/dataTable
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
.buildpath
.externalToolBuilders
bin
+ target
.settings
.classpath
.project
.buildpath
.externalToolBuilders
bin
.clover
Property changes on: trunk/ui/datascroller
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/dropdown-menu
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/effect
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/fileUpload
___________________________________________________________________
Name: svn:ignore
- .settings
target
.project
.classpath
+ .settings
target
.project
.classpath
.clover
Property changes on: trunk/ui/gmap
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/inplaceInput
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/inplaceSelect
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/insert
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/jQuery
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/listShuttle
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/menu-components
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
target
.settings
+ .classpath
.project
target
.settings
.clover
Property changes on: trunk/ui/message
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/modal-panel
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/orderingList
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
bin
+ .classpath
.project
.settings
target
bin
.clover
Property changes on: trunk/ui/panelbar
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/panelmenu
___________________________________________________________________
Name: svn:ignore
- target
.settings
.project
.classpath
+ target
.settings
.project
.classpath
.clover
Property changes on: trunk/ui/pickList
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
+ target
.classpath
.project
.settings
.clover
Property changes on: trunk/ui/progressBAR
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
+ target
.classpath
.project
.settings
.clover
Property changes on: trunk/ui/scrollableDataTable
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
bin
+ target
.classpath
.project
.settings
bin
.clover
Property changes on: trunk/ui/simpleTogglePanel
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/suggestionbox
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/togglePanel
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/toolBar
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
.clover
Property changes on: trunk/ui/treeModel
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
.clover
Property changes on: trunk/ui/virtualEarth
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
+ target
.classpath
.project
.settings
.clover
16 years, 10 months
JBoss Rich Faces SVN: r6800 - trunk/ui/datascroller/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2008-03-14 06:00:29 -0400 (Fri, 14 Mar 2008)
New Revision: 6800
Modified:
trunk/ui/datascroller/src/main/config/component/datascroller.xml
Log:
http://jira.jboss.com/jira/browse/RF-1133
Modified: trunk/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/component/datascroller.xml 2008-03-14 01:30:03 UTC (rev 6799)
+++ trunk/ui/datascroller/src/main/config/component/datascroller.xml 2008-03-14 10:00:29 UTC (rev 6800)
@@ -249,6 +249,7 @@
<property>
<name>page</name>
<classname>int</classname>
+ <description><![CDATA[If page >= 1 then it's a number of page to show, if page <= -1 then the page to show is pageCount + page + 1, so that if page="-1" the last page is shown]]></description>
</property>
<property>
16 years, 10 months
JBoss Rich Faces SVN: r6799 - in trunk/ui/suggestionbox/src: main/java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-13 21:30:03 -0400 (Thu, 13 Mar 2008)
New Revision: 6799
Modified:
trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml
trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-1774
Modified: trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml
===================================================================
--- trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2008-03-14 01:29:52 UTC (rev 6798)
+++ trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2008-03-14 01:30:03 UTC (rev 6799)
@@ -266,10 +266,6 @@
is set as a value
</description>
</property>
- <property>
- <name>hiddenFetchValue</name>
- <classname>java.lang.Object</classname>
- </property>
<property hidden="true">
<name>value</name>
<classname>java.lang.Object</classname>
@@ -353,9 +349,6 @@
It isn't selectable and list is closed as always after click on it and nothing is put to input.
</description>
</property>
- <property>
- <name>selectedObjects</name>
- <classname>javax.el.ValueExpression</classname>
- </property>
+
</component>
</components>
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2008-03-14 01:29:52 UTC (rev 6798)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2008-03-14 01:30:03 UTC (rev 6799)
@@ -21,13 +21,12 @@
package org.richfaces.component;
-import java.util.Collection;
-import java.util.HashMap;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
@@ -53,15 +52,43 @@
implements AjaxComponent, AjaxSource {
+ private static final class SubmittedValue implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2032953038329023808L;
+
+ private Object suggestionValue;
+ private String[] requestedValues;
+
+ public SubmittedValue() {
+
+ }
+
+ public SubmittedValue(Object suggestionValue, String[] requestedValues) {
+ super();
+ this.suggestionValue = suggestionValue;
+ this.requestedValues = requestedValues;
+ }
+
+ public Object getSuggestionValue() {
+ return suggestionValue;
+ }
+
+ public String[] getRequestedValues() {
+ return requestedValues;
+ }
+ }
+
/**
* Component type.
*/
- private static final String COMPONENT_TYPE = "org.richfaces.SuggestionBox";
+ public static final String COMPONENT_TYPE = "org.richfaces.SuggestionBox";
/**
* Component family.
*/
- private static final String COMPONENT_FAMILY =
+ public static final String COMPONENT_FAMILY =
"org.richfaces.SuggestionBox";
/**
@@ -87,6 +114,10 @@
public abstract void setSubmitedValue(Object v);
+ public void setSubmitedValue(Object suggestionValue, String[] requestedValues) {
+ setSubmitedValue(new SubmittedValue(suggestionValue, requestedValues));
+ }
+
public abstract String getFor();
/**
@@ -95,25 +126,7 @@
* @param f identifier
*/
public abstract void setFor(String f);
-
- public abstract Object getHiddenFetchValue();
- public abstract void setHiddenFetchValue(Object hfv);
-
- public abstract Object getFetchValue();
-
- public abstract void setFetchValue(Object fv);
-
- public abstract void setData(Object data);
-
- public abstract Object getData();
-
- public abstract ValueExpression getSelectedObjects();
-
- public abstract void setSelectedObjects(ValueExpression so);
-
-
-
/**
* Getter for suggestionAction.
*
@@ -295,12 +308,75 @@
public abstract void setNothingLabel(String nothingLabel);
+ public abstract Object getFetchValue();
+
+ public abstract void setFetchValue(Object value);
+
/* (non-Javadoc)
* @see javax.faces.component.UIData#broadcast(javax.faces.event.FacesEvent)
*/
private int rowNumber = -1;
+ private Object getRequestedValuesData() {
+ MethodExpression suggestingAction = getSuggestionAction();
+ SubmittedValue valueHolder = (SubmittedValue) getSubmitedValue();
+ FacesContext context = getFacesContext();
+
+ if (null != suggestingAction && valueHolder != null) {
+ String[] requestedValues = valueHolder.getRequestedValues();
+ if (requestedValues != null) {
+ int first = getFirst();
+ int rows = getRows();
+ int rowIndex = getRowIndex();
+ setFirst(0);
+ setRows(0);
+
+ List results = new ArrayList();
+ for (int i = 0; i < requestedValues.length; i++) {
+ String requestedValue = requestedValues[i];
+ if (requestedValue != null) {
+ setValue(suggestingAction.invoke(
+ context.getELContext(), new Object[]{requestedValue}));
+
+ setRowIndex(-1);
+
+ int j = 0;
+ boolean stop = false;
+
+ while (!stop) {
+ setRowIndex(j++);
+ if (isRowAvailable()) {
+ Object fetchValue = getFetchValue();
+ if (fetchValue != null) {
+ if (requestedValue.equalsIgnoreCase(fetchValue.toString())) {
+ results.add(getRowData());
+ stop = true;
+ }
+ }
+ } else {
+ results.add(null);
+ stop = true;
+ }
+ }
+ } else {
+ results.add(null);
+ }
+ }
+
+ setData(results);
+
+ setFirst(first);
+ setRows(rows);
+ setRowIndex(rowIndex);
+
+ return results;
+ }
+ }
+
+ return null;
+ }
+
public int getRowNumber() {
return rowNumber;
}
@@ -312,29 +388,23 @@
public final void broadcast(final FacesEvent event)
throws AbortProcessingException {
super.broadcast(event);
- FacesContext context = getFacesContext();
- if (event instanceof AjaxEvent) {
+ if (event instanceof AjaxEvent) {
+ FacesContext context = getFacesContext();
+ Object data = getRequestedValuesData();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (null != data) {
+ ajaxContext.setResponseData(data);
+ }
AjaxRendererUtils.addRegionsFromComponent(this, context);
AjaxRendererUtils.addRegionByName(context, this, this.getId());
setSubmitted(true);
if (isSelfRendered()) {
- AjaxContext.getCurrentInstance(context)
- .renderSubmittedAjaxRegion(context, true);
+ ajaxContext.renderSubmittedAjaxRegion(context, true);
}
} else if (event instanceof SelectSuggestionEvent) {
- setValue(null);
+ setValue(null);
}
-
}
- private Object getElementFromMap(Object selection){
- //TODO Add more than one Object support.
- HashMap<Object, Object> data = (HashMap<Object, Object>) getData();
- if(data!=null){
- return data.get(selection);
- }else{
- return null;
- }
- }
public void queueEvent(FacesEvent event) {
if (event instanceof SelectSuggestionEvent) {
@@ -361,29 +431,20 @@
setRowNumber(Integer.parseInt(rowValue)+getFirst());
setupValue(context);
queueEvent(new SelectSuggestionEvent(this));
-
} else {
setRowNumber(-1);
}
-
- Object selectedObject = context.getExternalContext().getRequestParameterMap().get(getClientId(context)+"_hiddenFetchValue");
- /*TODO set selected from Map to bean property or put it ot Listener.
- ValueExpression ve = getSelectedObjects();
- if(ve!=null){
- ve.setValue(context.getELContext(), getElementFromMap(selectedObject));
- setSelectedObjects(ve);
- }
- */
- super.processDecodes(context);
+ super.processDecodes(context);
}
public void setupValue(FacesContext context) {
- Object value = getSubmitedValue();
+ SubmittedValue valueHolder = (SubmittedValue) getSubmitedValue();
+ Object submittedValue = valueHolder != null ? valueHolder.getSuggestionValue() : null;
+
MethodExpression suggestingAction = getSuggestionAction();
if (null != suggestingAction) {
setValue(suggestingAction.invoke(
- context.getELContext(), new Object[]{value}));
-
+ context.getELContext(), new Object[]{submittedValue}));
}
}
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-03-14 01:29:52 UTC (rev 6798)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-03-14 01:30:03 UTC (rev 6799)
@@ -23,14 +23,11 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIColumn;
@@ -38,7 +35,6 @@
import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServlet;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
@@ -62,817 +58,778 @@
* Renderer for SuggestionBox component.
*/
public class SuggestionBoxRenderer extends AjaxComponentRendererBase {
- /**
- * Component options.
- */
- private static final String[] OPTIONS = { "popupClass", "popupStyle",
- "width", "height", "entryClass", "selectedClass", "param",
- "frequency", "minChars", "tokens", "rows", "selectValueClass" };
+ /**
+ * Component options.
+ */
+ private static final String[] OPTIONS = {"popupClass", "popupStyle",
+ "width", "height", "entryClass", "selectedClass", "param",
+ "frequency", "minChars", "tokens", "rows", "selectValueClass" };
- /**
- * Shadow depth.
- */
- public static final int SHADOW_DEPTH = 4;
+ /**
+ * Shadow depth.
+ */
+ public static final int SHADOW_DEPTH = 4;
- /**
- * Styles.
- */
- private InternetResource[] styles = { new TemplateCSSResource(
- "org/richfaces/renderkit/html/css/suggestionbox.xcss") };
+ /**
+ * Styles.
+ */
+ private InternetResource[] styles = {new TemplateCSSResource(
+ "org/richfaces/renderkit/html/css/suggestionbox.xcss")};
- /**
- * Additional scripts.
- */
- private final InternetResource[] additionalScripts = {
- new org.ajax4jsf.javascript.PrototypeScript(),
- new org.ajax4jsf.javascript.SmartPositionScript(),
- getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
- getResource("scripts/scriptaculo.js"),
- getResource("scripts/suggestionbox.js") };
+ /**
+ * Additional scripts.
+ */
+ private final InternetResource[] additionalScripts = {
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.SmartPositionScript(),
+ getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
+ getResource("scripts/scriptaculo.js"),
+ getResource("scripts/suggestionbox.js")};
- /**
- * Template for table.
- */
- private PreparedTemplate body = HtmlCompiler
- .compileResource("org/richfaces/renderkit/html/templates/table.jspx");
+ /**
+ * Template for table.
+ */
+ private PreparedTemplate body = HtmlCompiler
+ .compileResource("org/richfaces/renderkit/html/templates/table.jspx");
- /**
- * Template for popup.
- */
- private PreparedTemplate popup = HtmlCompiler
- .compileResource("org/richfaces/renderkit/html/templates/popup.jspx");
+ /**
+ * Template for popup.
+ */
+ private PreparedTemplate popup = HtmlCompiler
+ .compileResource("org/richfaces/renderkit/html/templates/popup.jspx");
- /**
- * Gets component class.
- *
- * @return component class
- */
- protected final Class getComponentClass() {
- return UISuggestionBox.class;
- }
+ /**
+ * Gets component class.
+ *
+ * @return component class
+ */
+ protected final Class getComponentClass() {
+ return UISuggestionBox.class;
+ }
- /**
- * Is render children.
- *
- * @return boolean
- */
- public final boolean getRendersChildren() {
- return true;
- }
+ /**
+ * Is render children.
+ *
+ * @return boolean
+ */
+ public final boolean getRendersChildren() {
+ return true;
+ }
- /**
- * Decode.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- *
- * @see org.ajax4jsf.framework.renderer.RendererBase#doDecode(
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected final void doDecode(final FacesContext context,
- final UIComponent component) {
- String clientId = component.getClientId(context);
- Map requestParameterMap = context.getExternalContext()
- .getRequestParameterMap();
- String reqValue = (String) requestParameterMap.get(clientId);
- if (reqValue != null && reqValue.equals(clientId)) {
- String paramName = (String) component.getAttributes().get("param");
- if (null == paramName) {
- paramName = "inputvalue";
- }
- Object elementValue = requestParameterMap.get(paramName);
- ((UISuggestionBox) component).setSubmitedValue(elementValue);
- component.queueEvent(new AjaxSuggestionEvent(component,
- elementValue));
- }
-
- }
+ private Pattern getTokensPattern(UIComponent component) {
+ //TODO nick - cache ?
+ String tokens = (String) component.getAttributes().get("tokens");
+ if (tokens != null && tokens.length() != 0) {
+ StringBuilder patternSource = new StringBuilder();
+ char[] array = tokens.toCharArray();
+ int l = array.length;
+ for (int i = 0; i < l; i++) {
+ if (i != 0) {
+ patternSource.append('|');
+ }
+ patternSource.append(Pattern.quote(String.valueOf(array[i])));
+ }
+
+ return Pattern.compile(patternSource.toString());
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Decode.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#doDecode(
+ * javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected final void doDecode(final FacesContext context,
+ final UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext()
+ .getRequestParameterMap();
+ String reqValue = (String) requestParameterMap.get(clientId);
+ if (reqValue != null && reqValue.equals(clientId)) {
+ String paramName = (String) component.getAttributes().get("param");
+ if (null == paramName) {
+ paramName = "inputvalue";
+ }
+ Object elementValue = requestParameterMap.get(paramName);
+ component.queueEvent(
+ new AjaxSuggestionEvent(component, elementValue));
- /**
- * Encode begin.
- *
- * @param writer
- * {@link javax.faces.context.ResponseWriter}
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @throws IOException
- *
- * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin}
- */
- protected final void doEncodeBegin(final ResponseWriter writer,
- final FacesContext context, final UIComponent component)
- throws IOException {
- super.doEncodeBegin(writer, context, component);
- org.richfaces.component.util.FormUtil.throwEnclFormReqExceptionIfNeed(
- context, component);
- }
+
+ String requestedParamName = paramName + "request";
+ String[] requestedValues = null;
+ Object requestedValuesParam = requestParameterMap.get(requestedParamName);
+
+ if (requestedValuesParam != null) {
+ String requestedString = requestedValuesParam.toString();
+ Pattern pattern = getTokensPattern(component);
+
+ if (pattern != null) {
+ requestedValues = pattern.split(requestedString);
+ } else {
+ requestedValues = new String[] {requestedString};
+ }
+ } else {
+ //TODO nick - review together with pasha
+ }
+ ((UISuggestionBox) component).setSubmitedValue(elementValue,
+ requestedValues);
+
+ }
+ }
- /**
- * Encode end.
- *
- * @param writer
- * {@link javax.faces.context.ResponseWriter}
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @throws IOException
- *
- * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
- */
- protected void doEncodeEnd(final ResponseWriter writer,
- final FacesContext context, final UIComponent component)
- throws IOException {
- UISuggestionBox suggestionBox = (UISuggestionBox) component;
+ /**
+ * Encode begin.
+ *
+ * @param writer {@link javax.faces.context.ResponseWriter}
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @throws IOException
+ *
+ * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin}
+ */
+ protected final void doEncodeBegin(final ResponseWriter writer,
+ final FacesContext context,
+ final UIComponent component)
+ throws IOException {
+ super.doEncodeBegin(writer, context, component);
+ org.richfaces.component.util.FormUtil.throwEnclFormReqExceptionIfNeed(
+ context, component);
+ }
- if (!suggestionBox.isSubmitted()) {
- suggestionBox.setRowIndex(-1);
+ /**
+ * Encode end.
+ *
+ * @param writer {@link javax.faces.context.ResponseWriter}
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @throws IOException
+ *
+ * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
+ */
+ protected void doEncodeEnd(final ResponseWriter writer,
+ final FacesContext context,
+ final UIComponent component) throws IOException {
+ UISuggestionBox suggestionBox = (UISuggestionBox) component;
+ if (!suggestionBox.isSubmitted()) {
+ suggestionBox.setRowIndex(-1);
+ writer.startElement(HTML.DIV_ELEM, component);
+ getUtils().encodeId(context, component);
- writer.startElement(HTML.DIV_ELEM, component);
- getUtils().encodeId(context, component);
+ StringBuffer clazz = new StringBuffer(
+ "dr-sb-common-container rich-sb-common-container ");
+ clazz.append(suggestionBox.getPopupClass() + " ").
+ append(suggestionBox.getStyleClass());
+ writer.writeAttribute("class", clazz, "popupClass");
- StringBuffer clazz = new StringBuffer(
- "dr-sb-common-container rich-sb-common-container ");
- clazz.append(suggestionBox.getPopupClass() + " ").append(
- suggestionBox.getStyleClass());
- writer.writeAttribute("class", clazz, "popupClass");
+ int zIndex = suggestionBox.getZindex();
- int zIndex = suggestionBox.getZindex();
+ StringBuffer style = new StringBuffer("display:none; z-index: " + (zIndex + 1) + ";");
- StringBuffer style = new StringBuffer("display:none; z-index: "
- + (zIndex + 1) + ";");
+ style.append(getSizeForStyle(component, "width", null, false));
+ style.append(getSizeForStyle(component, "height", null, false));
- style.append(getSizeForStyle(component, "width", null, false));
- style.append(getSizeForStyle(component, "height", null, false));
+ style.append(suggestionBox.getPopupStyle() + ";").
+ append(suggestionBox.getStyle() + ";");
+ writer.writeAttribute("style", style, "popupStyle");
- style.append(suggestionBox.getPopupStyle() + ";").append(
- suggestionBox.getStyle() + ";");
- writer.writeAttribute("style", style, "popupStyle");
+ UIComponent popupFacet = component.getFacet("popup");
+ if (null == popupFacet) {
+ popup.encode(this, context, component);
+ } else {
+ // Use facet as content of popup window
+ // suggestionBox.setPopup(popupFacet.getClientId(context));
+ renderChild(context, popupFacet);
+ }
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeText(getScript(context, component), "script");
+ writer.endElement(HTML.SCRIPT_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+ writer.startElement("iframe", component);
+ writer.writeAttribute("src",
+ getResource("/org/richfaces/renderkit/html/images/spacer.gif")
+ .getUri(context, null), null);
+ writer.writeAttribute("id", component.getClientId(context)
+ + "_iframe", null);
+ writer.writeAttribute(
+ "style", "position:absolute;display:none;z-index:" + zIndex + ";", null);
+ writer.endElement("iframe");
- UIComponent popupFacet = component.getFacet("popup");
- if (null == popupFacet) {
- popup.encode(this, context, component);
- } else {
- // Use facet as content of popup window
- // suggestionBox.setPopup(popupFacet.getClientId(context));
- renderChild(context, popupFacet);
- }
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeText(getScript(context, component), "script");
- writer.endElement(HTML.SCRIPT_ELEM);
- writer.endElement(HTML.DIV_ELEM);
- writer.startElement("iframe", component);
- writer.writeAttribute("src", getResource(
- "/org/richfaces/renderkit/html/images/spacer.gif").getUri(
- context, null), null);
- writer.writeAttribute("id", component.getClientId(context)
- + "_iframe", null);
- writer.writeAttribute("style",
- "position:absolute;display:none;z-index:" + zIndex + ";",
- null);
- writer.endElement("iframe");
+ writer.startElement("input", component);
+ writer.writeAttribute("type", "hidden", null);
+ writer.writeAttribute("id", component.getClientId(context)
+ + "_selection", null);
+ writer.writeAttribute("name", component.getClientId(context)
+ + "_selection", null);
+ writer.endElement("input");
+
+ } else {
+ suggestionBox.setSubmitted(false);
+ }
- writer.startElement("input", component);
- writer.writeAttribute("type", "hidden", null);
- writer.writeAttribute("id", component.getClientId(context)
- + "_hiddenFetchValue", null);
- writer.writeAttribute("name", component.getClientId(context)
- + "_hiddenFetchValue", null);
- writer.endElement("input");
+ // Fix for bug CH-1323.
+ ((UISuggestionBox) component).setValue(null);
+ }
- writer.startElement("input", component);
- writer.writeAttribute("type", "hidden", null);
- writer.writeAttribute("id", component.getClientId(context)
- + "_selection", null);
- writer.writeAttribute("name", component.getClientId(context)
- + "_selection", null);
- writer.endElement("input");
+ /**
+ * Encode children.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @throws IOException
+ *
+ * @see javax.faces.render.Renderer#encodeChildren
+ */
+ public void encodeChildren(final FacesContext context,
+ final UIComponent component)
+ throws IOException {
+ UISuggestionBox suggestionBox = (UISuggestionBox) component;
+ if (suggestionBox.isSubmitted()) {
+ suggestionBox.setupValue(context);
+ body.encode(getTemplateContext(context, suggestionBox));
+ // Replace rendered area ID from component to suggestion table
+ suggestionBox.setRowIndex(-1);
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.removeRenderedArea(component.getClientId(context));
+ ajaxContext.addRenderedArea(getContentId(context, component));
+ }
+ }
- } else {
- suggestionBox.setSubmitted(false);
- }
+ /**
+ * Gets component.
+ *
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return component
+ */
+ private UIComponent getTarget(final UIComponent component) {
+ String target = ((UISuggestionBox) component).getFor();
+ if (null != target) {
+ target = RendererUtils.getInstance().correctForIdReference(target,component);
+ // Use parent since UIData - naming container
+ UIComponent targetComponent = RendererUtils.getInstance().
+ findComponentFor(component, target);
+ if (null != targetComponent) {
+ return targetComponent;
+ } else {
+ throw new FacesException("Component for target " + target
+ + " not found in SuggestionBox " + component.getId());
+ }
+ } else {
+ throw new FacesException("Component SuggestionBox "
+ + component.getId() + " don't have property 'for' ");
+ }
+ }
- // Fix for bug CH-1323.
- ((UISuggestionBox) component).setValue(null);
- }
+ /**
+ * Gets script.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return script
+ */
+ private String getScript(final FacesContext context,
+ final UIComponent component) {
+ Map attributes = component.getAttributes();
+ StringBuffer script = new StringBuffer(" new ");
+ // Build ajax function call
+ JSFunction submitSuggest = AjaxRendererUtils.buildAjaxFunction(
+ component, context, "RichFaces.Suggestion");
+ UIComponent targetComponent = getTarget(component);
+ submitSuggest.addParameter(targetComponent.getClientId(context));
+ submitSuggest.addParameter(component.getClientId(context));
+ submitSuggest.addParameter(component.getAttributes().get("onsubmit"));
+ Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ options.put("popup", component.getClientId(context));
+ for (int i = 0; i < OPTIONS.length; i++) {
+ String option = OPTIONS[i];
+ Object value = attributes.get(option);
+ if (null != value) {
+ options.put(option, value);
+ }
+ }
+ // If ajax queue name not set, put clientId
+ String eventsQueue = (String) options.get("eventsQueue");
+ if (null == eventsQueue) {
+ options.put("eventsQueue", component.getClientId(context));
+ }
+ String onselect = (String) attributes.get("onselect");
+ if (null != onselect) {
+ JSFunctionDefinition function = new JSFunctionDefinition(
+ "suggestion");
+ function.addParameter("event");
+ function.addToBody(onselect);
- /**
- * Encode children.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @throws IOException
- *
- * @see javax.faces.render.Renderer#encodeChildren
- */
- public void encodeChildren(final FacesContext context,
- final UIComponent component) throws IOException {
- UISuggestionBox suggestionBox = (UISuggestionBox) component;
- if (suggestionBox.isSubmitted()) {
- suggestionBox.setupValue(context);
- body.encode(getTemplateContext(context, suggestionBox));
+ options.put("onselect", function);
- Object[] values = ((Collection) suggestionBox.getValue()).toArray();
- Collection data = new ArrayList();
- HashMap<Object,Object> dataToStore = new HashMap<Object,Object>();
- for (int i = 0; i < values.length; i++) {
+ }
+ if (component.getValueBinding("fetchValue") != null
+ || attributes.get("fetchValue") != null) {
+ options.put("select", attributes.get("selectValueClass"));
+ }
- String var = (String) suggestionBox.getAttributes().get("var");
- context.getExternalContext().getRequestMap()
- .put(var, values[i]);
- if (suggestionBox.getHiddenFetchValue() != null) {
- data.add(suggestionBox.getHiddenFetchValue());
- dataToStore.put(suggestionBox.getHiddenFetchValue(), values[i]);
- } else {
- data.add(suggestionBox.getFetchValue());
- dataToStore.put(suggestionBox.getFetchValue(), values[i]);
- }
-
+ submitSuggest.addParameter(options);
+ script.append(submitSuggest.toScript()).append(";\n");
+ return script.toString();
+ }
- }
- suggestionBox.setData(dataToStore);
- // Replace rendered area ID from component to suggestion table
- suggestionBox.setRowIndex(-1);
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ajaxContext.removeRenderedArea(component.getClientId(context));
- ajaxContext.addRenderedArea(getContentId(context, component));
- ajaxContext.getResponseDataMap().put("_ajax:data",data);
-
- }
- }
+ /**
+ * Gets template.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param data
+ * @return {@link org.ajax4jsf.framework.renderer.compiler.TemplateContext}
+ */
+ private TemplateContext getTemplateContext(final FacesContext context,
+ final UIData data) {
+ data.setRowIndex(-1);
+ return new DataTemplateContext(this, context, data);
+ }
- /**
- * Gets component.
- *
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return component
- */
- private UIComponent getTarget(final UIComponent component) {
- String target = ((UISuggestionBox) component).getFor();
- if (null != target) {
- target = RendererUtils.getInstance().correctForIdReference(target,
- component);
- // Use parent since UIData - naming container
- UIComponent targetComponent = RendererUtils.getInstance()
- .findComponentFor(component, target);
- if (null != targetComponent) {
- return targetComponent;
- } else {
- throw new FacesException("Component for target " + target
- + " not found in SuggestionBox " + component.getId());
- }
- } else {
- return component;
- }
- }
+ /**
+ * Special html templates context class with pre-defined properties for
+ * iterations over rows and columns.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.20 $ $Date: 2007/03/01 22:37:49 $
+ */
+ private static class DataTemplateContext extends TemplateContext {
- /**
- * Gets script.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return script
- */
- private String getScript(final FacesContext context,
- final UIComponent component) {
- Map attributes = component.getAttributes();
- StringBuffer script = new StringBuffer(" new ");
- // Build ajax function call
- JSFunction submitSuggest = AjaxRendererUtils.buildAjaxFunction(
- component, context, "RichFaces.Suggestion");
- UIComponent targetComponent = getTarget(component);
- if (targetComponent.equals(component)) {
- submitSuggest.addParameter(targetComponent.getClientId(context)
- + "_input");
- } else {
- submitSuggest.addParameter(targetComponent.getClientId(context));
- }
- submitSuggest.addParameter(component.getClientId(context));
- submitSuggest.addParameter(component.getAttributes().get("onsubmit"));
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
- options.put("popup", component.getClientId(context));
- for (int i = 0; i < OPTIONS.length; i++) {
- String option = OPTIONS[i];
- Object value = attributes.get(option);
- if (null != value) {
- options.put(option, value);
- }
- }
- // If ajax queue name not set, put clientId
- String eventsQueue = (String) options.get("eventsQueue");
- if (null == eventsQueue) {
- options.put("eventsQueue", component.getClientId(context));
- }
- String onselect = (String) attributes.get("onselect");
- if (null != onselect) {
- JSFunctionDefinition function = new JSFunctionDefinition(
- "suggestion");
- function.addParameter("event");
- function.addToBody(onselect);
+ private List columns;
- options.put("onselect", function);
+ private int first;
- }
- if (component.getValueBinding("fetchValue") != null
- || attributes.get("fetchValue") != null) {
- options.put("select", attributes.get("selectValueClass"));
- }
+ private int last;
- submitSuggest.addParameter(options);
- script.append(submitSuggest.toScript()).append(";\n");
- return script.toString();
- }
+ private int rows;
- /**
- * Gets template.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param data
- * @return {@link org.ajax4jsf.framework.renderer.compiler.TemplateContext}
- */
- private TemplateContext getTemplateContext(final FacesContext context,
- final UIData data) {
- data.setRowIndex(-1);
- return new DataTemplateContext(this, context, data);
- }
+ private int rowCount;
- /**
- * Special html templates context class with pre-defined properties for
- * iterations over rows and columns.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.20 $ $Date: 2007/03/01 22:37:49 $
- */
- private static class DataTemplateContext extends TemplateContext {
+ private int current;
- private List columns;
+ private String[] rowClasses = new String[0];
- private int first;
+ private String entryClass;
- private int last;
+ /**
+ * Constructor.
+ *
+ * @param renderer {@link org.ajax4jsf.framework.renderer.RendererBase}
+ * @param facesContext {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ */
+ public DataTemplateContext(final RendererBase renderer,
+ final FacesContext facesContext,
+ final UIComponent component) {
+ super(renderer, facesContext, component);
+ if (component.getFacet("head") != null) {
+ this.putParameter("hasHead", Boolean.TRUE);
+ }
+ if (component.getFacet("head") != null) {
+ this.putParameter("hasHead", Boolean.TRUE);
+ }
+ // Fill child columns components
+ columns = new ArrayList(component.getChildCount());
+ for (Iterator iter = component.getChildren().iterator(); iter
+ .hasNext();) {
+ UIComponent column = (UIComponent) iter.next();
+ if (column instanceof UIColumn) {
+ columns.add(column);
+ if (column.getFacet("head") != null) {
+ this.putParameter("hasHead", Boolean.TRUE);
+ this.putParameter("hasColumnHead", Boolean.TRUE);
+ }
+ if (column.getFacet("footer") != null) {
+ this.putParameter("hasFooter", Boolean.TRUE);
+ this.putParameter("hasColumnFooter", Boolean.TRUE);
+ }
+ }
+ }
+ // fill rows counters
+ UISuggestionBox box = (UISuggestionBox) component;
+ this.first = box.getFirst();
+ this.rows = box.getRows();
+ this.rowCount = box.getRowCount();
+ // return all records; CH-1330
+ if (rows <= 0 || true) {
+ rows = rowCount - first;
+ }
+ last = first + rows;
+ if (last > rowCount) {
+ last = rowCount;
+ }
+ current = first;
+ // rows classes
+ entryClass = box.getEntryClass();
+ String rowClasses = box.getRowClasses();
+ if (null != rowClasses && rowClasses.length() > 0) {
+ this.rowClasses = rowClasses.split("\\s+");
+ }
- private int rows;
+ }
- private int rowCount;
+ /**
+ * Gets parameter.
+ *
+ * @param key parameter key
+ * @return parameter
+ */
+ public Object getParameter(Object key) {
+ if ("rows".equals(key)) {
+ // Iterate over rows in datatable
+ return new Iterator() {
- private int current;
+ public boolean hasNext() {
+ if (current >= last) {
+ return false;
+ }
+ UIData data = ((UIData) getComponent());
+ data.setRowIndex(current);
+ return data.isRowAvailable();
+ }
- private String[] rowClasses = new String[0];
+ public Object next() {
+ // TODO reset rows and columns classes counters
+ current++;
+ return getComponent();
+ }
- private String entryClass;
+ public void remove() {
+ throw new UnsupportedOperationException(
+ "remove row from UIData not supported");
+ }
- /**
- * Constructor.
- *
- * @param renderer
- * {@link org.ajax4jsf.framework.renderer.RendererBase}
- * @param facesContext
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- */
- public DataTemplateContext(final RendererBase renderer,
- final FacesContext facesContext, final UIComponent component) {
- super(renderer, facesContext, component);
- if (component.getFacet("head") != null) {
- this.putParameter("hasHead", Boolean.TRUE);
- }
- if (component.getFacet("head") != null) {
- this.putParameter("hasHead", Boolean.TRUE);
- }
- // Fill child columns components
- columns = new ArrayList(component.getChildCount());
- for (Iterator iter = component.getChildren().iterator(); iter
- .hasNext();) {
- UIComponent column = (UIComponent) iter.next();
- if (column instanceof UIColumn) {
- columns.add(column);
- if (column.getFacet("head") != null) {
- this.putParameter("hasHead", Boolean.TRUE);
- this.putParameter("hasColumnHead", Boolean.TRUE);
- }
- if (column.getFacet("footer") != null) {
- this.putParameter("hasFooter", Boolean.TRUE);
- this.putParameter("hasColumnFooter", Boolean.TRUE);
- }
- }
- }
- // fill rows counters
- UISuggestionBox box = (UISuggestionBox) component;
- this.first = box.getFirst();
- this.rows = box.getRows();
- this.rowCount = box.getRowCount();
- // return all records; CH-1330
- if (rows <= 0 || true) {
- rows = rowCount - first;
- }
- last = first + rows;
- if (last > rowCount) {
- last = rowCount;
- }
- current = first;
- // rows classes
- entryClass = box.getEntryClass();
- String rowClasses = box.getRowClasses();
- if (null != rowClasses && rowClasses.length() > 0) {
- this.rowClasses = rowClasses.split("\\s+");
- }
+ };
+ } else if ("rowClass".equals(key)) {
+ // Build row class string from entryClass and row classes
+ StringBuffer rowClass = new StringBuffer();
+ if (null != entryClass) {
+ rowClass.append(entryClass);
+ if (rowClasses.length > 0) {
+ rowClass.append(" ");
+ }
+ }
+ if (rowClasses.length > 0) {
+ int currentClass = (current - first - 1)
+ % rowClasses.length;
+ if (currentClass < 0) {
+ currentClass = 0;
+ }
+ rowClass.append(rowClasses[currentClass]);
+ }
+ // for iterate over columns
+ return rowClass.toString();
+ } else if ("columns".equals(key)) {
+ // for iterate over columns
+ return columns;
+ } else if ("columnsCount".equals(key)) {
+ return new Integer(columns.size());
+ } else {
+ return super.getParameter(key);
+ }
+ }
+ }
- }
+ /**
+ * Gets opacity style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return style
+ */
+ public final String opacityStyle(final FacesContext context,
+ final UIComponent component) {
+ String opacity = (String) component.getAttributes().get("shadowOpacity");
+ String filterOpacity;
- /**
- * Gets parameter.
- *
- * @param key
- * parameter key
- * @return parameter
- */
- public Object getParameter(Object key) {
- if ("rows".equals(key)) {
- // Iterate over rows in datatable
- return new Iterator() {
+ if (null == opacity) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ opacity = (String) skin.getParameter(context, "shadowOpacity");
+ }
+ try {
+ Double op = Double.valueOf(opacity);
+ filterOpacity = Integer.toString(op.intValue() * 10);
+ opacity = Double.toString(op.doubleValue() / 10);
+ } catch (Exception e) {
+ // illegal opacity
+ return ";";
+ }
+ return "opacity:" + opacity
+ + "; filter:alpha(opacity=" + filterOpacity + ");";
+ }
- public boolean hasNext() {
- if (current >= last) {
- return false;
- }
- UIData data = ((UIData) getComponent());
- data.setRowIndex(current);
- return data.isRowAvailable();
- }
+ /**
+ * Gets border style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return style
+ */
+ public final String border(final FacesContext context,
+ final UIComponent component) {
- public Object next() {
- // TODO reset rows and columns classes counters
- current++;
- return getComponent();
- }
+ String border = (String) component.getAttributes().get("border");
- public void remove() {
- throw new UnsupportedOperationException(
- "remove row from UIData not supported");
- }
+ String frame = (String) component.getAttributes().get("frame");
+ if (null == frame) {
+ frame = "box";
+ }
+ StringBuffer stringBuffer = new StringBuffer();
- };
- } else if ("rowClass".equals(key)) {
- // Build row class string from entryClass and row classes
- StringBuffer rowClass = new StringBuffer();
- if (null != entryClass) {
- rowClass.append(entryClass);
- if (rowClasses.length > 0) {
- rowClass.append(" ");
- }
- }
- if (rowClasses.length > 0) {
- int currentClass = (current - first - 1)
- % rowClasses.length;
- if (currentClass < 0) {
- currentClass = 0;
- }
- rowClass.append(rowClasses[currentClass]);
- }
- // for iterate over columns
- return rowClass.toString();
- } else if ("columns".equals(key)) {
- // for iterate over columns
- return columns;
- } else if ("columnsCount".equals(key)) {
- return new Integer(columns.size());
- } else {
- return super.getParameter(key);
- }
- }
- }
+ if (null != border && Pattern.matches("\\d*", border)) {
+ border += "px";
+ }
- /**
- * Gets opacity style.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return style
- */
- public final String opacityStyle(final FacesContext context,
- final UIComponent component) {
- String opacity = (String) component.getAttributes()
- .get("shadowOpacity");
- String filterOpacity;
+ boolean top = false, right = false, bottom = false, left = false;
+ if (frame.equalsIgnoreCase("above")) {
+ top = true;
+ // else if (frame.equalsIgnoreCase("border") |
+ // frame.equalsIgnoreCase("box")) top=right=bottom=left=true;
+ } else if (frame.equalsIgnoreCase("below")) {
+ bottom = true;
+ } else if (frame.equalsIgnoreCase("hsides")) {
+ top = true;
+ bottom = true;
+ } else if (frame.equalsIgnoreCase("lhs")) {
+ left = true;
+ } else if (frame.equalsIgnoreCase("rhs")) {
+ right = true;
+ } else if (frame.equalsIgnoreCase("vsides")) {
+ right = true;
+ left = true;
+ } else {
+ top = true;
+ right = true;
+ bottom = true;
+ left = true;
+ }
+ stringBuffer.append("; border-width:");
+ if (top) {
+ stringBuffer.append(" ").append(border).append(" ");
+ } else {
+ stringBuffer.append(" 0px ");
+ }
+ if (right) {
+ stringBuffer.append(" ").append(border).append(" ");
+ } else {
+ stringBuffer.append(" 0px ");
+ }
+ if (bottom) {
+ stringBuffer.append(" ").append(border).append(" ");
+ } else {
+ stringBuffer.append(" 0px ");
+ }
+ if (left) {
+ stringBuffer.append(" ").append(border).append(" ");
+ } else {
+ stringBuffer.append(" 0px ");
+ }
+ stringBuffer.append(";");
+ return stringBuffer.toString();
+ }
- if (null == opacity) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
- opacity = (String) skin.getParameter(context, "shadowOpacity");
- }
- try {
- Double op = Double.valueOf(opacity);
- filterOpacity = Integer.toString(op.intValue() * 10);
- opacity = Double.toString(op.doubleValue() / 10);
- } catch (Exception e) {
- // illegal opacity
- return ";";
- }
- return "opacity:" + opacity + "; filter:alpha(opacity=" + filterOpacity
- + ");";
- }
+ /**
+ * Gets background-color style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return background-color style
+ */
+ public final String bgcolor(final FacesContext context,
+ final UIComponent component) {
+ String bgcolor = (String) component.getAttributes().get("bgcolor");
+ if (bgcolor != null) {
+ return "background-color: " + bgcolor + ";";
+ }
+ return ";";
+ }
- /**
- * Gets border style.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return style
- */
- public final String border(final FacesContext context,
- final UIComponent component) {
+ /**
+ * Gets cellpadding style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return cellpadding style
+ */
+ public final String cellPadding(final FacesContext context,
+ final UIComponent component) {
+ UISuggestionBox box = (UISuggestionBox) component;
+ String cp = box.getCellpadding();
+ if (cp != null) {
+ return "padding: " + getUtils().encodePctOrPx(cp) + ";";
+ }
+ return ";";
+ }
- String border = (String) component.getAttributes().get("border");
+ /**
+ * Gets border size
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return border size if set, 0 if none
+ */
+ public final String getBorder(final FacesContext context,
+ final UIComponent component) {
- String frame = (String) component.getAttributes().get("frame");
- if (null == frame) {
- frame = "box";
- }
- StringBuffer stringBuffer = new StringBuffer();
+ String border = (String) component.getAttributes().get("border");
+ if (border == null || border.length() == 0) {
+ return "0";
+ }
+
+ return border;
+ }
- if (null != border && Pattern.matches("\\d*", border)) {
- border += "px";
- }
+
+ /**
+ * Gets context identifier.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return context identifier
+ */
+ public final String getContentId(final FacesContext context,
+ final UIComponent component) {
+ return component.getClientId(context)
+ + NamingContainer.SEPARATOR_CHAR + "suggest";
+ }
- boolean top = false, right = false, bottom = false, left = false;
- if (frame.equalsIgnoreCase("above")) {
- top = true;
- // else if (frame.equalsIgnoreCase("border") |
- // frame.equalsIgnoreCase("box")) top=right=bottom=left=true;
- } else if (frame.equalsIgnoreCase("below")) {
- bottom = true;
- } else if (frame.equalsIgnoreCase("hsides")) {
- top = true;
- bottom = true;
- } else if (frame.equalsIgnoreCase("lhs")) {
- left = true;
- } else if (frame.equalsIgnoreCase("rhs")) {
- right = true;
- } else if (frame.equalsIgnoreCase("vsides")) {
- right = true;
- left = true;
- } else {
- top = true;
- right = true;
- bottom = true;
- left = true;
- }
- stringBuffer.append("; border-width:");
- if (top) {
- stringBuffer.append(" ").append(border).append(" ");
- } else {
- stringBuffer.append(" 0px ");
- }
- if (right) {
- stringBuffer.append(" ").append(border).append(" ");
- } else {
- stringBuffer.append(" 0px ");
- }
- if (bottom) {
- stringBuffer.append(" ").append(border).append(" ");
- } else {
- stringBuffer.append(" 0px ");
- }
- if (left) {
- stringBuffer.append(" ").append(border).append(" ");
- } else {
- stringBuffer.append(" 0px ");
- }
- stringBuffer.append(";");
- return stringBuffer.toString();
- }
+ /**
+ * Gets overflow sizes.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return overflow style
+ */
+ public final String overflowSize(final FacesContext context,
+ final UIComponent component) {
+ StringBuffer style = new StringBuffer();
- /**
- * Gets background-color style.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return background-color style
- */
- public final String bgcolor(final FacesContext context,
- final UIComponent component) {
- String bgcolor = (String) component.getAttributes().get("bgcolor");
- if (bgcolor != null) {
- return "background-color: " + bgcolor + ";";
- }
- return ";";
- }
+ style.append(getSizeForStyle(component, "width", null, true));
+ style.append(getSizeForStyle(component, "height", null, true));
- /**
- * Gets cellpadding style.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return cellpadding style
- */
- public final String cellPadding(final FacesContext context,
- final UIComponent component) {
- UISuggestionBox box = (UISuggestionBox) component;
- String cp = box.getCellpadding();
- if (cp != null) {
- return "padding: " + getUtils().encodePctOrPx(cp) + ";";
- }
- return ";";
- }
+ return style.toString();
+ }
- /**
- * Gets border size
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return border size if set, 0 if none
- */
- public final String getBorder(final FacesContext context,
- final UIComponent component) {
+ /**
+ * Gets shadow style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return shadow style
+ */
+ public final String shadowDepth(final FacesContext context,
+ final UIComponent component) {
+ String shadow = (String) component.getAttributes().get("shadowDepth");
+ if (shadow == null) {
+ shadow = Integer.toString(SHADOW_DEPTH);
+ }
- String border = (String) component.getAttributes().get("border");
- if (border == null || border.length() == 0) {
- return "0";
- }
+ return "top: " + shadow + "px; left: " + shadow +"px; ";
+ }
- return border;
- }
+ /**
+ * Gets additional scripts.
+ *
+ * @return array of resources
+ * {@link org.ajax4jsf.framework.resource.InternetResource}
+ */
+ protected final InternetResource[] getAdditionalScripts() {
+ return additionalScripts;
+ }
- /**
- * Gets context identifier.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return context identifier
- */
- public final String getContentId(final FacesContext context,
- final UIComponent component) {
- return component.getClientId(context) + NamingContainer.SEPARATOR_CHAR
- + "suggest";
- }
+ /**
+ * Gets styles.
+ *
+ * @return array of styles
+ * {@link org.ajax4jsf.framework.resource.InternetResource}
+ */
+ protected final InternetResource[] getStyles() {
+ return styles;
+ }
- /**
- * Gets overflow sizes.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return overflow style
- */
- public final String overflowSize(final FacesContext context,
- final UIComponent component) {
- StringBuffer style = new StringBuffer();
+ /**
+ * Gets style for width & height.
+ * @param component {@link javax.faces.component.UIComponent}
+ * @param attr attribute
+ * @param def default value
+ * @param isShadow TRUE if shadow exists
+ * @return style
+ */
+ private String getSizeForStyle(final UIComponent component,
+ final String attr,
+ final String def,
+ final boolean isShadow) {
+ Map attributes = component.getAttributes();
+ StringBuffer style = new StringBuffer();
- style.append(getSizeForStyle(component, "width", null, true));
- style.append(getSizeForStyle(component, "height", null, true));
+ String attribute = (String) attributes.get(attr);
+ if (attribute == null && def != null) {
+ attribute = def;
+ }
- return style.toString();
- }
+ if (attribute != null && (!attribute.equals(""))) {
+ if (isShadow) {
+ attribute = String.valueOf(Integer.parseInt(attribute)
+ - SHADOW_DEPTH);
+ }
- /**
- * Gets shadow style.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return shadow style
- */
- public final String shadowDepth(final FacesContext context,
- final UIComponent component) {
- String shadow = (String) component.getAttributes().get("shadowDepth");
- if (shadow == null) {
- shadow = Integer.toString(SHADOW_DEPTH);
- }
+ style.append(attr).append(":").append(attribute);
+ if (Pattern.matches("\\d*", attribute)) {
+ style.append("px");
+ }
+ style.append(";");
+ }
- return "top: " + shadow + "px; left: " + shadow + "px; ";
- }
-
- /**
- * Gets additional scripts.
- *
- * @return array of resources
- * {@link org.ajax4jsf.framework.resource.InternetResource}
- */
- protected final InternetResource[] getAdditionalScripts() {
- return additionalScripts;
- }
-
- /**
- * Gets styles.
- *
- * @return array of styles
- * {@link org.ajax4jsf.framework.resource.InternetResource}
- */
- protected final InternetResource[] getStyles() {
- return styles;
- }
-
- /**
- * Gets style for width & height.
- *
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @param attr
- * attribute
- * @param def
- * default value
- * @param isShadow
- * TRUE if shadow exists
- * @return style
- */
- private String getSizeForStyle(final UIComponent component,
- final String attr, final String def, final boolean isShadow) {
- Map attributes = component.getAttributes();
- StringBuffer style = new StringBuffer();
-
- String attribute = (String) attributes.get(attr);
- if (attribute == null && def != null) {
- attribute = def;
- }
-
- if (attribute != null && (!attribute.equals(""))) {
- if (isShadow) {
- attribute = String.valueOf(Integer.parseInt(attribute)
- - SHADOW_DEPTH);
- }
-
- style.append(attr).append(":").append(attribute);
- if (Pattern.matches("\\d*", attribute)) {
- style.append("px");
- }
- style.append(";");
- }
-
- return style.toString();
- }
-
- public void insertNothingLabel(final FacesContext context,
- final UIComponent component) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- UISuggestionBox suggestionBox = (UISuggestionBox) component;
- final String startHtml = "<tr id=\""
- + suggestionBox.getClientId(context)
- + "NothingLabel\" class=\"dr-sb-int rich-sb-int "
- + suggestionBox.getRowClasses()
- + "\" style=\"display: none;\">"
- + "<td nowrap=\"nowrap\" class=\"dr-sb-cell-padding rich-sb-cell-padding\" style=\""
- + this.cellPadding(context, component) + "\">";
- final String endHtml = "</td></tr>";
-
- UIComponent nothingLabelFacet = component.getFacet("nothingLabel");
- if (null != nothingLabelFacet && nothingLabelFacet.isRendered()) {
- writer.write(startHtml);
- renderChild(context, nothingLabelFacet);
- writer.write(endHtml);
- } else if (null != suggestionBox.getNothingLabel()
- && !"".equals(suggestionBox.getNothingLabel())) {
- writer.write(startHtml);
- writer.write(suggestionBox.getNothingLabel());
- writer.write(endHtml);
- }
-
- }
-
- /**
- * Gets 'class' attribute for suggestion entry.
- *
- * @param context
- * {@link javax.faces.context.FacesContext}
- * @param component
- * {@link javax.faces.component.UIComponent}
- * @return 'class' attribute for 'tr' element of suggestion entry.
- */
- public final String getEntryClass(final FacesContext context,
- final UIComponent component) {
- String entryClass = (String) component.getAttributes()
- .get("entryClass");
- if (null == entryClass)
- entryClass = "";
- String rowClass = (String) component.getAttributes().get("rowClasses");
- if (null == rowClass)
- rowClass = "";
-
- return "dr-sb-int rich-sb-int " + entryClass + " " + rowClass;
- }
-
+ return style.toString();
+ }
+
+ public void insertNothingLabel(final FacesContext context,
+ final UIComponent component) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ UISuggestionBox suggestionBox = (UISuggestionBox)component;
+ final String startHtml =
+ "<tr id=\"" + suggestionBox.getClientId(context) + "NothingLabel\" class=\"dr-sb-int rich-sb-int " + suggestionBox.getRowClasses() +
+ "\" style=\"display: none;\">" +
+ "<td nowrap=\"nowrap\" class=\"dr-sb-cell-padding rich-sb-cell-padding\" style=\"" + this.cellPadding(context, component) + "\">";
+ final String endHtml = "</td></tr>";
+
+ UIComponent nothingLabelFacet = component.getFacet("nothingLabel");
+ if(null != nothingLabelFacet && nothingLabelFacet.isRendered()) {
+ writer.write(startHtml);
+ renderChild(context, nothingLabelFacet);
+ writer.write(endHtml);
+ }
+ else if (null != suggestionBox.getNothingLabel() &&
+ !"".equals(suggestionBox.getNothingLabel())) {
+ writer.write(startHtml);
+ writer.write(suggestionBox.getNothingLabel());
+ writer.write(endHtml);
+ }
+
+ }
+
+ /**
+ * Gets 'class' attribute for suggestion entry.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return 'class' attribute for 'tr' element of suggestion entry.
+ */
+ public final String getEntryClass(final FacesContext context,
+ final UIComponent component) {
+ String entryClass = (String) component.getAttributes().get("entryClass");
+ if (null == entryClass)
+ entryClass = "";
+ String rowClass = (String) component.getAttributes().get("rowClasses");
+ if (null == rowClass)
+ rowClass = "";
+
+ return "dr-sb-int rich-sb-int " + entryClass + " " + rowClass;
+ }
}
Modified: trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
--- trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-14 01:29:52 UTC (rev 6798)
+++ trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-14 01:30:03 UTC (rev 6799)
@@ -753,11 +753,11 @@
{
for (var i=0;i<this.selectedItems.length; i++)
{
- if (!this.selectedItems.object) list.push(this.selectedItems.text);
+ if (!this.selectedItems[i].object) list.push(this.selectedItems[i].text);
}
result = list.join(this.options.tokens[0]);
}
- else if (this.selectedItems.length!=0 && !this.selectedItems[0].object) result = this.selectedItems.object;
+ else if (this.selectedItems.length!=0 && !this.selectedItems[0].object) result = this.selectedItems[0].object;
return result;
},
Modified: trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
===================================================================
--- trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2008-03-14 01:29:52 UTC (rev 6798)
+++ trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2008-03-14 01:30:03 UTC (rev 6799)
@@ -118,12 +118,6 @@
HtmlElement iframe = page.getHtmlElementById(sb.getClientId(facesContext) + "_iframe");
assertNotNull(iframe);
assertEquals("iframe", iframe.getNodeName());
- HtmlElement input_select = page.getHtmlElementById(sb.getClientId(facesContext)+"_selection");
- assertNotNull(input_select);
- assertSame("input", input_select.getNodeName());
- HtmlElement input_fetchValue = page.getHtmlElementById(sb.getClientId(facesContext)+"_hiddenFetchValue");
- assertNotNull(input_fetchValue);
- assertSame("input", input_fetchValue.getNodeName());
}
/**
16 years, 10 months