JBoss Rich Faces SVN: r19646 - in trunk/ui/input: ui/src/main/java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-21 13:44:09 -0400 (Thu, 21 Oct 2010)
New Revision: 19646
Modified:
trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js
trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
trunk/ui/input/ui/src/main/templates/select.template.xml
Log:
fix renderers, add defaultOptions, fix client filtering for the select
Modified: trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -38,5 +38,17 @@
public boolean isSaveOnBlur();
public InplaceState getState();
+
+ public String getReadyStateCss();
+ public String getEditStateCss();
+
+ public String getChangedStateCss();
+
+ public String getDisableStateCss();
+
+ public String getEditCss();
+
+ public String getNoneCss();
+
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -67,6 +67,24 @@
@Attribute
public abstract String getTabIndex();
+ @Attribute
+ public abstract String getReadyStateCss();
+
+ @Attribute
+ public abstract String getEditStateCss();
+
+ @Attribute
+ public abstract String getChangedStateCss();
+
+ @Attribute
+ public abstract String getDisableStateCss();
+
+ @Attribute
+ public abstract String getEditCss();
+
+ @Attribute
+ public abstract String getNoneCss();
+
@Attribute(events=@EventName("blur"))
public abstract String getOnblur();
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -57,23 +57,24 @@
public abstract boolean isSaveOnBlur();
@Attribute(defaultValue="false")
- public abstract boolean isShowControls();
+ public abstract boolean isShowControls();
- @Attribute(defaultValue="click")
- public abstract String getEditEvent();
-
@Override
- @Attribute(defaultValue="rf-is-opt")
+ @Attribute
public abstract String getItemCss();
@Override
- @Attribute(defaultValue="rf-is-sel")
+ @Attribute
public abstract String getSelectItemCss();
@Override
- @Attribute(defaultValue="rf-is-lst-cord")
+ @Attribute
public abstract String getListCss();
+
+ @Attribute(defaultValue="click")
+ public abstract String getEditEvent();
+
@Attribute(events=@EventName("inputclick"))
public abstract String getOninputclick();
@@ -109,5 +110,11 @@
@Attribute(events=@EventName("inputblur"))
public abstract String getOninputblur();
+
+ @Attribute(events=@EventName("inputselect"))
+ public abstract String getOninputselect();
+
+ @Attribute(events=@EventName("inputchange"))
+ public abstract String getOnchange();
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -30,7 +30,6 @@
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
-
/**
* @author abelevich
*
@@ -57,9 +56,24 @@
@Attribute(defaultValue="true")
public abstract boolean isShowButton();
+ @Attribute(defaultValue="false")
+ public abstract boolean isEnableManualInput();
+
+ @Attribute(defaultValue="true")
+ public abstract boolean isSelectFirst();
+
@Attribute
public abstract String getDefaultLabel();
+ @Attribute
+ public abstract String getItemCss();
+
+ @Attribute
+ public abstract String getSelectItemCss();
+
+ @Attribute
+ public abstract String getListCss();
+
@Attribute(events=@EventName("blur"))
public abstract String getOnblur();
@@ -131,16 +145,5 @@
@Attribute(events=@EventName("change"))
public abstract String getOnchange();
- //TODO: add list event attributes
-
- @Attribute(defaultValue = "rf-sel-opt")
- public abstract String getItemCss();
-
- //TODO: rename css class "rf-sel-opt-sel"
- @Attribute(defaultValue = "rf-sel-sel")
- public abstract String getSelectItemCss();
-
- @Attribute(defaultValue = "rf-sel-lst-cord")
- public abstract String getListCss();
-
+
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -84,8 +84,12 @@
public static final String OPTIONS_INITIAL_VALUE = "initialValue";
public static final String OPTIONS_SAVE_ON_BLUR = "saveOnBlur";
-
- protected static final Map<String, ComponentAttribute> INPLACEINPUT_HANDLER_ATTRIBUTES = Collections
+
+
+
+
+ //TODO: anton - move to RenderUtils (we use the same in the calendar base renderer) ?
+ protected static final Map<String, ComponentAttribute> INPLACE_INPUT_HANDLER_ATTRIBUTES = Collections
.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
.setEventNames("inputclick")
@@ -133,7 +137,7 @@
public void renderInputHandlers(FacesContext facesContext,
UIComponent component) throws IOException {
RenderKitUtils.renderPassThroughAttributesOptimized(facesContext,
- component, INPLACEINPUT_HANDLER_ATTRIBUTES);
+ component, INPLACE_INPUT_HANDLER_ATTRIBUTES);
}
public InplaceState getInplaceState(UIComponent component) {
@@ -158,20 +162,20 @@
return null;
}
- public String getStateStyleClass(UIComponent component,
- InplaceState inplaceState) {
- String style = getReadyStateCss();
+ public String getStateStyleClass(UIComponent component, InplaceState inplaceState) {
+ InplaceComponent inplaceComponent = (InplaceComponent)component;
+ String style = getReadyStateCss(inplaceComponent);
switch (inplaceState) {
case edit:
- style = HtmlUtil.concatClasses(style, getEditStateCss());
+ style = HtmlUtil.concatClasses(style, getEditStateCss(inplaceComponent));
break;
case changed:
- style = HtmlUtil.concatClasses(style, getChangedStateCss());
+ style = HtmlUtil.concatClasses(style, getChangedStateCss(inplaceComponent));
break;
case disable:
- style = getDisableStateCss();
+ style = getDisableStateCss(inplaceComponent);
break;
default:
@@ -185,9 +189,9 @@
return (InplaceState.disable == currentState);
}
- public String getEditStyleClass(UIComponent component,
- InplaceState inplaceState) {
- return (InplaceState.edit != inplaceState) ? HtmlUtil.concatClasses(getEditCss(), getNoneCss()) : getEditCss();
+ public String getEditStyleClass(UIComponent component, InplaceState inplaceState) {
+ InplaceComponent inplaceComponent = (InplaceComponent)component;
+ return (InplaceState.edit != inplaceState) ? HtmlUtil.concatClasses(getEditCss(inplaceComponent), getNoneCss(inplaceComponent)) : getEditCss(inplaceComponent);
}
public void buildScript(ResponseWriter writer, FacesContext facesContext,
@@ -214,25 +218,43 @@
private Map<String, Object> createInplaceComponentOptions(String clientId,
InplaceComponent inplaceComponent) {
Map<String, Object> options = new HashMap<String, Object>();
- options.put(OPTIONS_EDIT_EVENT, inplaceComponent.getEditEvent());
- options.put(OPTIONS_STATE, inplaceComponent.getState());
- options.put(OPTIONS_NONE_CSS, getNoneCss());
- options.put(OPTIONS_CHANGED_CSS, getChangedStateCss());
- options.put(OPTIONS_EDIT_CSS, getEditStateCss());
- options.put(OPTIONS_EDIT_CONTAINER, clientId + "Edit");
- options.put(OPTIONS_INPUT, clientId + "Input");
- options.put(OPTIONS_LABEL, clientId + "Label");
- options.put(OPTIONS_FOCUS, clientId + "Focus");
- options.put(OPTIONS_DEFAULT_LABEL, inplaceComponent.getDefaultLabel());
- options.put(OPTIONS_SAVE_ON_BLUR, inplaceComponent.isSaveOnBlur());
+
+ if(!"click".equals(inplaceComponent.getEditEvent())){
+ options.put(OPTIONS_EDIT_EVENT, inplaceComponent.getEditEvent());
+ }
+
+ if(!(InplaceState.ready == inplaceComponent.getState())) {
+ options.put(OPTIONS_STATE, inplaceComponent.getState());
+ }
+
+ String css = inplaceComponent.getNoneCss();
+ if(css != null && css.trim().length() > 0) {
+ options.put(OPTIONS_NONE_CSS, getNoneCss(inplaceComponent));
+ }
- boolean showControls = inplaceComponent.isShowControls();
-
- options.put(OPTIONS_SHOWCONTROLS, showControls);
- if (showControls) {
- options.put(OPTIONS_BUTTON_OK, clientId + "Okbtn");
- options.put(OPTIONS_BUTTON_CANCEL, clientId + "Cancelbtn");
+ css = inplaceComponent.getChangedStateCss();
+ if(css != null && css.trim().length() > 0) {
+ options.put(OPTIONS_CHANGED_CSS, getChangedStateCss(inplaceComponent));
+ }
+
+ css = inplaceComponent.getEditStateCss();
+ if(css != null && css.trim().length() > 0) {
+ options.put(OPTIONS_EDIT_CSS, getEditStateCss(inplaceComponent));
}
+
+ String label = inplaceComponent.getDefaultLabel();
+ if(label != null && label.trim().length() > 0) {
+ options.put(OPTIONS_DEFAULT_LABEL, inplaceComponent.getDefaultLabel());
+ }
+
+ if(!inplaceComponent.isSaveOnBlur()) {
+ options.put(OPTIONS_SAVE_ON_BLUR, inplaceComponent.isSaveOnBlur());
+ }
+
+ if(inplaceComponent.isShowControls()) {
+ options.put(OPTIONS_SHOWCONTROLS, inplaceComponent.isShowControls());
+ }
+
return options;
}
@@ -241,27 +263,33 @@
// override this method if you need additional options
}
- public String getReadyStateCss() {
- return "rf-ii-d-s";
+ public String getReadyStateCss(InplaceComponent component) {
+ String css = component.getReadyStateCss();
+ return HtmlUtil.concatClasses("rf-ii-d-s", css);
}
- public String getEditStateCss() {
- return "rf-ii-e-s";
+ public String getEditStateCss(InplaceComponent component) {
+ String css = component.getEditStateCss();
+ return HtmlUtil.concatClasses("rf-ii-e-s", css);
}
- public String getChangedStateCss() {
- return "rf-ii-c-s";
+ public String getChangedStateCss(InplaceComponent component) {
+ String css = component.getChangedStateCss();
+ return HtmlUtil.concatClasses("rf-ii-c-s", css);
}
- public String getDisableStateCss() {
- return "rf-ii-dis-s";
+ public String getDisableStateCss(InplaceComponent component) {
+ String css = component.getDisableStateCss();
+ return HtmlUtil.concatClasses("rf-ii-dis-s", css);
}
-
- public String getEditCss() {
- return "rf-ii-edit";
+
+ public String getEditCss(InplaceComponent component) {
+ String css = component.getEditCss();
+ return HtmlUtil.concatClasses("rf-ii-edit", css);
}
- public String getNoneCss() {
- return "rf-ii-none";
+ public String getNoneCss(InplaceComponent component) {
+ String css = component.getNoneCss();
+ return HtmlUtil.concatClasses("rf-ii-none", css);
}
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -32,6 +32,9 @@
import javax.faces.context.FacesContext;
import org.richfaces.component.AbstractInplaceSelect;
+import org.richfaces.component.AbstractSelect;
+import org.richfaces.component.InplaceComponent;
+import org.richfaces.component.util.HtmlUtil;
/**
* @author Anton Belevich
@@ -41,7 +44,6 @@
@ResourceDependencies({
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "jquery.position.js"),
@ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "jquery.position.js"),
@ResourceDependency(name = "richfaces-event.js"),
@@ -57,7 +59,14 @@
public class InplaceSelectRendererBase extends InplaceInputRendererBase {
public static final String OPTIONS_VISIBLE = "visible";
+
+ public static final String ITEM_CSS = "rf-is-opt";
+
+ public static final String SELECT_ITEM_CSS = "rf-is-sel";
+ public static final String LIST_CSS = "rf-is-lst-cord";
+
+
@Override
protected String getScriptName() {
return "new RichFaces.ui.InplaceSelect";
@@ -68,7 +77,7 @@
}
public void encodeItems(FacesContext facesContext, UIComponent component, List<ClientSelectItem> clientSelectItems) throws IOException {
- SelectHelper.encodeItems(facesContext, component, clientSelectItems, HtmlConstants.SPAN_ELEM);
+ SelectHelper.encodeItems(facesContext, component, clientSelectItems, HtmlConstants.SPAN_ELEM, ITEM_CSS);
}
public void renderListHandlers(FacesContext facesContext, UIComponent component) throws IOException {
@@ -77,7 +86,7 @@
@Override
public void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
- RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, INPLACEINPUT_HANDLER_ATTRIBUTES);
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, INPLACE_INPUT_HANDLER_ATTRIBUTES);
}
public String getSelectInputLabel(FacesContext facesContext, UIComponent component) {
@@ -86,15 +95,13 @@
@Override
public void addToOptions(FacesContext facesContext, UIComponent component, Map<String, Object> options, Object additional) {
- options.put(PopupConstants.OPTIONS_ITEM_CLASS, "rf-is-opt");
- options.put(PopupConstants.OPTIONS_SELECT_ITEM_CLASS, "rf-is-sel");
-
- String clientId = component.getClientId(facesContext);
- options.put(PopupConstants.OPTIONS_LIST_CORD, clientId + "List");
- options.put(PopupConstants.OPTIONS_LIST_CLASS, component.getAttributes().get("listCss"));
- options.put(SelectHelper.OPTIONS_SELECT_ITEM_VALUE_INPUT, clientId + "selValue");
+ AbstractSelect abstractSelect = (AbstractSelect)component;
+ SelectHelper.addSelectCssToOptions(abstractSelect, options, new String[] {ITEM_CSS, SELECT_ITEM_CSS, LIST_CSS});
+ boolean openOnEdit = (Boolean)component.getAttributes().get("openOnEdit");
+ if(openOnEdit) {
+ options.put(OPTIONS_VISIBLE, openOnEdit);
+ }
options.put(SelectHelper.OPTIONS_LIST_ITEMS, additional);
- options.put(OPTIONS_VISIBLE, component.getAttributes().get("openOnEdit"));
}
public String getSelectLabel(FacesContext facesContext, UIComponent component) {
@@ -106,32 +113,33 @@
return label;
}
- public String getListStyles(FacesContext facesContext, UIComponent component) {
- AbstractInplaceSelect inplaceSelect = (AbstractInplaceSelect) component;
- return inplaceSelect.isOpenOnEdit() ? "" : "display: none";
+ public String getReadyStateCss(InplaceComponent component) {
+ String css = component.getReadyStateCss();
+ return HtmlUtil.concatClasses("rf-is-d-s", css);
}
- public String getReadyStateCss() {
- return "rf-is-d-s";
+ public String getEditStateCss(InplaceComponent component) {
+ String css = component.getEditStateCss();
+ return HtmlUtil.concatClasses("rf-is-e-s", css);
}
- public String getEditStateCss() {
- return "rf-is-e-s";
+ public String getChangedStateCss(InplaceComponent component) {
+ String css = component.getChangedStateCss();
+ return HtmlUtil.concatClasses("rf-is-c-s", css);
}
- public String getChangedStateCss() {
- return "rf-is-c-s";
+ public String getDisableStateCss(InplaceComponent component) {
+ String css = component.getDisableStateCss();
+ return HtmlUtil.concatClasses("rf-is-dis-s", css);
}
-
- public String getDisableStateCss() {
- return "rf-is-dis-s";
- }
- public String getEditCss() {
- return "rf-is-edit";
+ public String getEditCss(InplaceComponent component) {
+ String css = component.getEditCss();
+ return HtmlUtil.concatClasses("rf-is-edit", css);
}
- public String getNoneCss() {
- return "rf-is-none";
+ public String getNoneCss(InplaceComponent component) {
+ String css = component.getNoneCss();
+ return HtmlUtil.concatClasses("rf-is-none", css);
}
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -34,6 +34,7 @@
import javax.faces.model.SelectItem;
import org.richfaces.component.AbstractSelect;
+import org.richfaces.component.util.HtmlUtil;
import org.richfaces.component.util.InputUtils;
import org.richfaces.component.util.SelectUtils;
@@ -45,11 +46,14 @@
public static final String OPTIONS_SHOWCONTROL = "showControl";
- public static final String OPTIONS_SELECT_ITEM_VALUE_INPUT = "selValueInput";
-
public static final String OPTIONS_LIST_ITEMS = "items";
+ public static final String OPTIONS_ENABLE_MANUAL_INPUT = "enableManualInput";
+ public static final String OPTIONS_LIST_SELECT_FIRST = "selectFirst";
+
+ public static final String OPTIONS_INPUT_DEFAULT_LABEL = "defaultLabel";
+
public static final Map<String, ComponentAttribute> SELECT_LIST_HANDLER_ATTRIBUTES = Collections
.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
@@ -101,7 +105,7 @@
}
public static void encodeItems(FacesContext facesContext, UIComponent component,
- List<ClientSelectItem> clientSelectItems, String itemHtmlElement) throws IOException {
+ List<ClientSelectItem> clientSelectItems, String itemHtmlElement, String defaultItemCss) throws IOException {
AbstractSelect select = (AbstractSelect) component;
if (clientSelectItems != null && !clientSelectItems.isEmpty()) {
ResponseWriter writer = facesContext.getResponseWriter();
@@ -114,7 +118,8 @@
writer.startElement(itemHtmlElement, select);
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, itemClientId,
null);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, select.getItemCss(), null);
+
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, HtmlUtil.concatClasses(defaultItemCss, select.getItemCss()), null);
String label = clientSelectItem.getLabel();
if (label != null && label.trim().length() > 0) {
@@ -146,5 +151,21 @@
return label;
}
-
+
+ public static void addSelectCssToOptions(AbstractSelect abstractSelect, Map<String, Object> options, String [] defaultCss) {
+ String itemCss = abstractSelect.getItemCss();
+ if(itemCss != null && itemCss.trim().length() > 0) {
+ options.put(PopupConstants.OPTIONS_ITEM_CLASS, HtmlUtil.concatClasses(defaultCss[0], itemCss));
+ }
+
+ String selectItemCss = abstractSelect.getSelectItemCss();
+ if(selectItemCss != null && selectItemCss.trim().length() > 0) {
+ options.put(PopupConstants.OPTIONS_SELECT_ITEM_CLASS, HtmlUtil.concatClasses(defaultCss[1], selectItemCss));
+ }
+
+ String listCss = abstractSelect.getListCss();
+ if(listCss != null && listCss.trim().length() > 0) {
+ options.put(PopupConstants.OPTIONS_LIST_CLASS, HtmlUtil.concatClasses(defaultCss[2], listCss));
+ }
+ }
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-10-21 17:44:09 UTC (rev 19646)
@@ -36,6 +36,10 @@
import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.AbstractSelect;
+/**
+ * @author abelevich
+ *
+ */
@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "jquery.position.js"),
@ResourceDependency(name = "richfaces.js"), @ResourceDependency(name = "jquery.position.js"),
@@ -44,10 +48,18 @@
@ResourceDependency(library = "org.richfaces", name = "inputBase.js"),
@ResourceDependency(library = "org.richfaces", name = "popup.js"),
@ResourceDependency(library = "org.richfaces", name = "popupList.js"),
+ @ResourceDependency(library = "org.richfaces", name = "selectList.js"),
@ResourceDependency(library = "org.richfaces", name = "select.js"),
@ResourceDependency(library = "org.richfaces", name = "select.ecss") })
public class SelectRendererBase extends InputRendererBase {
+
+ public static final String ITEM_CSS = "rf-sel-opt";
+
+ public static final String SELECT_ITEM_CSS = "rf-sel-sel";
+ public static final String LIST_CSS = "rf-sel-lst-cord";
+
+
public void renderListHandlers(FacesContext facesContext, UIComponent component) throws IOException {
RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, SelectHelper.SELECT_LIST_HANDLER_ATTRIBUTES);
}
@@ -71,7 +83,7 @@
public void encodeItems(FacesContext facesContext, UIComponent component, List<ClientSelectItem> clientSelectItems)
throws IOException {
- SelectHelper.encodeItems(facesContext, component, clientSelectItems, HtmlConstants.DIV_ELEM);
+ SelectHelper.encodeItems(facesContext, component, clientSelectItems, HtmlConstants.DIV_ELEM, ITEM_CSS);
}
public void buildScript(ResponseWriter writer, FacesContext facesContext, UIComponent component, List<ClientSelectItem> selectItems) throws IOException {
@@ -85,15 +97,27 @@
String clientId = abstractSelect.getClientId(facesContext);
Map<String, Object> options = new HashMap<String, Object>();
- options.put(SelectHelper.OPTIONS_SHOWCONTROL, abstractSelect.isShowButton());
options.put(SelectHelper.OPTIONS_LIST_ITEMS, selectItems);
- options.put(SelectHelper.OPTIONS_SELECT_ITEM_VALUE_INPUT, clientId + "selValue");
- options.put(PopupConstants.OPTIONS_ITEM_CLASS, abstractSelect.getItemCss());
- options.put(PopupConstants.OPTIONS_SELECT_ITEM_CLASS, abstractSelect.getSelectItemCss());
- options.put(PopupConstants.OPTIONS_LIST_CLASS, abstractSelect.getListCss());
- options.put(PopupConstants.OPTIONS_LIST_CORD, clientId + "List");
+
+ if(!abstractSelect.isShowButton()) {
+ options.put(SelectHelper.OPTIONS_SHOWCONTROL, abstractSelect.isShowButton());
+ }
+
+ String defaultLabel = abstractSelect.getDefaultLabel();
+ if( defaultLabel != null && defaultLabel.trim().length() > 0) {
+ options.put(SelectHelper.OPTIONS_INPUT_DEFAULT_LABEL, defaultLabel);
+ }
+
+ if(abstractSelect.isEnableManualInput()) {
+ options.put(SelectHelper.OPTIONS_ENABLE_MANUAL_INPUT, abstractSelect.isEnableManualInput());
+ }
+
+ if(!abstractSelect.isSelectFirst()) {
+ options.put(SelectHelper.OPTIONS_LIST_SELECT_FIRST, abstractSelect.isSelectFirst());
+ }
+
+ SelectHelper.addSelectCssToOptions(abstractSelect, options, new String[] {ITEM_CSS, SELECT_ITEM_CSS, LIST_CSS});
-
function.addParameter(clientId);
function.addParameter(options);
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -44,27 +44,27 @@
rf.ui.InplaceBase = function(id, options) {
$super.constructor.call(this, id);
-
- this.editEvent = options.editEvent;
- this.noneCss = options.noneCss;
- this.changedCss = options.changedCss;
- this.defaultLabel = options.defaultLabel;
- this.state = options.state;
-
+ var mergedOptions = $.extend({}, defaultOptions, options);
+ this.editEvent = mergedOptions.editEvent;
+ this.noneCss = mergedOptions.noneCss;
+ this.changedCss = mergedOptions.changedCss;
+ this.defaultLabel = mergedOptions.defaultLabel;
+ this.state = mergedOptions.state;
this.element = $(document.getElementById(id));
- this.editContainer = $(document.getElementById(options.editContainer));
- this.state = options.state;
-
+ this.editContainer = $(document.getElementById(id+"Edit"));
this.element.bind(this.editEvent, $.proxy(this.__editHandler, this));
-
this.isSaved = false;
this.useDefaultLabel = false;
-
};
rf.ui.InputBase.extend(rf.ui.InplaceBase);
var $super = rf.ui.InplaceBase.$super;
+ var defaultOptions = {
+ editEvent: "click",
+ state: "ready"
+ };
+
$.extend(rf.ui.InplaceBase.prototype, ( function () {
var STATE = {
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -3,33 +3,41 @@
rf.ui = rf.ui || {};
rf.ui.InplaceInput = function(id, options) {
- $super.constructor.call(this, id, options);
-
- //rename input id in template (id + "Input")
-
- this.label = $(document.getElementById(options.label));
-
- var label = this.label.text();
+ var mergedOptions = $.extend({}, defaultOptions, options);
+ $super.constructor.call(this, id, mergedOptions);
+ this.label = $(document.getElementById(id+"Label"));
+ var labelText = this.label.text();
var inputLabel = this.getValue();
- this.initialValue = (label == inputLabel) ? label : "";
- this.saveOnBlur = options.saveOnBlur;
- this.showControls = options.showControls;
-
+ this.initialValue = (labelText == inputLabel) ? labelText : "";
+ this.saveOnBlur = mergedOptions.saveOnBlur;
+ this.showControls = mergedOptions.showControls;
this.getInput().bind("focus", $.proxy(this.__editHandler, this));
if(this.showControls) {
- this.okbtn = $(document.getElementById(options.okbtn));
- this.cancelbtn = $(document.getElementById(options.cancelbtn));
+ this.okbtn = $(document.getElementById(id+"Okbtn"));
+ this.cancelbtn = $(document.getElementById(id+"Cancelbtn"));
this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler, this));
this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler, this));
}
-
- this.focusElement = $(document.getElementById(options.focusElement));
+ this.focusElement = $(document.getElementById(id+"Focus"));
};
rf.ui.InplaceBase.extend(rf.ui.InplaceInput);
var $super = rf.ui.InplaceInput.$super;
-
+
+ var defaultOptions = {
+ defaultLabel: "",
+ saveOnBlur: true,
+ showControl: true,
+ itemCss: "rf-ii-opt",
+ selectItemCss: "rf-ii-sel",
+ listCss: "rf-ii-lst-cord",
+ noneCss: "rf-ii-none",
+ //not used in inputBase?
+ editCss: "rf-ii-edit",
+ changedCss: "rf-ii-c-s"
+ };
+
$.extend(rf.ui.InplaceInput.prototype, ( function () {
return {
@@ -45,15 +53,7 @@
},
__keydownHandler: function(e) {
- var code;
-
- if(e.keyCode) {
- code = e.keyCode;
- } else if(e.which) {
- code = e.which;
- }
-
- switch(code) {
+ switch(e.keyCode || e.which) {
case 27:
e.preventDefault();
this.cancel();
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -3,21 +3,30 @@
rf.ui = rf.ui || {};
rf.ui.InplaceSelect = function(id, options) {
- $super.constructor.call(this, id, options)
-
- options['attachTo'] = id;
- options['attachToBody'] = true;
- this.popupList = new rf.ui.PopupList(options.list, this, options);
-
- this.items = options.items;
- this.selValueInput = $(document.getElementById(options.selValueInput));
+ var mergedOptions = $.extend({}, defaultOptions, options);
+ $super.constructor.call(this, id, mergedOptions)
+ mergedOptions['attachTo'] = id;
+ this.popupList = new rf.ui.PopupList(id+"List", this, mergedOptions);
+ this.items = mergedOptions.items;
+ this.selValueInput = $(document.getElementById(id+"selValue"));
this.openPopup = false;
-
}
rf.ui.InplaceInput.extend(rf.ui.InplaceSelect);
var $super = rf.ui.InplaceSelect.$super;
+ var defaultOptions = {
+ defaultLabel: "",
+ showControl: false,
+ itemCss: "rf-is-opt",
+ selectItemCss: "rf-is-sel",
+ listCss: "rf-is-lst-cord",
+ noneCss: "rf-is-none",
+ editCss: "rf-is-edit",
+ changedCss: "rf-is-c-s"
+ };
+
+
$.extend(rf.ui.InplaceSelect.prototype, ( function () {
return{
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -7,9 +7,12 @@
this.attachToDom(id);
this.popup = $(document.getElementById(id));
- this.visible = options.visible;
- this.attachTo = options.attachTo;
- this.attachToBody = options.attachToBody;
+ var mergedOptions = $.extend({}, defaultOptions, options);
+ this.visible = mergedOptions.visible;
+ this.attachTo = mergedOptions.attachTo;
+ this.attachToBody = mergedOptions.attachToBody;
+ this.positionType = mergedOptions.positionType;
+ this.positionOffset = mergedOptions.positionOffset;
this.popup.bind("mouseover", $.proxy(this.__onMouseOver, this));
this.popup.bind("click", $.proxy(this.__onClick, this));
@@ -17,6 +20,11 @@
rf.BaseComponent.extend(rf.ui.Popup);
var $super = rf.ui.Popup.$super;
+
+
+ var defaultOptions = {
+ visible: false
+ };
$.extend(rf.ui.Popup.prototype, (function () {
@@ -30,7 +38,7 @@
this.parentElement = this.popup.parent();
this.popup.detach().appendTo("body");
}
- this.popup.setPosition({id: this.attachTo}, {type:"DROPDOWN", offset:[0,20]}).show();
+ this.popup.setPosition({id: this.attachTo}, {type: this.positionType , offset: this.positionOffset}).show();
this.visible = true;
}
},
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -3,17 +3,25 @@
rf.ui = rf.ui || {};
rf.ui.PopupList = function(id, listener, options) {
- $super.constructor.call(this, id, options);
+ var mergedOptions = $.extend({}, defaultOptions, options);
+ $super.constructor.call(this, id, mergedOptions);
this.selectListener = listener;
- this.selectItemCss = options.selectItemCss;
- this.itemCss = options.itemCss;
- this.listCss = options.listCss;
+ this.selectItemCss = mergedOptions.selectItemCss;
+ this.itemCss = mergedOptions.itemCss;
+ this.listCss = mergedOptions.listCss;
this.index = -1;
this.__updateItemsList();
};
rf.ui.Popup.extend(rf.ui.PopupList);
var $super = rf.ui.PopupList.$super;
+
+ var defaultOptions = {
+ attachToBody: true,
+ positionType: "DROPDOWN",
+ positionOffset: [0,20]
+ };
+
$.extend(rf.ui.PopupList.prototype, ( function () {
@@ -43,13 +51,23 @@
}
},
+ resetItemsSelection: function() {
+ if(this.items) {
+ var popup = this;
+ this.items.each(function(i,item){
+ popup.unselectItem($(item));
+ }
+ );
+ }
+ },
+
isPopupList: function(target) {
var parentId = target.parents("." + this.listCss).attr("id");
return (parentId && (parentId == this.getId()));
},
__updateItemsList: function () {
- this.items = this.popup.find("."+this.itemCss);
+ return (this.items = this.popup.find("."+this.itemCss));
},
__select: function(item) {
@@ -126,7 +144,11 @@
__getItems: function () {
return this.items;
- }
+ },
+
+ __setItems: function(items) {
+ this.items = items;
+ }
}
})());
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -1,4 +1,4 @@
-//TODO: to the utils?
+//TODO: to the utils? <--
(function (rf) {
rf.KEYS = {
BACKSPACE: 8,
@@ -16,30 +16,152 @@
})(RichFaces);
+//TODO: remove when cache will be moved to utils <--
(function ($, rf) {
+ rf.utils = rf.utils || {};
+
+ rf.utils.Cache = function (key, items, values, useCache) {
+ this.key = key.toLowerCase();
+ this.cache = {}
+ this.cache[this.key] = items || [];
+ this.originalValues = typeof values == "function" ? values(items) : values || this.cache[this.key];
+ this.values = processValues(this.originalValues);
+ this.useCache = useCache || checkValuesPrefix.call(this);
+ };
+ var processValues = function (values) {
+ var processedValues = [];
+ for (var i = 0; i<values.length; i++) {
+ processedValues.push(values[i].toLowerCase());
+ }
+ return processedValues;
+ }
+
+ var checkValuesPrefix = function () {
+ var result = true;
+ for (var i = 0; i<this.values.length; i++) {
+ if (this.values[i].indexOf(this.key)!=0) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+
+ var getItems = function (key, filterFunction) {
+ key = key.toLowerCase();
+ var newCache = [];
+
+ if (key.length < this.key.length) {
+ return newCache;
+ }
+
+ if (this.cache[key]) {
+ newCache = this.cache[key];
+ } else {
+ var useCustomFilterFunction = typeof filterFunction == "function";
+ var itemsCache = this.cache[this.key];
+ for (var i = 0; i<this.values.length; i++) {
+ var value = this.values[i];
+ if (useCustomFilterFunction && filterFunction(key, value)) {
+ newCache.push(itemsCache[i]);
+ } else {
+ var p = value.indexOf(key);
+ if (p == 0) {
+ newCache.push(itemsCache[i]);
+ }
+ }
+ }
+
+ if ((!this.lastKey || key.indexOf(this.lastKey)!=0) && newCache.length > 0) {
+ this.cache[key] = newCache;
+ if (newCache.length==1) {
+ this.lastKey = key;
+ }
+ }
+ }
+
+ return newCache;
+ };
+
+ var getItemValue = function (item) {
+ return this.originalValues[this.cache[this.key].index(item)];
+ };
+
+ var isCached = function (key) {
+ key = key.toLowerCase();
+ return this.cache[key] || this.useCache && key.indexOf(this.key)==0;
+ };
+
+ $.extend(rf.utils.Cache.prototype, (function () {
+ return {
+ getItems: getItems,
+ getItemValue: getItemValue,
+ isCached: isCached
+ };
+ })());
+
+
+})(jQuery, RichFaces);
+
+//-->
+
+(function ($, rf) {
+
rf.ui = rf.ui || {};
rf.ui.Select = function(id, options) {
$super.constructor.call(this, id);
this.id = id;
+ var mergedOptions = $.extend({}, defaultOptions, options);
+ mergedOptions['attachTo'] = id;
+
+ this.defaultLabel = mergedOptions.defaultLabel;
+ var inputLabel = this.getValue() ;
+ this.initialValue = (inputLabel != this.defaultLabel) ? inputLabel : "";
+
+ this.selValueInput = $(document.getElementById(id+"selValue"));
+ this.clientItems = mergedOptions.items;
- // TODO: move to defaultOptions ??
- options['attachTo'] = id;
- options['attachToBody'] = true;
-
- this.selValueInput = $(document.getElementById(options.selValueInput));
- this.items = options.items;
-
- if(options.showControl) {
+ if(mergedOptions.showControl) {
this.btn = $(document.getElementById(id+"Button"));
this.btn.bind("click", $.proxy(this.__clickHandler, this));
}
- this.popupList = new rf.ui.PopupList(options.list, this, options);
+ this.selectFirst = mergedOptions.selectFirst;
+ this.popupList = new rf.ui.SelectList((id+"List"), this, mergedOptions);
+
+ var items = this.popupList.__getItems();
+ var enableManualInput = mergedOptions.enableManualInput;
+ if (items.length>0 && enableManualInput) {
+ this.cache = new rf.utils.Cache("", items, getData, true);
+ }
+
+ this.changeDelay = mergedOptions.changeDelay;
};
rf.ui.InputBase.extend(rf.ui.Select);
var $super = rf.ui.Select.$super;
+
+ var defaultOptions = {
+ defaultLabel: "",
+ selectFirst: true,
+ showControl: true,
+ enableManualInput: false,
+ itemCss: "rf-sel-opt",
+ selectItemCss: "rf-sel-sel",
+ listCss: "rf-sel-lst-cord",
+ changeDelay: 8
+ };
+
+ var REGEXP_TRIM = /^[\n\s]*(.*)[\n\s]*$/;
+
+ var getData = function (nodeList) {
+ var data = [];
+ nodeList.each(function () {;
+ data.push($(this).text().replace(REGEXP_TRIM, "$1"));
+ });
+ return data;
+ }
$.extend(rf.ui.Select.prototype, ( function () {
@@ -50,12 +172,18 @@
e.preventDefault();
if(!this.popupList.isVisible()) {
this.popupList.show();
+ this.__setInputFocus();
} else {
this.popupList.hide();
}
- this.__setInputFocus();
},
-
+
+ __focusHandler: function(e) {
+ if(this.getValue() == this.defaultLabel) {
+ this.setValue("");
+ }
+ },
+
__keydownHandler: function(e) {
var code;
@@ -65,33 +193,70 @@
code = e.which;
}
- if(this.popupList.isVisible()) {
- switch(code) {
- case rf.KEYS.DOWN:
- e.preventDefault();
- this.popupList.__selectNext();
- this.__setInputFocus();
- break;
+ var visible = this.popupList.isVisible();
+ switch(code) {
+ case rf.KEYS.DOWN:
+ e.preventDefault();
+ if(!visible) {
+ this.popupList.show();
+ } else {
+ this.popupList.__selectNext() ;
+ }
+ break;
- case rf.KEYS.UP:
- e.preventDefault();
- this.popupList.__selectPrev();
- this.__setInputFocus();
- break;
+ case rf.KEYS.UP:
+ e.preventDefault();
+ if(visible) {
+ this.popupList.__selectPrev();
+ }
+ break;
- case rf.KEYS.RETURN:
- e.preventDefault();
- this.popupList.__selectCurrent();
- this.__setInputFocus();
- return false;
- break;
- }
+ case rf.KEYS.RETURN:
+ e.preventDefault();
+ if(visible) {
+ this.popupList.__selectCurrent();
+ }
+ return false;
+ break;
+
+ default:
+ var _this = this;
+ window.clearTimeout(this.changeTimerId);
+ this.changeTimerId = window.setTimeout(function(){_this.__onChangeValue(e);}, this.changeDelay);
+ break;
}
},
-
+
+ __onChangeValue: function(e) {
+ this.popupList.__selectByIndex();
+ var newValue = this.getValue();
+
+ if(this.cache && this.cache.isCached(newValue)) {
+
+ if(this.initialValue !=newValue) {
+ var newItems = this.cache.getItems(newValue);
+ var items = $(newItems);
+ this.popupList.__setItems(items);
+ $(document.getElementById(this.id+"Items")).empty().append(items);
+ }
+
+ if(!this.popupList.isVisible()) {
+ this.popupList.show();
+ }
+
+ if(this.selectFirst) {
+ this.popupList.__selectByIndex(0);
+ }
+ }
+ },
+
__blurHandler: function(e) {
var target = $(e.originalEvent.explicitOriginalTarget);
if(!this.popupList.isPopupList(target)) {
+ var inputLabel = this.getValue();
+ if(!inputLabel || inputLabel == "") {
+ this.setValue(this.defaultLabel);
+ }
this.popupList.hide();
return true;
}
@@ -109,8 +274,8 @@
},
getItemValue: function(key) {
- for(var i in this.items) {
- var item = this.items[i];
+ for(var i in this.clientItems) {
+ var item = this.clientItems[i];
if(item && item.id == key) {
return item.value;
}
@@ -118,8 +283,8 @@
},
getItemLabel: function(key) {
- for(var i in this.items) {
- var item = this.items[i];
+ for(var i in this.clientItems) {
+ var item = this.clientItems[i];
if(item && item.id == key) {
return item.label;
}
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js 2010-10-21 17:44:09 UTC (rev 19646)
@@ -4,15 +4,32 @@
rf.ui.SelectList = function(id, listener, options) {
$super.constructor.call(this, id, listener, options);
+ this.selectFirst = options.selectFirst;
};
rf.ui.PopupList.extend(rf.ui.SelectList);
var $super = rf.ui.SelectList.$super;
-
+
$.extend(rf.ui.SelectList.prototype,(function () {
return{
name : "selectList",
+
+ show: function() {
+ if(!this.isVisible()) {
+ $super.show.call(this);
+ if(this.selectFirst) {
+ this.__selectByIndex(0);
+ }
+ }
+ },
+
+ hide: function() {
+ if(this.isVisible()) {
+ $super.hide.call(this);
+ this.__selectByIndex(-1);
+ }
+ }
}
})());
Modified: trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-21 17:44:09 UTC (rev 19646)
@@ -78,7 +78,7 @@
</span>
</span>
</c:if>
- <span id="#{clientId}List" style="#{getListStyles(facesContext, component)}" class="rf-is-lst-cord">
+ <span id="#{clientId}List" style="#{component.attributes['openOnEdit'] ? '' : 'display: none'}" class="rf-is-lst-cord">
<cdk:call expression="renderListHandlers(facesContext, component);"/>
<span class="rf-is-lst-pos" style="width: #{component.attributes['listWidth']}">
<span class="rf-is-shdw">
Modified: trunk/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/select.template.xml 2010-10-21 16:57:09 UTC (rev 19645)
+++ trunk/ui/input/ui/src/main/templates/select.template.xml 2010-10-21 17:44:09 UTC (rev 19646)
@@ -29,7 +29,7 @@
type="text"
class="rf-sel-fnt rf-sel-inp"
autocomplete="off"
- readonly="readonly"/>
+ readonly="#{component.attributes['enableManualInput'] ? '' : 'readonly'}"/>
<c:if test="#{component.attributes['showButton']}">
<c:if test="#{component.attributes['disabled']}">
@@ -54,7 +54,7 @@
<div class="rf-sel-shdw-b"></div>
<div class="rf-sel-lst-dcrtn">
- <div class="rf-sel-lst-scrl">
+ <div class="rf-sel-lst-scrl" id="#{clientId}Items" >
<cdk:call expression="encodeItems(facesContext, component, clientSelectItems);"/>
</div>
</div>
13 years, 8 months
JBoss Rich Faces SVN: r19645 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richTab and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-21 12:57:09 -0400 (Thu, 21 Oct 2010)
New Revision: 19645
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java
Log:
https://jira.jboss.org/browse/RFPL-875
* added 33 tests for rich:tab
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java 2010-10-21 16:57:09 UTC (rev 19645)
@@ -0,0 +1,438 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richTab;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/richTab/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichTab extends AbstractMetamerTest {
+
+ private JQueryLocator panel = pjq("div[id$=tabPanel]");
+ private JQueryLocator[] itemContents = {pjq("div[id$=tab1] > div.rf-tb-cnt"), pjq("div[id$=tab2] > div.rf-tb-cnt"),
+ pjq("div[id$=tab3] > div.rf-tb-cnt"), pjq("div[id$=tab4] > div.rf-tb-cnt"), pjq("div[id$=tab5] > div.rf-tb-cnt")};
+ private JQueryLocator[] activeHeaders = {pjq("td[id$=tab1:header:active]"), pjq("td[id$=tab2:header:active]"),
+ pjq("td[id$=tab3:header:active]"), pjq("td[id$=tab4:header:active]"), pjq("td[id$=tab5:header:active]")};
+ private JQueryLocator[] inactiveHeaders = {pjq("td[id$=tab1:header:inactive]"), pjq("td[id$=tab2:header:inactive]"),
+ pjq("td[id$=tab3:header:inactive]"), pjq("td[id$=tab4:header:inactive]"), pjq("td[id$=tab5:header:inactive]")};
+ private JQueryLocator[] disabledHeaders = {pjq("td[id$=tab1:header:disabled]"), pjq("td[id$=tab2:header:disabled]"),
+ pjq("td[id$=tab3:header:disabled]"), pjq("td[id$=tab4:header:disabled]"), pjq("td[id$=tab5:header:disabled]")};
+ private JQueryLocator tab = pjq("div[id$=tab1]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richTab/simple.xhtml");
+ }
+
+ @Test
+ public void testInit() {
+ boolean displayed = selenium.isDisplayed(panel);
+ assertTrue(displayed, "Tab panel is not present on the page.");
+
+ displayed = selenium.isDisplayed(activeHeaders[0]);
+ assertTrue(displayed, "Header of tab1 should be active.");
+ displayed = selenium.isDisplayed(inactiveHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be inactive.");
+ displayed = selenium.isDisplayed(disabledHeaders[3]);
+ assertTrue(displayed, "Header of tab4 should be disabled.");
+
+ String text = selenium.getText(activeHeaders[0]);
+ assertEquals(text, "tab1 header");
+ text = selenium.getText(inactiveHeaders[1]);
+ assertEquals(text, "tab2 header");
+ text = selenium.getText(disabledHeaders[3]);
+ assertEquals(text, "tab4 header");
+ text = selenium.getText(itemContents[0]);
+ assertEquals(text, "content of tab 1");
+
+ }
+
+ @Test
+ public void testContentClass() {
+ ElementLocator<?> classInput = pjq("input[id$=contentClassInput]");
+ final String value = "metamer-ftest-class";
+
+ selenium.type(classInput, value);
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.belongsClass(itemContents[0], value), "contentClass does not work");
+ }
+
+ @Test
+ public void testDir() {
+ JQueryLocator ltrInput = pjq("input[type=radio][name$=dirInput][value=ltr]");
+ JQueryLocator rtlInput = pjq("input[type=radio][name$=dirInput][value=rtl]");
+ AttributeLocator<?> dirAttribute = tab.getAttribute(new Attribute("dir"));
+
+ // dir = null
+ assertFalse(selenium.isAttributePresent(dirAttribute), "Attribute dir should not be present.");
+
+ // dir = ltr
+ selenium.click(ltrInput);
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should be present.");
+ String value = selenium.getAttribute(dirAttribute);
+ assertEquals(value, "ltr", "Attribute dir");
+
+ // dir = rtl
+ selenium.click(rtlInput);
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should be present.");
+ value = selenium.getAttribute(dirAttribute);
+ assertEquals(value, "rtl", "Attribute dir");
+ }
+
+ @Test
+ public void testDisabled() {
+ // disable the first tab
+ selenium.click(pjq("input[type=radio][name$=disabledInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ boolean displayed = selenium.isDisplayed(activeHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be active.");
+ displayed = selenium.isDisplayed(inactiveHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be inactive.");
+ displayed = selenium.isDisplayed(disabledHeaders[0]);
+ assertTrue(displayed, "Header of tab1 should be disabled.");
+
+ String text = selenium.getText(disabledHeaders[0]);
+ assertEquals(text, "tab1 header");
+
+ // enable the first tab
+ selenium.click(pjq("input[type=radio][name$=disabledInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ displayed = selenium.isDisplayed(activeHeaders[0]);
+ assertTrue(displayed, "Header of tab1 should not be active.");
+ displayed = selenium.isDisplayed(inactiveHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be inactive.");
+ displayed = selenium.isDisplayed(disabledHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should be disabled.");
+
+ text = selenium.getText(activeHeaders[0]);
+ assertEquals(text, "tab1 header");
+ }
+
+ @Test
+ public void testHeader() {
+ selenium.type(pjq("input[type=text][id$=headerInput]"), "new header");
+ selenium.waitForPageToLoad();
+
+ assertEquals(selenium.getText(activeHeaders[0]), "new header", "Header of the first tab did not change.");
+
+ selenium.type(pjq("input[type=text][id$=headerInput]"), "ľščťťžžôúňď ацущьмщфзщйцу");
+ selenium.waitForPageToLoad();
+
+ assertEquals(selenium.getText(activeHeaders[0]), "ľščťťžžôúňď ацущьмщфзщйцу", "Header of the first tab did not change.");
+ }
+
+ @Test
+ public void testHeaderClass() {
+ selenium.type(pjq("input[id$=headerClassInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.belongsClass(activeHeaders[0], "metamer-ftest-class"), "tabHeaderClass does not work");
+ assertTrue(selenium.belongsClass(inactiveHeaders[0], "metamer-ftest-class"), "tabHeaderClass does not work");
+ assertTrue(selenium.belongsClass(disabledHeaders[0], "metamer-ftest-class"), "tabHeaderClass does not work");
+
+ assertFalse(selenium.belongsClass(activeHeaders[1], "metamer-ftest-class"), "tabHeaderClass does not work");
+ assertFalse(selenium.belongsClass(inactiveHeaders[1], "metamer-ftest-class"), "tabHeaderClass does not work");
+ assertFalse(selenium.belongsClass(disabledHeaders[1], "metamer-ftest-class"), "tabHeaderClass does not work");
+ }
+
+ @Test
+ public void testheaderClassActive() {
+ selenium.type(pjq("input[id$=headerClassActiveInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.belongsClass(activeHeaders[0], "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ assertFalse(selenium.belongsClass(inactiveHeaders[0], "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ assertFalse(selenium.belongsClass(disabledHeaders[0], "metamer-ftest-class"), "tabHeaderClassActive does not work");
+
+ assertFalse(selenium.belongsClass(activeHeaders[1], "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ assertFalse(selenium.belongsClass(inactiveHeaders[1], "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ assertFalse(selenium.belongsClass(disabledHeaders[1], "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ }
+
+ @Test
+ public void testTabHeaderClassDisabled() {
+ selenium.type(pjq("input[id$=headerClassDisabledInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.belongsClass(activeHeaders[0], "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ assertFalse(selenium.belongsClass(inactiveHeaders[0], "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ assertTrue(selenium.belongsClass(disabledHeaders[0], "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+
+ assertFalse(selenium.belongsClass(activeHeaders[1], "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ assertFalse(selenium.belongsClass(inactiveHeaders[1], "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ assertFalse(selenium.belongsClass(disabledHeaders[1], "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ }
+
+ @Test
+ public void testTabHeaderClassInactive() {
+ selenium.type(pjq("input[id$=headerClassInactiveInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.belongsClass(activeHeaders[0], "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ assertTrue(selenium.belongsClass(inactiveHeaders[0], "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ assertFalse(selenium.belongsClass(disabledHeaders[0], "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+
+ assertFalse(selenium.belongsClass(activeHeaders[1], "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ assertFalse(selenium.belongsClass(inactiveHeaders[1], "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ assertFalse(selenium.belongsClass(disabledHeaders[1], "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ }
+
+ @Test
+ public void testHeaderStyle() {
+ ElementLocator<?> styleInput = pjq("input[id$=headerStyleInput]");
+ final String value = "background-color: yellow; font-size: 1.5em;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad();
+
+ AttributeLocator<?> styleAttr = activeHeaders[0].getAttribute(Attribute.STYLE);
+ assertTrue(selenium.getAttribute(styleAttr).contains(value), "Attribute style should contain \"" + value + "\"");
+ }
+
+ @Test
+ public void testLang() {
+ JQueryLocator langInput = pjq("input[type=text][id$=langInput]");
+
+ // lang = null
+ AttributeLocator<?> langAttr = tab.getAttribute(new Attribute("lang"));
+ assertFalse(selenium.isAttributePresent(langAttr), "Attribute xml:lang should not be present.");
+
+ selenium.type(langInput, "sk");
+ selenium.waitForPageToLoad();
+
+ // lang = sk
+ langAttr = tab.getAttribute(new Attribute("lang"));
+ assertTrue(selenium.isAttributePresent(langAttr), "Attribute xml:lang should be present.");
+ assertEquals(selenium.getAttribute(langAttr), "sk", "Attribute xml:lang should be present.");
+ }
+
+ @Test
+ public void testOnclick() {
+ testFireEvent(Event.CLICK, tab);
+ }
+
+ @Test
+ public void testOndblclick() {
+ testFireEvent(Event.DBLCLICK, tab);
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9537")
+ public void testOnenter() {
+ JQueryLocator time = jq("span[id$=requestTime]");
+
+ selenium.type(pjq("input[type=text][id$=onenterInput]"), "metamerEvents += \"enter \"");
+ selenium.waitForPageToLoad();
+
+ selenium.getEval(new JavaScript("window.metamerEvents = \"\";"));
+ String time1Value = selenium.getText(time);
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Page was not updated").waitForChange(time1Value, retrieveText.locator(time));
+ guardXhr(selenium).click(inactiveHeaders[0]);
+ waitGui.failWith("Page was not updated").waitForChange(time1Value, retrieveText.locator(time));
+
+ String[] events = selenium.getEval(new JavaScript("window.metamerEvents")).split(" ");
+
+ assertEquals(events[0], "enter", "Attribute onenter doesn't work");
+ }
+
+ @Test
+ public void testOnheaderclick() {
+ testFireEvent(Event.CLICK, activeHeaders[0], "headerclick");
+ }
+
+ @Test
+ public void testOnheaderdblclick() {
+ testFireEvent(Event.DBLCLICK, activeHeaders[0], "headerdblclick");
+ }
+
+ @Test
+ public void testOnheadermousedown() {
+ testFireEvent(Event.MOUSEDOWN, activeHeaders[0], "headermousedown");
+ }
+
+ @Test
+ public void testOnheadermousemove() {
+ testFireEvent(Event.MOUSEMOVE, activeHeaders[0], "headermousemove");
+ }
+
+ @Test
+ public void testOnheadermouseup() {
+ testFireEvent(Event.MOUSEUP, activeHeaders[0], "headermouseup");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9537")
+ public void testOnleave() {
+ JQueryLocator time = jq("span[id$=requestTime]");
+
+ selenium.type(pjq("input[type=text][id$=onleaveInput]"), "metamerEvents += \"enter \"");
+ selenium.waitForPageToLoad();
+
+ selenium.getEval(new JavaScript("window.metamerEvents = \"\";"));
+ String time1Value = selenium.getText(time);
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Page was not updated").waitForChange(time1Value, retrieveText.locator(time));
+
+ String[] events = selenium.getEval(new JavaScript("window.metamerEvents")).split(" ");
+
+ assertEquals(events[0], "leave", "Attribute onleave doesn't work");
+ }
+
+ @Test
+ public void testOnmousedown() {
+ testFireEvent(Event.MOUSEDOWN, tab);
+ }
+
+ @Test
+ public void testOnmousemove() {
+ testFireEvent(Event.MOUSEMOVE, tab);
+ }
+
+ @Test
+ public void testOnmouseout() {
+ testFireEvent(Event.MOUSEOUT, tab);
+ }
+
+ @Test
+ public void testOnmouseover() {
+ testFireEvent(Event.MOUSEOVER, tab);
+ }
+
+ @Test
+ public void testOnmouseup() {
+ testFireEvent(Event.MOUSEUP, tab);
+ }
+
+ @Test
+ public void testRendered() {
+ JQueryLocator input = pjq("input[type=radio][name$=renderedInput][value=false]");
+ selenium.click(input);
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.isElementPresent(activeHeaders[0]), "Tab should not be rendered when rendered=false.");
+ assertFalse(selenium.isElementPresent(inactiveHeaders[0]), "Tab should not be rendered when rendered=false.");
+ assertFalse(selenium.isElementPresent(disabledHeaders[0]), "Tab should not be rendered when rendered=false.");
+ assertFalse(selenium.isElementPresent(tab), "Tab should not be rendered when rendered=false.");
+ }
+
+ @Test
+ public void testStyle() {
+ testStyle(tab);
+ }
+
+ @Test
+ public void testStyleClass() {
+ testStyleClass(tab, "styleClass");
+ }
+
+ @Test
+ public void testSwitchTypeNull() {
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Tab 2 is not displayed.").until(isDisplayed.locator(itemContents[1]));
+
+ guardXhr(selenium).click(inactiveHeaders[0]);
+ waitGui.failWith("Tab 1 is not displayed.").until(isDisplayed.locator(itemContents[0]));
+ }
+
+ @Test
+ public void testSwitchTypeAjax() {
+ JQueryLocator selectOption = pjq("input[name$=switchTypeInput][value=ajax]");
+ selenium.click(selectOption);
+ selenium.waitForPageToLoad();
+
+ testSwitchTypeNull();
+ }
+
+ @Test
+ public void testSwitchTypeClient() {
+ JQueryLocator selectOption = pjq("input[name$=switchTypeInput][value=client]");
+ selenium.click(selectOption);
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Tab 2 is not displayed.").until(isDisplayed.locator(itemContents[1]));
+
+ guardNoRequest(selenium).click(inactiveHeaders[0]);
+ waitGui.failWith("Tab 1 is not displayed.").until(isDisplayed.locator(itemContents[0]));
+ }
+
+ @Test
+ public void testSwitchTypeServer() {
+ JQueryLocator selectOption = pjq("input[name$=switchTypeInput][value=server]");
+ selenium.click(selectOption);
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Tab 2 is not displayed.").until(isDisplayed.locator(itemContents[1]));
+
+ guardHttp(selenium).click(inactiveHeaders[0]);
+ waitGui.failWith("Tab 1 is not displayed.").until(isDisplayed.locator(itemContents[0]));
+ }
+
+ @Test
+ public void testTitle() {
+ JQueryLocator input = pjq("input[type=text][id$=titleInput]");
+ AttributeLocator<?> attribute = tab.getAttribute(new Attribute("title"));
+
+ // title = null
+ assertFalse(selenium.isAttributePresent(attribute), "Attribute title should not be present.");
+
+ // title = "RichFaces Tab Panel"
+ selenium.type(input, "RichFaces Tab Panel");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertTrue(selenium.isAttributePresent(attribute), "Attribute title should be present.");
+ String value = selenium.getAttribute(attribute);
+ assertEquals(value, "RichFaces Tab Panel", "Attribute title");
+ }
+}
Property changes on: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java
___________________________________________________________________
Name: svn:keywords
+ Revision
13 years, 8 months
JBoss Rich Faces SVN: r19644 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-21 12:14:09 -0400 (Thu, 21 Oct 2010)
New Revision: 19644
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
Log:
* added new method for testing JavaScript events
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-10-21 16:10:55 UTC (rev 19643)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-10-21 16:14:09 UTC (rev 19644)
@@ -131,7 +131,22 @@
* locator of tested element
*/
protected void testFireEvent(Event event, ElementLocator<?> element) {
- ElementLocator<?> eventInput = pjq("input[id$=on" + event.getEventName() + "Input]");
+ testFireEvent(event, element, event.getEventName());
+ }
+
+ /**
+ * A helper method for testing javascripts events. It sets alert('testedevent') to the input field for given event
+ * and fires the event. Then it checks the message in the alert dialog.
+ *
+ * @param event
+ * JavaScript event to be tested
+ * @param element
+ * locator of tested element
+ * @param attributeName
+ * name of the attribute that should be set
+ */
+ protected void testFireEvent(Event event, ElementLocator<?> element, String attributeName) {
+ ElementLocator<?> eventInput = pjq("input[id$=on" + attributeName + "Input]");
String value = "metamerEvents += \"" + event.getEventName() + " \"";
selenium.type(eventInput, value);
13 years, 8 months
JBoss Rich Faces SVN: r19643 - modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-21 12:10:55 -0400 (Thu, 21 Oct 2010)
New Revision: 19643
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
* fixed typo in method invalidateSession
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-10-21 15:02:53 UTC (rev 19642)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-10-21 16:10:55 UTC (rev 19643)
@@ -319,7 +319,7 @@
if (session instanceof HttpSession) {
((HttpSession) session).invalidate();
- return FacesContext.getCurrentInstance().getViewRoot().getViewId() + "?faces-redirect=tru";
+ return FacesContext.getCurrentInstance().getViewRoot().getViewId() + "?faces-redirect=true";
}
throw new IllegalStateException();
13 years, 8 months
JBoss Rich Faces SVN: r19642 - modules/tests/metamer/trunk/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-10-21 11:02:53 -0400 (Thu, 21 Oct 2010)
New Revision: 19642
Modified:
modules/tests/metamer/trunk/ftest/pom.xml
Log:
jboss6x-snapshot-mojarra_2_1_0 filled with jsf configuration Mojarra-2.0 (althought it will be rewritten by JSF impl inside war)
Modified: modules/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- modules/tests/metamer/trunk/ftest/pom.xml 2010-10-21 14:46:47 UTC (rev 19641)
+++ modules/tests/metamer/trunk/ftest/pom.xml 2010-10-21 15:02:53 UTC (rev 19642)
@@ -360,6 +360,12 @@
</properties>
</profile>
<profile>
+ <id>tomcat6x-mojarra-snapshot</id>
+ <properties>
+ <deployable.classifier>mojarra-snapshot</deployable.classifier>
+ </properties>
+ </profile>
+ <profile>
<id>jboss6x-mojarra</id>
<properties>
<deployable.classifier>jee6</deployable.classifier>
@@ -389,6 +395,7 @@
<id>jboss6x-snapshot-mojarra_2_1_0</id>
<properties>
<deployable.classifier>mojarra_2_1_0</deployable.classifier>
+ <jsf.config>Mojarra-2.0</jsf.config>
</properties>
</profile>
<profile>
13 years, 8 months
JBoss Rich Faces SVN: r19641 - modules/tests/metamer/trunk/application.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-10-21 10:46:47 -0400 (Thu, 21 Oct 2010)
New Revision: 19641
Modified:
modules/tests/metamer/trunk/application/pom.xml
Log:
disabled uniqueVersion for application distributionManagement (need to add artifacts iteratively with another profiles)
Modified: modules/tests/metamer/trunk/application/pom.xml
===================================================================
--- modules/tests/metamer/trunk/application/pom.xml 2010-10-21 14:29:31 UTC (rev 19640)
+++ modules/tests/metamer/trunk/application/pom.xml 2010-10-21 14:46:47 UTC (rev 19641)
@@ -26,7 +26,21 @@
<artifactId>metamer</artifactId>
<packaging>war</packaging>
<name>Metamer: RichFaces Testing Application</name>
-
+
+ <distributionManagement>
+ <snapshotRepository>
+ <id>jboss-qa-snapshots</id>
+ <name>JBoss QA snapshot repository</name>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/repositories/snapshots</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ <repository>
+ <id>jboss-qa-releases</id>
+ <name>JBoss QA selease repository</name>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/repositories/releases</url>
+ </repository>
+ </distributionManagement>
+
<repositories>
<repository>
<id>maven-repository2.dev.java.net</id>
@@ -130,6 +144,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
+ <attachClasses>true</attachClasses>
+ <attachSources>true</attachSources>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
@@ -228,6 +244,16 @@
<timestampFormat>{0,date,MMM dd, yyyy H:mm:ss zzz}</timestampFormat>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
@@ -257,16 +283,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>package</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
@@ -280,10 +296,6 @@
<goals>
<goal>war</goal>
</goals>
- <configuration>
- <attachClasses>true</attachClasses>
- <attachSources>true</attachSources>
- </configuration>
</execution>
</executions>
</plugin>
13 years, 8 months
JBoss Rich Faces SVN: r19640 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-21 10:29:31 -0400 (Thu, 21 Oct 2010)
New Revision: 19640
Added:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabBean.properties
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
Log:
* added select options for rich:tab
* fixed comment in assert
Added: modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabBean.properties
===================================================================
--- modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabBean.properties (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabBean.properties 2010-10-21 14:29:31 UTC (rev 19640)
@@ -0,0 +1,8 @@
+attr.dir.ltr=ltr
+attr.dir.rtl=rtl
+attr.dir.null=
+
+attr.switchType.client=client
+attr.switchType.server=server
+attr.switchType.ajax=ajax
+attr.switchType.null=
\ No newline at end of file
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java 2010-10-21 13:35:31 UTC (rev 19639)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java 2010-10-21 14:29:31 UTC (rev 19640)
@@ -72,7 +72,7 @@
@Test
public void testInit() {
boolean displayed = selenium.isDisplayed(panel);
- assertTrue(displayed, "Accordion is not present on the page.");
+ assertTrue(displayed, "Tab panel is not present on the page.");
displayed = selenium.isDisplayed(activeHeaders[0]);
assertTrue(displayed, "Header of tab1 should be active.");
13 years, 8 months
JBoss Rich Faces SVN: r19638 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richTabPanel and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-21 09:31:39 -0400 (Thu, 21 Oct 2010)
New Revision: 19638
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
Log:
https://jira.jboss.org/browse/RFPL-837
* added 30 tests for rich:tabPanel
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java 2010-10-21 13:31:39 UTC (rev 19638)
@@ -0,0 +1,459 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richTabPanel;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertNotSame;
+
+import java.net.URL;
+
+import javax.faces.event.PhaseId;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/richTabPanel/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichTabPanel extends AbstractMetamerTest {
+
+ private JQueryLocator panel = pjq("div[id$=tabPanel]");
+ private JQueryLocator[] itemContents = {pjq("div[id$=tab1] > div.rf-tb-cnt"), pjq("div[id$=tab2] > div.rf-tb-cnt"),
+ pjq("div[id$=tab3] > div.rf-tb-cnt"), pjq("div[id$=tab4] > div.rf-tb-cnt"), pjq("div[id$=tab5] > div.rf-tb-cnt")};
+ private JQueryLocator[] activeHeaders = {pjq("td[id$=tab1:header:active]"), pjq("td[id$=tab2:header:active]"),
+ pjq("td[id$=tab3:header:active]"), pjq("td[id$=tab4:header:active]"), pjq("td[id$=tab5:header:active]")};
+ private JQueryLocator[] inactiveHeaders = {pjq("td[id$=tab1:header:inactive]"), pjq("td[id$=tab2:header:inactive]"),
+ pjq("td[id$=tab3:header:inactive]"), pjq("td[id$=tab4:header:inactive]"), pjq("td[id$=tab5:header:inactive]")};
+ private JQueryLocator[] disabledHeaders = {pjq("td[id$=tab1:header:disabled]"), pjq("td[id$=tab2:header:disabled]"),
+ pjq("td[id$=tab3:header:disabled]"), pjq("td[id$=tab4:header:disabled]"), pjq("td[id$=tab5:header:disabled]")};
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richTabPanel/simple.xhtml");
+ }
+
+ @Test
+ public void testInit() {
+ boolean displayed = selenium.isDisplayed(panel);
+ assertTrue(displayed, "Accordion is not present on the page.");
+
+ displayed = selenium.isDisplayed(activeHeaders[0]);
+ assertTrue(displayed, "Header of tab1 should be active.");
+ for (int i = 1; i < 5; i++) {
+ displayed = selenium.isDisplayed(activeHeaders[i]);
+ assertFalse(displayed, "Header of tab " + (i + 1) + " should not be active.");
+ }
+
+ displayed = selenium.isDisplayed(inactiveHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be inactive.");
+ displayed = selenium.isDisplayed(inactiveHeaders[1]);
+ assertTrue(displayed, "Header of tab2 should be inactive.");
+
+ displayed = selenium.isDisplayed(disabledHeaders[3]);
+ assertTrue(displayed, "Header of tab4 should be disabled.");
+ for (int i = 0; i < 3; i++) {
+ displayed = selenium.isDisplayed(disabledHeaders[i]);
+ assertFalse(displayed, "Header of tab " + (i + 1) + " should not be disabled.");
+ }
+
+ displayed = selenium.isDisplayed(itemContents[0]);
+ assertTrue(displayed, "Content of item1 should be visible.");
+
+ for (int i = 1; i < 5; i++) {
+ displayed = selenium.isDisplayed(itemContents[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s content should not be visible.");
+ }
+ }
+
+ @Test
+ public void testSwitchTypeNull() {
+ for (int i = 2; i >= 0; i--) {
+ final int index = i;
+ guardXhr(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+ @Test
+ public void testSwitchTypeAjax() {
+ JQueryLocator selectOption = pjq("input[name$=switchTypeInput][value=ajax]");
+ selenium.click(selectOption);
+ selenium.waitForPageToLoad();
+
+ testSwitchTypeNull();
+ }
+
+ @Test
+ public void testSwitchTypeClient() {
+ JQueryLocator selectOption = pjq("input[name$=switchTypeInput][value=client]");
+ selenium.click(selectOption);
+ selenium.waitForPageToLoad();
+
+ for (int i = 2; i >= 0; i--) {
+ final int index = i;
+ guardNoRequest(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+ @Test
+ public void testSwitchTypeServer() {
+ JQueryLocator selectOption = pjq("input[name$=switchTypeInput][value=server]");
+ selenium.click(selectOption);
+ selenium.waitForPageToLoad();
+
+ for (int i = 2; i >= 0; i--) {
+ final int index = i;
+ guardHttp(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+ @Test
+ public void testBypassUpdates() {
+ JQueryLocator input = pjq("input[type=radio][name$=bypassUpdatesInput][value=true]");
+ selenium.click(input);
+ selenium.waitForPageToLoad();
+
+ selenium.click(inactiveHeaders[2]);
+ waitGui.failWith("Tab 3 is not displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES, PhaseId.PROCESS_VALIDATIONS,
+ PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void testCycledSwitching() {
+ String panelId = selenium.getEval(new JavaScript("window.testedComponentId"));
+ String result = null;
+
+ // RichFaces.$('form:tabPanel').nextItem('tab4') will be null
+ result = selenium.getEval(new JavaScript("window.RichFaces.$('" + panelId + "').nextItem('tab4')"));
+ assertEquals(result, "null", "Result of function nextItem('tab4')");
+
+ // RichFaces.$('form:tabPanel').prevItem('tab1') will be null
+ result = selenium.getEval(new JavaScript("window.RichFaces.$('" + panelId + "').prevItem('tab1')"));
+ assertEquals(result, "null", "Result of function prevItem('tab1')");
+
+ JQueryLocator input = pjq("input[type=radio][name$=cycledSwitchingInput][value=true]");
+ selenium.click(input);
+ selenium.waitForPageToLoad();
+
+ // RichFaces.$('form:tabPanel').nextItem('tab5') will be item1
+ result = selenium.getEval(new JavaScript("window.RichFaces.$('" + panelId + "').nextItem('tab5')"));
+ assertEquals(result, "tab1", "Result of function nextItem('tab5')");
+
+ // RichFaces.$('form:tabPanel').prevItem('tab1') will be item5
+ result = selenium.getEval(new JavaScript("window.RichFaces.$('" + panelId + "').prevItem('tab1')"));
+ assertEquals(result, "tab5", "Result of function prevItem('tab1')");
+ }
+
+ @Test
+ public void testDir() {
+ JQueryLocator ltrInput = pjq("input[type=radio][name$=dirInput][value=LTR]");
+ JQueryLocator rtlInput = pjq("input[type=radio][name$=dirInput][value=RTL]");
+ AttributeLocator<?> dirAttribute = panel.getAttribute(new Attribute("dir"));
+
+ // dir = null
+ assertFalse(selenium.isAttributePresent(dirAttribute), "Attribute dir should not be present.");
+
+ // dir = ltr
+ selenium.click(ltrInput);
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should be present.");
+ String value = selenium.getAttribute(dirAttribute);
+ assertEquals(value, "LTR", "Attribute dir");
+
+ // dir = rtl
+ selenium.click(rtlInput);
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should be present.");
+ value = selenium.getAttribute(dirAttribute);
+ assertEquals(value, "RTL", "Attribute dir");
+ }
+
+ @Test
+ public void testImmediate() {
+ JQueryLocator input = pjq("input[type=radio][name$=immediateInput][value=true]");
+ selenium.click(input);
+ selenium.waitForPageToLoad();
+
+ selenium.click(inactiveHeaders[2]);
+ waitGui.failWith("Tab 3 is not displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES, PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void testLang() {
+ JQueryLocator langInput = pjq("input[type=text][id$=langInput]");
+
+ // lang = null
+ AttributeLocator<?> langAttr = panel.getAttribute(new Attribute("xml|lang"));
+ assertFalse(selenium.isAttributePresent(langAttr), "Attribute xml:lang should not be present.");
+
+ selenium.type(langInput, "sk");
+ selenium.waitForPageToLoad();
+
+ // lang = sk
+ langAttr = panel.getAttribute(new Attribute("lang"));
+ assertTrue(selenium.isAttributePresent(langAttr), "Attribute xml:lang should be present.");
+ assertEquals(selenium.getAttribute(langAttr), "sk", "Attribute xml:lang should be present.");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9535")
+ public void testLimitToList() {
+ JQueryLocator timeLoc = jq("span[id$=requestTime]");
+
+ selenium.type(pjq("input[type=text][id$=renderInput]"), "@this");
+ selenium.waitForPageToLoad();
+
+ selenium.click(pjq("input[type=radio][name$=limitToListInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ String time = selenium.getText(timeLoc);
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Tab 2 is not displayed.").until(isDisplayed.locator(itemContents[1]));
+
+ String newTime = selenium.getText(timeLoc);
+ assertNotSame(newTime, time, "Panel with ajaxRendered=true should not be rerendered.");
+ }
+
+ @Test
+ public void testOnbeforeitemchange() {
+ selenium.type(pjq("input[id$=onbeforeitemchangeInput]"), "metamerEvents += \"onbeforeitemchange \"");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Tab 2 is not displayed.").until(isDisplayed.locator(itemContents[1]));
+
+ waitGui.failWith("onbeforeitemchange attribute does not work correctly").until(new EventFiredCondition(new Event("beforeitemchange")));
+ }
+
+ @Test
+ public void testItemchangeEvents() {
+ JQueryLocator time = jq("span[id$=requestTime]");
+
+ selenium.type(pjq("input[type=text][id$=onbeforeitemchangeInput]"), "metamerEvents += \"beforeitemchange \"");
+ selenium.waitForPageToLoad();
+ selenium.type(pjq("input[type=text][id$=onitemchangeInput]"), "metamerEvents += \"itemchange \"");
+ selenium.waitForPageToLoad();
+
+ selenium.getEval(new JavaScript("window.metamerEvents = \"\";"));
+ String time1Value = selenium.getText(time);
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Page was not updated").waitForChange(time1Value, retrieveText.locator(time));
+
+ String[] events = selenium.getEval(new JavaScript("window.metamerEvents")).split(" ");
+
+ assertEquals(events[0], "beforeitemchange", "Attribute onbeforeitemchange doesn't work");
+ assertEquals(events[1], "itemchange", "Attribute onbeforeitemchange doesn't work");
+ }
+
+ @Test
+ public void testOnclick() {
+ testFireEvent(Event.CLICK, panel);
+ }
+
+ @Test
+ public void testOndblclick() {
+ testFireEvent(Event.DBLCLICK, panel);
+ }
+
+ @Test
+ public void testOnitemchange() {
+ selenium.type(pjq("input[id$=onitemchangeInput]"), "metamerEvents += \"onitemchange \"");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ guardXhr(selenium).click(inactiveHeaders[1]);
+ waitGui.failWith("Tab 2 is not displayed.").until(isDisplayed.locator(itemContents[1]));
+
+ waitGui.failWith("onitemchange attribute does not work correctly").until(new EventFiredCondition(new Event("itemchange")));
+ }
+
+ @Test
+ public void testOnmousedown() {
+ testFireEvent(Event.MOUSEDOWN, panel);
+ }
+
+ @Test
+ public void testOnmousemove() {
+ testFireEvent(Event.MOUSEMOVE, panel);
+ }
+
+ @Test
+ public void testOnmouseout() {
+ testFireEvent(Event.MOUSEOUT, panel);
+ }
+
+ @Test
+ public void testOnmouseover() {
+ testFireEvent(Event.MOUSEOVER, panel);
+ }
+
+ @Test
+ public void testOnmouseup() {
+ testFireEvent(Event.MOUSEUP, panel);
+ }
+
+ @Test
+ public void testRendered() {
+ JQueryLocator input = pjq("input[type=radio][name$=renderedInput][value=false]");
+ selenium.click(input);
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.isElementPresent(panel), "Tab panel should not be rendered when rendered=false.");
+ }
+
+ @Test
+ public void testStyle() {
+ testStyle(panel);
+ }
+
+ @Test
+ public void testStyleClass() {
+ testStyleClass(panel, "styleClass");
+ }
+
+ @Test
+ public void testTabContentClass() {
+ ElementLocator<?> classInput = pjq("input[id$=tabContentClassInput]");
+ final String value = "metamer-ftest-class";
+
+ selenium.type(classInput, value);
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : itemContents) {
+ assertTrue(selenium.belongsClass(loc, value), "tabContentClass does not work");
+ }
+ }
+
+ @Test
+ public void testTabHeaderClass() {
+ selenium.type(pjq("input[id$=tabHeaderClassInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClass does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClass does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClass does not work");
+ }
+ }
+
+ @Test
+ public void testTabHeaderClassActive() {
+ selenium.type(pjq("input[id$=tabHeaderClassActiveInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassActive does not work");
+ }
+ }
+
+ @Test
+ public void testTabHeaderClassDisabled() {
+ selenium.type(pjq("input[id$=tabHeaderClassDisabledInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassDisabled does not work");
+ }
+ }
+
+ @Test
+ public void testTabHeaderClassInactive() {
+ selenium.type(pjq("input[id$=tabHeaderClassInactiveInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "tabHeaderClassInactive does not work");
+ }
+ }
+
+ @Test
+ public void testTitle() {
+ JQueryLocator input = pjq("input[type=text][id$=titleInput]");
+ AttributeLocator<?> attribute = panel.getAttribute(new Attribute("title"));
+
+ // title = null
+ assertFalse(selenium.isAttributePresent(attribute), "Attribute title should not be present.");
+
+ // title = "RichFaces Tab Panel"
+ selenium.type(input, "RichFaces Tab Panel");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertTrue(selenium.isAttributePresent(attribute), "Attribute title should be present.");
+ String value = selenium.getAttribute(attribute);
+ assertEquals(value, "RichFaces Tab Panel", "Attribute title");
+ }
+}
Property changes on: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
___________________________________________________________________
Name: svn:keywords
+ Revision
13 years, 8 months
JBoss Rich Faces SVN: r19637 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org: richfaces/tests/metamer/ftest and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-21 09:29:47 -0400 (Thu, 21 Oct 2010)
New Revision: 19637
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
Log:
* refactoring
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java 2010-10-21 13:29:47 UTC (rev 19637)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.jboss.test.selenium.waiting;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+
+/**
+ * JavaScript condition that verifies that an event was fired, i.e. variable metamerEvents contains event name.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class EventFiredCondition implements JavaScriptCondition {
+
+ Event event;
+
+ public EventFiredCondition(final Event event) {
+ this.event = event;
+ }
+
+ public JavaScript getJavaScriptCondition() {
+ return new JavaScript("window.metamerEvents.indexOf(\"" + event.getEventName() + "\") != -1");
+ }
+}
Property changes on: modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-10-21 12:51:37 UTC (rev 19636)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-10-21 13:29:47 UTC (rev 19637)
@@ -19,7 +19,6 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*******************************************************************************/
-
package org.richfaces.tests.metamer.ftest;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
@@ -38,7 +37,7 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.richfaces.tests.metamer.TemplatesList;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Templates;
@@ -55,26 +54,9 @@
public abstract class AbstractMetamerTest extends AbstractTestCase {
/**
- * JavaScript condition that verifies that an event was fired, i.e. variable metamerEvents contains event name.
- */
- private class EventFiredCondition implements JavaScriptCondition {
-
- Event event;
-
- public EventFiredCondition(final Event event) {
- this.event = event;
- }
-
- public JavaScript getJavaScriptCondition() {
- return new JavaScript("window.metamerEvents.indexOf(\"" + event.getEventName() + "\") != -1");
- }
- }
-
- /**
* timeout in miliseconds
*/
public static final long TIMEOUT = 5000;
-
@Inject
@Templates({"plain", "richDataTable1,redDiv", "richDataTable2,redDiv", "a4jRepeat1", "a4jRepeat2", "hDataTable1",
"hDataTable2", "uiRepeat1", "uiRepeat2"})
@@ -158,7 +140,7 @@
selenium.fireEvent(element, event);
waitGui.failWith(event.getEventName() + " attribute did not change correctly").until(
- new EventFiredCondition(event));
+ new EventFiredCondition(event));
}
/**
@@ -176,7 +158,7 @@
selenium.waitForPageToLoad();
AttributeLocator<?> styleAttr = element.getAttribute(Attribute.STYLE);
- assertEquals(selenium.getAttribute(styleAttr), value, "Attribute style");
+ assertTrue(selenium.getAttribute(styleAttr).contains(value), "Attribute style should contain \"" + value + "\"");
}
/**
@@ -211,23 +193,23 @@
protected void showControls() {
selenium.getEval(new JavaScript("window.showControls()"));
}
-
+
/**
* Verifies that only given phases were executed. It uses the list of phases in the header of the page.
* @param phases phases that are expected to have been executed
*/
- protected void assertPhases(PhaseId ... phases) {
+ protected void assertPhases(PhaseId... phases) {
JQueryLocator phasesItems = jq("div#phasesPanel li");
int count = selenium.getCount(phasesItems);
-
+
String phase;
int phaseNumber = 1;
-
+
for (int i = 0; i < count; i++) {
phase = selenium.getText(jq("div#phasesPanel li:eq(" + i + ")"));
// check that it is really name of a phase
if (!phase.startsWith("* ")) {
- assertEquals(phase, phases[phaseNumber-1].toString(), "Phase nr. " + phaseNumber);
+ assertEquals(phase, phases[phaseNumber - 1].toString(), "Phase nr. " + phaseNumber);
phaseNumber++;
}
}
13 years, 8 months