JBoss Rich Faces SVN: r15893 - in root/ui-sandbox/trunk/components/tables/ui/src/main: java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-11-17 12:16:22 -0500 (Tue, 17 Nov 2009)
New Revision: 15893
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml
Log:
add client subTables expand/collapse functionality, add dataTable toggle control
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-11-17 17:16:22 UTC (rev 15893)
@@ -22,7 +22,27 @@
</superclass>
</tag>
</component>
+
<component>
+ <name>org.richfaces.ToggleControl</name>
+ <family>org.richfaces.ToggleControl</family>
+ <classname>org.richfaces.component.html.HtmlToggleControl</classname>
+ <superclass>org.richfaces.component.UIToggleControl</superclass>
+
+ <renderer generate="true" override="true">
+ <name>org.richfaces.renderkit.html.ToggleControlRenderer</name>
+ <template>org/richfaces/renderkit/html/toggle-control.template.xml</template>
+ </renderer>
+
+ <tag>
+ <name>toggleControl</name>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
+ </superclass>
+ </tag>
+ </component>
+
+ <component>
<name>org.richfaces.Colgroup</name>
<family>org.richfaces.Colgroup</family>
<classname>org.richfaces.component.html.HtmlColumnGroup</classname>
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -44,7 +44,7 @@
UIComponent child = childrenIterator.next();
//TODO nick - why non-rendered children are filtered?
//TODO nick - should be (child instanceof UIColumn || child instanceof Column)?
- if ((child instanceof UIColumn) && child.isRendered()) {
+ if ((child instanceof UIColumn) || (child instanceof Column) || child instanceof UISubTable) {
nextColumn = child;
} else if(checkAjaxComponent(child)) {
nextColumn = child;
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -39,7 +39,17 @@
public static final String COMPONENT_FAMILY = "org.richfaces.SubTable";
+ public static final String SWITCH_TYPE_SERVER = "server";
+ public static final String SWITCH_TYPE_CLIENT = "client";
+
+ public static final String SWITCH_TYPE_AJAX = "ajax";
+
+
+ enum PropertyKeys {
+ switchType, expanded
+ }
+
@Override
public Iterator<UIComponent> fixedChildren() {
return new SubtableFixedChildrenIterator(this);
@@ -69,6 +79,22 @@
super.walk(context, visitor, argument);
}
+ public String getSwichType(){
+ return (String)getStateHelper().eval(PropertyKeys.switchType, SWITCH_TYPE_SERVER);
+ }
+
+ public void setSwitchType(String switchType){
+ getStateHelper().put(PropertyKeys.switchType, switchType);
+ }
+
+ public void setExpanded(boolean expanded) {
+ getStateHelper().put(PropertyKeys.expanded, expanded);
+ }
+
+ public boolean getExpanded() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.expanded, Boolean.TRUE);
+ }
+
@Override
public boolean getRendersChildren() {
//TODO nick - why "false"?
@@ -92,11 +118,11 @@
}
public String getHeaderRowSkinClass() {
- return "rich-subtable-header-continue";
+ return "rich-subtable-header-row";
}
public String getHeaderFirstRowSkinClass() {
- return "rich-subtable-header";
+ return "rich-subtable-header-first-row";
}
public String getColumnHeaderCellSkinClass() {
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -0,0 +1,54 @@
+package org.richfaces.component;
+
+import javax.faces.component.UICommand;
+
+public abstract class UIToggleControl extends UICommand{
+
+ public static final String COMPONENT_TYPE = "org.richfaces.ToggleControl";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.ToggleControl";
+
+
+ enum PropertyKeys {
+ expandControl, collapseControl, forId, event
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getExpandControl(){
+ return (String) getStateHelper().eval(PropertyKeys.expandControl, null);
+ }
+
+ public void setExpandControl(String expandControl) {
+ getStateHelper().put(PropertyKeys.expandControl, expandControl);
+ }
+
+ public String getCollapseControl() {
+ return (String) getStateHelper().eval(PropertyKeys.collapseControl, null);
+ }
+
+ public void setCollapseControl(String collapseControl) {
+ getStateHelper().put(PropertyKeys.collapseControl, collapseControl);
+ }
+
+ public String getForId(){
+ return (String)getStateHelper().eval(PropertyKeys.forId, null);
+ }
+
+ public void setForId(String forId) {
+ getStateHelper().put(PropertyKeys.forId, forId);
+ }
+
+ public String getEvent() {
+ return (String)getStateHelper().eval(PropertyKeys.event, "onclick");
+
+ }
+
+ public void setEvent(String event) {
+ getStateHelper().put(PropertyKeys.event, event);
+ }
+
+}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -12,7 +12,7 @@
import org.richfaces.component.UIDataTableBase;
-@ResourceDependencies({
+@ResourceDependencies(value = {
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js")
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -16,8 +16,11 @@
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UISubTable;
-@ResourceDependencies({
- @ResourceDependency(name = "datatable.js"),
+@ResourceDependencies( {
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "datatable.js"),
@ResourceDependency(name = "table.css")
})
public class DataTableRenderer extends AbstractTableRenderer implements ElementEncodeListener{
@@ -66,13 +69,17 @@
holder.setRowClass(dataTable.getRowSkinClass());
holder.setFirstRowClass(dataTable.getFirstRowSkinClass());
holder.setHeaderRow(false);
+ holder.setCellElement(HTML.TD_ELEM);
encodeRows(context, dataTable, holder);
}
-
+ //TODO: refactor
public void encodeRow(FacesContext context, RowHolder rowHolder) throws IOException {
boolean rowStart = true;
+ boolean bodyStart = false;
+
+
int processCell = 0;
Row row = rowHolder.getRow();
@@ -80,6 +87,11 @@
ResponseWriter writer = context.getResponseWriter();
+ if(rowHolder.isDataTable()) {
+ encodeTableBodyStart(writer, context, (UIDataTable)row);
+ bodyStart = true;
+ }
+
Iterator<UIComponent> iterator = row.columns();
while(iterator.hasNext()) {
@@ -95,21 +107,39 @@
childRowHolder.setRowClass(rowHolder.getRowClass());
childRowHolder.setFirstRowClass(rowHolder.getFirstRowClass());
childRowHolder.setCellClass(rowHolder.getCellClass());
+ childRowHolder.setCellElement(HTML.TH_ELEM);
} else {
childRowHolder.setRowClass(childRow.getRowSkinClass());
childRowHolder.setFirstRowClass(childRow.getFirstRowSkinClass());
childRowHolder.setCellClass(childRow.getCellSkinClass());
+ childRowHolder.setCellElement(HTML.TD_ELEM);
}
childRowHolder.setHeaderRow(rowHolder.isHeaderRow());
if(child instanceof UISubTable) {
//ecode subTable header facet
- encodeHeader(writer, context, (UISubTable)child);
+ UISubTable subTable = (UISubTable)child;
+ if(bodyStart) {
+ encodeTableBodyEnd(writer, context, (UIDataTableBase)row);
+ bodyStart = false;
+ }
+// subTable.setRowKey(childRowHolder.getCurrentRow());
+ encodeTableBodyStart(writer, context, subTable);
+ encodeHeader(writer, context, subTable);
}
encodeRows(context, childRow, childRowHolder);
if(child instanceof UISubTable) {
- encodeFooter(writer, context, (UISubTable)child);
+ UISubTable subTable = (UISubTable)child;
+ encodeFooter(writer, context, subTable);
+
+ encodeTableBodyEnd(writer, context, subTable);
+
+ bodyStart = false;
+ if(iterator.hasNext()) {
+ encodeTableBodyStart(writer, context, (UIDataTableBase)row);
+ bodyStart=true;
+ }
}
} else if(child instanceof UIColumn) {
@@ -124,7 +154,6 @@
}
if(rowStart) {
-
if(processRow == 0) {
encodeFirstRowStart(writer, context, child, rowHolder);
} else {
@@ -135,7 +164,7 @@
}
encodeCellStart(writer, context, child, rowHolder);
- encodeCellEnd(writer, context, child);
+ encodeCellEnd(writer, context, child, rowHolder);
if(!iterator.hasNext()) {
if(processRow == 0) {
@@ -146,7 +175,12 @@
}
processCell++;
}
+ }
+
+ if(bodyStart && rowHolder.isDataTable()) {
+ encodeTableBodyEnd(writer, context, (UIDataTableBase) row);
}
+
}
@Override
@@ -167,9 +201,9 @@
}
UIDataTableBase dataTable = (UIDataTableBase)component;
- encodeTableBodyStart(writer, context, dataTable);
+// encodeTableBodyStart(writer, context, dataTable);
encodeRows(context, dataTable);
- encodeTableBodyEnd(writer, context, dataTable);
+// encodeTableBodyEnd(writer, context, dataTable);
}
@@ -193,12 +227,13 @@
return UIDataTable.class;
}
- public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- writer.endElement(HTML.TD_ELEM);
+ public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
+ writer.endElement(holder.getCellElement());
}
public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
- writer.startElement(HTML.TD_ELEM, component);
+ //anton - TODO: scope attribute
+ writer.startElement(holder.getCellElement(), component);
String cellClass = holder.getCellClass();
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, cellClass);
@@ -224,7 +259,8 @@
public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
writer.startElement(HTML.TR_ELEMENT, component);
- String styleClass = holder.getFirstRowClass() + " " + holder.getRowClass();
+ getUtils().encodeId(context, component);
+ String styleClass = holder.getRowClass() + " " + holder.getFirstRowClass();
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
@@ -234,20 +270,22 @@
public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
writer.startElement(HTML.TR_ELEMENT, component);
+ getUtils().encodeId(context, component);
String styleClass = holder.getRowClass();
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context, UIDataTableBase component) throws IOException {
- writer.endElement(HTML.TABLE_ELEMENT);
+ writer.endElement(HTML.TBOBY_ELEMENT);
}
public void encodeTableBodyStart(ResponseWriter writer, FacesContext context, UIDataTableBase component) throws IOException {
- writer.startElement(HTML.BODY_ELEMENT, component);
+ writer.startElement(HTML.TBOBY_ELEMENT, component);
+ getUtils().encodeId(context, component);
}
public void encodeTableEnd(ResponseWriter writer, FacesContext context, UIDataTableBase component) throws IOException {
- writer.endElement(HTML.BODY_ELEMENT);
+ writer.endElement(HTML.TABLE_ELEMENT);
}
public void encodeTableStart(ResponseWriter writer, FacesContext context, UIDataTableBase component) throws IOException {
@@ -382,12 +420,6 @@
}
- public void encodeSubTableHeader(ResponseWriter writer, FacesContext context, UIDataTable table){
- }
-
- public void encodeSubTableFooter(ResponseWriter writer, FacesContext context, UIDataTable table) {
- }
-
protected void encodeTableHeaderFacet(FacesContext context, int columns, ResponseWriter writer, UIComponent footer,
String skinFirstRowClass, String skinRowClass, String skinCellClass, String footerClass, String element)
throws IOException {
@@ -400,7 +432,7 @@
holder.setFirstRowClass(skinFirstRowClass);
holder.setRowClass(skinRowClass);
holder.setCellClass(skinCellClass);
- holder.resetCurrentRow();
+ //holder.resetCurrentRow();
holder.setHeaderRow(true);
encodeRows(context, row, holder);
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -16,7 +16,7 @@
public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException;
- public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
+ public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException;
// public void encodeHeaderCellStart(ResponseWriter writer, FacesContext context, UIComponent component, String styleClass) throws IOException;
//
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -1,6 +1,9 @@
package org.richfaces.renderkit;
import org.richfaces.component.Row;
+import org.richfaces.component.UIColumnGroup;
+import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UISubTable;
public class RowHolder {
@@ -16,6 +19,7 @@
private boolean headerRow;
+
public boolean isHeaderRow() {
return headerRow;
}
@@ -85,6 +89,19 @@
public void setRow(Row row) {
this.row = row;
}
+
+ public boolean isColGroup(){
+ return row instanceof UIColumnGroup;
+ }
+
+ public boolean isSubTable(){
+ return row instanceof UISubTable;
+ }
+
+ public boolean isDataTable(){
+ return row instanceof UIDataTable;
+ }
+
}
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-11-17 17:16:22 UTC (rev 15893)
@@ -0,0 +1,130 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UISubTable;
+import org.richfaces.component.UIToggleControl;
+
+@ResourceDependencies({
+ @ResourceDependency(name = "toggler.js")
+})
+public abstract class ToggleControlRendererBase extends RendererBase {
+
+ private static final String MANAGER_SCRIPT = "<script type=\"text/javascript\">ToggleManager.add(new Toggle(\"{0}\", \"{1}\", \"{2}\"));</script>";
+
+ private static final String CLIENT_TOGGLE_SCRIPT = "ToggleManager.clientToggle(''{0}'', ''{1}'');";
+
+ private static final String SERVER_TOGGLE_SCRIPT = "ToggleManager.serverToggle(''{0}'', ''{1}'');";
+
+ private static final String AJAX_TOGGLE_SCRIPT = "ToggleManager.ajaxToggle(''{0}'', ''{1}'');";
+
+ private static final String DISPLAY_NONE = "display: none;";
+
+ private static final String EXPAND_STATE = "expand";
+
+ private static final String COLLAPSE_STATE = "collapse";
+
+
+ public void encodeControl(FacesContext context, UIToggleControl toggleControl) throws IOException{
+
+ UISubTable subTable = findComponent(context, toggleControl);
+ if(subTable != null) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ String toggleId = toggleControl.getClientId();
+ String subTableId = subTable.getClientId();
+ boolean expanded = subTable.getExpanded();
+ String initialState = expanded ? EXPAND_STATE : COLLAPSE_STATE;
+
+ String registerScript = MessageFormat.format(MANAGER_SCRIPT, toggleId, subTableId, initialState);
+ writer.write(registerScript);
+
+ String switchType = subTable.getSwichType();
+ encodeControl(context, writer, toggleControl, switchType, expanded, false);
+ encodeControl(context, writer, toggleControl, switchType, !expanded, true);
+ }
+ }
+
+ protected void encodeControl(FacesContext context, ResponseWriter writer, UIToggleControl control, String switchType, boolean expanded, boolean visible) throws IOException {
+
+ String state = expanded ? EXPAND_STATE: COLLAPSE_STATE;
+ String image = expanded ? control.getExpandControl() : control.getCollapseControl();
+
+ String script = getScript(control, switchType, state);
+
+ String style = getStyle(context, control);
+ String styleClass = getStyleClass(context, control);
+
+ writer.startElement(HTML.SPAN_ELEM, control);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, styleClass, null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
+
+ writer.startElement(HTML.IMG_ELEMENT,control);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, control.getClientId() + ":" + state, null);
+
+ if(!visible) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
+ }
+
+ if(script != null && script.length() > 0) {
+ String eventName = control.getEvent();
+ writer.writeAttribute(eventName,script, null);
+ }
+
+ if(image != null && image.trim().length() > 0) {
+ writer.writeAttribute(HTML.SRC_ATTRIBUTE, image, null);
+ }
+
+ writer.endElement(HTML.IMG_ELEMENT);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ public String getStyleClass(FacesContext context, UIToggleControl control) {
+ return null;
+ }
+
+ public String getStyle(FacesContext context, UIToggleControl control) {
+ return null;
+ }
+
+ protected UISubTable findComponent(FacesContext context, UIToggleControl toggleControl) {
+ String forId = toggleControl.getForId();
+
+ if(forId != null && forId.length() > 0) {
+ UIComponent subTable = getUtils().findComponentFor(context, toggleControl, forId);
+ if(subTable instanceof UISubTable) {
+ return (UISubTable)subTable;
+ }
+ }
+ return null;
+ }
+
+ public String getScript(UIToggleControl toggleControl, String switchType ,String state) {
+
+ StringBuffer pattern = new StringBuffer();
+
+ if(switchType.equals(UISubTable.SWITCH_TYPE_CLIENT)) {
+ pattern.append(CLIENT_TOGGLE_SCRIPT);
+ } else if (switchType.equals(UISubTable.SWITCH_TYPE_AJAX)){
+ pattern.append(AJAX_TOGGLE_SCRIPT);
+ } else {
+ pattern.append(SERVER_TOGGLE_SCRIPT);
+ }
+
+ String toggleId = toggleControl.getClientId();
+
+ String script = ( pattern.length() > 0) ? MessageFormat.format(pattern.toString(), toggleId, state) : null;
+
+ return script;
+ }
+
+}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-11-17 17:16:22 UTC (rev 15893)
@@ -47,6 +47,10 @@
<component-type>org.richfaces.SubTable</component-type>
<component-class>org.richfaces.component.html.HtmlSubTable</component-class>
</component>
+ <component>
+ <component-type>org.richfaces.ToggleControl</component-type>
+ <component-class>org.richfaces.component.html.HtmlToggleControl</component-class>
+ </component>
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
@@ -60,5 +64,10 @@
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.ExtendedDataTableRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>org.richfaces.ToggleControl</component-family>
+ <renderer-type>org.richfaces.ToggleControlRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.ToggleControlRenderer</renderer-class>
+ </renderer>
</render-kit>
</faces-config>
\ No newline at end of file
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2009-11-17 17:16:22 UTC (rev 15893)
@@ -1 +1 @@
-var i = 1;
\ No newline at end of file
+var c = 1;
\ No newline at end of file
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/table.css 2009-11-17 17:16:22 UTC (rev 15893)
@@ -25,7 +25,7 @@
.rich-subtable-row{
}
-.rich-subtable-firstrow{
+.rich-subtable-first-row{
}
.rich-subtable-cell{
@@ -112,7 +112,7 @@
text-align:left;
}
-.rich-subtable-header {
+.rich-subtable-header-row {
background-color: grey;
}
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2009-11-17 17:16:22 UTC (rev 15893)
@@ -0,0 +1,85 @@
+function Toggle(id, forId, initialState){
+ this.id = id;
+ this.forId = forId;
+ this.state = initialState;
+}
+
+Toggle.prototype.convertId = function(id) {
+ return id.replace(/:/g, "\\:");
+}
+
+Toggle.prototype.clientToggle= function(toState){
+ var elements = this.getElement(this.forId);
+
+ if(this.state != toState) {
+
+ var hideId = this.id + ":" + toState;
+ var showId = this.id + ":" + this.state;
+
+ var hideControl = this.getElement(hideId);
+ var showControl = this.getElement(showId);
+
+ this.command("show", showControl);
+ this.command("hide", hideControl);
+
+ if(toState == 'collapse') {
+ this.command("hide", elements);
+ } else {
+ this.command("show", elements);
+ }
+ this.state = toState;
+ }
+}
+
+Toggle.prototype.serverToggle = function(toState) {
+}
+
+Toggle.prototype.ajaxToggle = function(toState) {
+}
+
+Toggle.prototype.command = function(name, elements){
+ if(name) {
+ for(var i in elements) {
+ var element = elements[i];
+ if(element && typeof element[name] == 'function') {
+ element[name]();
+ }
+ }
+ }
+}
+
+Toggle.prototype.getElement = function() {
+ var elements = new Array();
+ for(var i = 0; i < arguments.length; i++) {
+ elements[i] = $("#" + this.convertId(arguments[i]));
+ }
+ return elements;
+}
+
+ToggleManager = new Object();
+
+ToggleManager.process = {};
+
+ToggleManager.add = function (toggler){
+ if(toggler) {
+ this.process[toggler.id] = toggler;
+ }
+}
+
+ToggleManager.clientToggle = function(id, state) {
+ if(id) {
+ this.process[id].clientToggle(state);
+ }
+}
+
+ToggleManager.serverToggle = function(id, state) {
+ if(id) {
+ this.process[id].serverToggle(state);
+ }
+}
+
+ToggleManager.ajaxToggle = function(id, state) {
+ if(id) {
+ this.process[id].ajaxToggle(state);
+ }
+}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-11-17 15:28:13 UTC (rev 15892)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-11-17 17:16:22 UTC (rev 15893)
@@ -37,4 +37,11 @@
<!-- renderer-type>org.richfaces.renderkit.SubTableRenderer</renderer-type-->
</component>
</tag>
+ <tag>
+ <tag-name>toggleControl</tag-name>
+ <component>
+ <component-type>org.richfaces.ToggleControl</component-type>
+ <renderer-type>org.richfaces.ToggleControlRenderer</renderer-type>
+ </component>
+ </tag>
</facelet-taglib>
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml 2009-11-17 17:16:22 UTC (rev 15893)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://richfaces.org/xhtml-el" xmlns:cdk="http://richfaces.org/cdk"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ class="org.richfaces.renderkit.html.ToggleControlRenderer"
+ superclass="org.richfaces.renderkit.ToggleControlRendererBase"
+ componentclass="org.richfaces.component.UIToggleControl">
+
+ <span id="#{clientId}" class="#{component.attributes['styleClass']}">
+ <cdk:call expression="encodeControl(context, component);" />
+ </span>
+
+</cdk:root>
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r15892 - in root/ui-sandbox/trunk/components/tables/ui/src/main: resources/META-INF/resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-11-17 10:28:13 -0500 (Tue, 17 Nov 2009)
New Revision: 15892
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-7865
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2009-11-17 15:28:12 UTC (rev 15891)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2009-11-17 15:28:13 UTC (rev 15892)
@@ -35,6 +35,9 @@
import org.richfaces.component.util.HtmlUtil;
@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "extendedDataTable.js"),
@ResourceDependency(name = "extendedDataTable.css")
})
@@ -207,7 +210,7 @@
if (column.isRendered()) {
writer.startElement(HTML.TD_ELEM, table);
writer.startElement(HTML.DIV_ELEM, table);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-std2-cell rich-std2-cell-width-" + columnIndex++, null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-cell rich-extable-cell-width-" + columnIndex++, null);
renderChildren(context, column);
writer.endElement(HTML.DIV_ELEM);
writer.endElement(HTML.TD_ELEM);
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css 2009-11-17 15:28:12 UTC (rev 15891)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css 2009-11-17 15:28:13 UTC (rev 15892)
@@ -22,6 +22,7 @@
.rich-extable{
background-color: #FFFFFF;
border: 1px solid #C4C0C9;
+ height: 100%;
}
.rich-extable-header {
@@ -47,10 +48,10 @@
overflow: hidden;
}
-/*.rich-extable-footer-part{
+.rich-extable-footer-part{
overflow-x: auto;
overflow-y: visible;
-}*/
+}
.rich-extable-cell, .rich-extable-header-cell, .rich-extable-footer-cell{
height: 20px;
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2009-11-17 15:28:12 UTC (rev 15891)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2009-11-17 15:28:13 UTC (rev 15892)
@@ -20,6 +20,20 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
(function(richfaces, jQuery) {
+ richfaces.getCSSRule = function (className) {
+ var rule = null;
+ var sheets = document.styleSheets;
+ for (var j = 0; !rule && j < sheets.length; j++) {
+ var rules = sheets[j].cssRules ? sheets[j].cssRules: sheets[j].rules;
+ for (var i = 0; !rule && i < rules.length; i++) {
+ if (rules[i].selectorText.toLowerCase() == (className.toLowerCase())) {
+ rule = rules[i];
+ }
+ }
+ }
+ return rule;
+ };
+
richfaces.ExtendedDataTable = function(id) {
this.id = id;
this.element = document.getElementById(id);
@@ -29,26 +43,32 @@
this.dataTableElement = this.contentElement.lastChild;//TODO this.dataTableElement = Richfaces.lastDescendant(this.contentElement);
this.frozenHeaderPartElement = document.getElementById(id + ":fhpe");
- this.normalPartStyle = Utils.getRule(".rich-std2-part-width").style;
- this.resizerHolderStyle = Utils.getRule(".rich-std2-resizer-holder").style;
+ this.normalPartStyle = richfaces.getCSSRule(".rich-extable-part-width").style;
this.idSuffixs = [":nhpe", ":nbpe", ":nfpe"];
this.scrollElement = document.getElementById(this.id + this.idSuffixs[2]);
this.rows = document.getElementById(id + ":nbte").rows.length;
- this.scrollListener = this.updateScrollPosition.bindAsEventListener(this);
- Event.observe(this.scrollElement, 'scroll', this.scrollListener);
- this.updateDataListener = this.updateData.bindAsEventListener(this);
- Event.observe(this.bodyElement, 'scroll', this.updateDataListener);
- this.resizeListener = this.updateLayout.bindAsEventListener(this);
- Event.observe(window, 'resize', this.resizeListener);
-
+ this.updateLayout = function() {
+ var offsetWidth = this.frozenHeaderPartElement ? this.frozenHeaderPartElement.offsetWidth : 0;
+ this.normalPartStyle.width = this.element.clientWidth - offsetWidth + "px";
+ var height = this.element.clientHeight;
+ var element = this.element.firstChild;
+ while (element) {
+ if(element.nodeName.toUpperCase() == "DIV" && element != this.bodyElement) {
+ height -= element.offsetHeight;
+ }
+ element = element.nextSibling;
+ }
+ this.bodyElement.style.height = height + "px";
+ };
+
var table = this;
jQuery(document).ready(function(){
- table.contentElement.style.height = (table.rowCount * table.dataTableElement.offsetHeight / table.rows) + "px";
- table.updateLayout();
- });
+ table.contentElement.style.height = (table.rowCount * table.dataTableElement.offsetHeight / table.rows) + "px";
+ table.updateLayout();
+ });
};
}(window.RichFaces, jQuery));
15 years, 1 month
JBoss Rich Faces SVN: r15891 - root/examples-sandbox/trunk/components/tables/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-11-17 10:28:12 -0500 (Tue, 17 Nov 2009)
New Revision: 15891
Modified:
root/examples-sandbox/trunk/components/tables/src/main/webapp/extendedtable.xhtml
Log:
RF-7852 ExtendedDataTable sample
Modified: root/examples-sandbox/trunk/components/tables/src/main/webapp/extendedtable.xhtml
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/webapp/extendedtable.xhtml 2009-11-17 02:04:34 UTC (rev 15890)
+++ root/examples-sandbox/trunk/components/tables/src/main/webapp/extendedtable.xhtml 2009-11-17 15:28:12 UTC (rev 15891)
@@ -36,7 +36,7 @@
<h:body>
<h:form id="form1">
- <rich:extendedDataTable var="record" value="#{dataBean.employeeList}" rows="20">
+ <rich:extendedDataTable var="record" value="#{dataBean.employeeList}" style="width: 500px;">
<rich:column id="column_name">
<f:facet name="header">
<h:outputText id="columnHeader1" value="Column Header Facet"/>
@@ -47,11 +47,11 @@
</f:facet>
</rich:column>
- <rich:column id="column_title">
+ <rich:column id="column_title" width="200px">
<h:outputText value="#{record.title}" />
</rich:column>
- <rich:column id="column_email">
+ <rich:column id="column_email" width="300px">
<h:outputText value="#{record.EMail}" />
</rich:column>
</rich:extendedDataTable>
15 years, 1 month
JBoss Rich Faces SVN: r15890 - in branches/community/3.3.X/ui/fileUpload/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-16 21:04:34 -0500 (Mon, 16 Nov 2009)
New Revision: 15890
Modified:
branches/community/3.3.X/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
branches/community/3.3.X/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
Log:
https://jira.jboss.org/jira/browse/RF-8053 - hook method added.
Modified: branches/community/3.3.X/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- branches/community/3.3.X/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-11-17 00:49:17 UTC (rev 15889)
+++ branches/community/3.3.X/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-11-17 02:04:34 UTC (rev 15890)
@@ -435,6 +435,17 @@
return function.toScript();
}
+
+ /**
+ * https://jira.jboss.org/jira/browse/RF-8053 - public hook to change action URL in portlet environment.
+ * @param context
+ * @return
+ */
+ public String getActionUrl(FacesContext context){
+ AjaxContext ajaxContext = org.ajax4jsf.context.AjaxContext.getCurrentInstance(context);
+ String ajaxActionUrl = ajaxContext.getAjaxActionURL(context);
+ return ajaxActionUrl;
+ }
/**
* Return accepted types map
Modified: branches/community/3.3.X/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
--- branches/community/3.3.X/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2009-11-17 00:49:17 UTC (rev 15889)
+++ branches/community/3.3.X/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2009-11-17 02:04:34 UTC (rev 15890)
@@ -48,12 +48,6 @@
variables.setVariable("addLabel",labels.get("add"));
variables.setVariable("uploadLabel",labels.get("upload"));
variables.setVariable("clearAllLabel",labels.get("clear_all"));
-
- org.ajax4jsf.context.AjaxContext ajaxContext = org.ajax4jsf.context.AjaxContext.getCurrentInstance(context);
- String ajaxActionUrl = ajaxContext.getAjaxActionURL(context);
-
- variables.setVariable("actionUrl", ajaxActionUrl);
-
variables.setVariable("listWidth", getFileListWidth(component));
variables.setVariable("listHeight", getFileListHeight(component));
@@ -191,7 +185,7 @@
<c:scriptOption name="labels" value="#{labels}" />
</c:scriptObject>
<script type="text/javascript">
- new FileUpload('#{clientId}','#{actionUrl}', #{this:getActionScript(context, component)}, '#{this:getProgressBarId(context, component)}',
+ new FileUpload('#{clientId}','#{this:getActionUrl(context)}', #{this:getActionScript(context, component)}, '#{this:getProgressBarId(context, component)}',
'#{this:getSessionId(context, component)}'
<c:if test="#{not empty options}">
, <f:writeAsScript value="#{options}" />
15 years, 1 month
JBoss Rich Faces SVN: r15889 - in branches/community/3.3.X/cdk/generator/src/main: resources/META-INF/templates/templatecompiler and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-16 19:49:17 -0500 (Mon, 16 Nov 2009)
New Revision: 15889
Modified:
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ForEachTemplateElement.java
branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/FORElement_2.vm
branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/FORElement_2.vm
Log:
https://jira.jboss.org/jira/browse/RF-8051
Modified: branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ForEachTemplateElement.java
===================================================================
--- branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ForEachTemplateElement.java 2009-11-16 23:56:33 UTC (rev 15888)
+++ branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ForEachTemplateElement.java 2009-11-17 00:49:17 UTC (rev 15889)
@@ -100,14 +100,14 @@
* @return
*/
protected String getTemplate2Name() {
- return A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/FORElement_1.vm";
+ return A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/FORElement_2.vm";
}
/**
* @return
*/
protected String getTemplate1Name() {
- return A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/FORElement_2.vm";
+ return A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/FORElement_1.vm";
}
/**
Modified: branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/FORElement_2.vm
===================================================================
--- branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/FORElement_2.vm 2009-11-16 23:56:33 UTC (rev 15888)
+++ branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/FORElement_2.vm 2009-11-17 00:49:17 UTC (rev 15889)
@@ -1,5 +1,5 @@
for (
variables.setVariable("$item", $from);
- Integer.getInteger(variables.getVariable("$item").toString()).intValue() < Integer.getInteger($to).toString()).intValue();
+ Integer.getInteger(variables.getVariable("$item").toString()).intValue() < Integer.getInteger($to).toString().intValue();
variables.addValueToVariable("$item", new Integer(1) )
) {
\ No newline at end of file
Modified: branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/FORElement_2.vm
===================================================================
--- branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/FORElement_2.vm 2009-11-16 23:56:33 UTC (rev 15888)
+++ branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/FORElement_2.vm 2009-11-17 00:49:17 UTC (rev 15889)
@@ -1,5 +1,5 @@
for (
variables.setVariable("$item", $from);
- Integer.getInteger(variables.getVariable("$item").toString()).intValue() < Integer.getInteger($to).toString()).intValue();
+ Integer.getInteger(variables.getVariable("$item").toString()).intValue() < Integer.getInteger($to).toString().intValue();
variables.addValueToVariable("$item", new Integer(1) )
) {
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r15888 - in branches/community/3.3.X: samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-16 18:56:33 -0500 (Mon, 16 Nov 2009)
New Revision: 15888
Added:
branches/community/3.3.X/ui/beanValidator/src/test/java/org/richfaces/validator/FacesValidatorTest.java
Modified:
branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/include/pagesList.xhtml
branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/GraphValidatorBean.java
branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/MinMaxBean.java
branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml
branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/pages/graphValidation.xhtml
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java
Log:
https://jira.jboss.org/jira/browse/RF-7636, fix graphValidator example.
Modified: branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/include/pagesList.xhtml
===================================================================
--- branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/include/pagesList.xhtml 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/include/pagesList.xhtml 2009-11-16 23:56:33 UTC (rev 15888)
@@ -7,7 +7,6 @@
xmlns:c="http://java.sun.com/jstl/core"
>
<ui:composition>
- <h:form>
<h:dataTable value="#{pages.xhtmlPages}" var="page">
<h:column>
<h:outputLink value="#{page.url}">
@@ -15,6 +14,5 @@
</h:outputLink>
</h:column>
</h:dataTable>
- </h:form>
</ui:composition>
</html>
\ No newline at end of file
Modified: branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/GraphValidatorBean.java
===================================================================
--- branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/GraphValidatorBean.java 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/GraphValidatorBean.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -11,17 +11,18 @@
* @author asmirnov
*
*/
-public class GraphValidatorBean {
+public class GraphValidatorBean implements Cloneable {
@Min(0)
@Max(10)
private int first ;
- @Min(0)
- @Max(10)
+ @Min(value=5,message="Value {0} should be more than {value}")
+ @Max(15)
private int second ;
+
@Min(0)
- @Max(10)
+ @Max(20)
private int third ;
private String actionResult;
Modified: branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/MinMaxBean.java
===================================================================
--- branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/MinMaxBean.java 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/jsr303src/org/richfaces/example/MinMaxBean.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -16,7 +16,7 @@
private String text;
- @Min(2)
+ @Min(value=2,message="Value {0} should be more than {value}")
@Max(10)
private int intValue;
Modified: branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml
===================================================================
--- branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml 2009-11-16 23:56:33 UTC (rev 15888)
@@ -1,59 +1,47 @@
-<f:view xmlns:ui="http://java.sun.com/jsf/facelets"
+<rich:page xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
- xmlns:s="http://jboss.com/products/seam/taglib"
- xmlns:a="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich"
- locale="#{locale.current}">
-<a:page pageTitle="#{title}" format="xhtml">
- <a:loadStyle src="/css/grids.css" />
- <a:loadStyle src="resource://css/panel.xcss" />
- <a:loadStyle src="resource://css/table.xcss" />
- <div id="doc3" class="yui-t3 dr-pnl">
- <div id="hd" class="dr-pnl-h">
- <h1>RichFaces Validation components examples</h1>
- <ui:insert name="header" /></div>
- <div id="bd">
- <div class="yui-b">
- <!-- YOUR NAVIGATION GOES HERE -->
- <ui:include src="/include/pagesList.xhtml" />
- <h:form>
- <h:selectOneMenu value="#{locale.language}">
- <f:selectItem itemLabel="English" itemValue="en"/>
- <f:selectItem itemLabel="Deutsch" itemValue="de"/>
- <f:selectItem itemLabel="Francais" itemValue="fr"/>
-</h:selectOneMenu>
-<h:commandButton action="#{locale.select}" value="ChangeLanguage"/>
-</h:form>
- </div>
- <div class="yui-main">
- <div class="yui-b">
- <!-- YOUR DATA GOES HERE -->
- <rich:tabPanel binding="#{tabNavigation.tabPanel}" switchType="ajax">
- <rich:tab name="usage" label="Usage">
- <ui:insert name="description" />
- <ui:insert name="content" />
- </rich:tab>
- <rich:tab name="page" label="Page Source">
- <rich:insert content="#{contentBean.content}" highlight="xhtml"/>
- </rich:tab>
- <rich:tab name="java" label="Java Source" rendered="#{!empty javaBean}">
- <rich:insert src="/src/#{javaBean}" highlight="java"/>
- </rich:tab>
- </rich:tabPanel>
- </div>
- </div>
- </div>
- <div id="ft" class="dr-table-footer">
- <div class="yui-ge dr-table-footercell">
- <div class="yui-u first">
- Built with RichFaces #{a4j.version}
- </div>
- <div class="yui-u" style="text-align:right">
- © 2007 Exadel, Inc.
- </div>
- </div>
- </div>
- </div>
-</a:page>
-</f:view>
\ No newline at end of file
+ xmlns:a="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich" pageTitle="#{title}"
+ theme="simple" markupType="html">
+ <f:facet name="header">
+ <h1>RichFaces Validation components examples</h1>
+ </f:facet>
+ <f:facet name="subheader">
+ <ui:insert name="header" />
+ </f:facet>
+ <f:facet name="sidebar">
+ <h:panelGroup>
+ <!-- YOUR NAVIGATION GOES HERE -->
+ <ui:include src="/include/pagesList.xhtml" />
+ <h:form>
+ <h:selectOneMenu value="#{locale.language}">
+ <f:selectItem itemLabel="English" itemValue="en" />
+ <f:selectItem itemLabel="Deutsch" itemValue="de" />
+ <f:selectItem itemLabel="Francais" itemValue="fr" />
+ </h:selectOneMenu>
+ <h:commandButton action="#{locale.select}"
+ value="ChangeLanguage" />
+ </h:form>
+ </h:panelGroup>
+ </f:facet>
+ <!-- YOUR DATA GOES HERE -->
+ <rich:tabPanel binding="#{tabNavigation.tabPanel}" switchType="ajax">
+ <rich:tab name="usage" label="Usage">
+ <div><ui:insert name="description" /></div>
+ <div><ui:insert name="content" /></div>
+ </rich:tab>
+ <rich:tab name="page" label="Page Source">
+ <rich:insert content="#{contentBean.content}"
+ highlight="xhtml" />
+ </rich:tab>
+ <rich:tab name="java" label="Java Source"
+ rendered="#{!empty javaBean}">
+ <rich:insert src="/src/#{javaBean}" highlight="java" />
+ </rich:tab>
+ </rich:tabPanel>
+ <f:facet name="footer">
+ <h:panelGroup>Built with RichFaces #{a4j.version}
+ (C) 2009 Exadel, Inc.</h:panelGroup>
+ </f:facet>
+</rich:page>
Modified: branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/pages/graphValidation.xhtml
===================================================================
--- branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/pages/graphValidation.xhtml 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/samples/beanValidatorSample/src/main/webapp/pages/graphValidation.xhtml 2009-11-16 23:56:33 UTC (rev 15888)
@@ -13,13 +13,15 @@
<!-- Page header -->
<ui:define name="header">
<h1><rich:graphValidator> usage</h1>
- <p>In that sampe <rich:graphValidator> component appends JSR-299 or Hibernate validators to all enclosed input components
+ </ui:define>
+ <!-- content -->
+ <ui:define name="description">
+ <p>In that sampe <rich:graphValidator> component appends JSR-303 or Hibernate validators to all enclosed input components
that check restrictions for field values, and, in addition, validates whole bean.</p>
<p>JSF bean fields are annotated with @Min/@Max restrictions and getter for the 'total' attribute is also annotated by the @Max</p>
<p>As a result, even valid field values would make whole bean an invalid. For example, values '2','7','15' are valid for fields values but their sum exceed maximum total value '20'</p>
<p>Validator assignes new values to a cloned bean instance hence model is not updated with invalid values.</p>
- </ui:define>
- <!-- content -->
+ </ui:define>
<ui:define name="content">
<h:form id="form">
<rich:graphValidator value="#{graphValidatorBean}" id="validator" profiles="javax.validation.groups.Default">
@@ -35,12 +37,12 @@
<h:outputText value="#{graphValidatorBean.first}"/>
<h:outputLabel for="value1" value="Second value,integer from 5 to 15:" />
- <h:inputText id="value1" value="#{graphValidatorBean.second}" label="First" />
+ <h:inputText id="value1" value="#{graphValidatorBean.second}" label="Second" />
<rich:message for="value1"/>
<h:outputText value="#{graphValidatorBean.second}"/>
<h:outputLabel for="value2" value="Third value,integer from 0 to 20:" />
- <h:inputText id="value2" value="#{graphValidatorBean.third}" label="First" />
+ <h:inputText id="value2" value="#{graphValidatorBean.third}" label="Third" />
<rich:message for="value2"/>
<h:outputText value="#{graphValidatorBean.third}"/>
Modified: branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java
===================================================================
--- branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIGraphValidator.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -149,8 +150,12 @@
Class<?> type = valueExpression.getType(new ELContextWrapper(initialELContext, capturingELResolver));
if(null != type) {
validatorState = new GraphValidatorState();
- Method method = value.getClass().getDeclaredMethod("clone");
- method.setAccessible(true);
+ Method method = getCloneMethod(value.getClass());
+ if(!Modifier.isPublic(method.getModifiers())){
+ // Method Object#clone() is protected by default. Make it public
+ // unless developer did it.
+ method.setAccessible(true);
+ }
validatorState.cloned = method.invoke(value);
validatorState.base = capturingELResolver.getBase();
validatorState.property = capturingELResolver.getProperty();
@@ -174,6 +179,18 @@
}
}
+ private Method getCloneMethod(Class<?> clazz) throws NoSuchMethodException {
+ try {
+ return clazz.getDeclaredMethod("clone");
+ } catch( NoSuchMethodException e){
+ if(null != clazz.getSuperclass()){
+ return getCloneMethod(clazz.getSuperclass());
+ } else {
+ throw e;
+ }
+ }
+ }
+
protected String getStateId(FacesContext context) {
String stateId = STATE_ATTRIBUTE_PREFIX+getClientId(context);
return stateId;
Modified: branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
--- branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -25,6 +25,7 @@
private static final Class[] DEFAULT_PROFILE = new Class[] {};
private final ValidatorFactory validatorFactory;
+ private ValidatorContext validatorContext;
BeanValidator() {
// Enforce class to load
@@ -33,6 +34,10 @@
// https://jira.jboss.org/jira/browse/RF-7226
validatorFactory = Validation
.buildDefaultValidatorFactory();
+ validatorContext = validatorFactory.usingContext();
+ MessageInterpolator jsfMessageInterpolator = new JsfMessageInterpolator(
+ validatorFactory.getMessageInterpolator());
+ validatorContext.messageInterpolator(jsfMessageInterpolator);
}
/*
@@ -107,30 +112,25 @@
}
protected Validator getValidator(FacesContext facesContext) {
- ValidatorContext validatorContext = validatorFactory.usingContext();
- MessageInterpolator jsfMessageInterpolator = new JsfMessageInterpolator(
- calculateLocale(facesContext), validatorFactory.getMessageInterpolator());
- validatorContext.messageInterpolator(jsfMessageInterpolator);
Validator beanValidator = validatorContext.getValidator();
return beanValidator;
}
private static class JsfMessageInterpolator implements MessageInterpolator {
- private Locale locale;
private MessageInterpolator delegate;
- public JsfMessageInterpolator(Locale locale,
+ public JsfMessageInterpolator(
MessageInterpolator delegate) {
- this.locale = locale;
this.delegate = delegate;
}
public String interpolate(String messageTemplate, Context context) {
+ Locale locale = ObjectValidator.calculateLocale(FacesContext.getCurrentInstance());
if (null != locale) {
return delegate.interpolate(messageTemplate, context,
- this.locale);
+ locale);
} else {
return delegate.interpolate(messageTemplate, context);
}
@@ -138,9 +138,10 @@
public String interpolate(String messageTemplate, Context context,
Locale locale) {
- if (null != locale) {
+ Locale faceslocale = ObjectValidator.calculateLocale(FacesContext.getCurrentInstance());
+ if (null != faceslocale) {
return delegate.interpolate(messageTemplate, context,
- this.locale);
+ faceslocale);
} else {
return delegate.interpolate(messageTemplate, context, locale);
}
Modified: branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
===================================================================
--- branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -21,6 +21,8 @@
package org.richfaces.validator;
import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Locale;
import java.util.Set;
import javax.el.ELException;
@@ -99,16 +101,20 @@
ValueExpression valueExpression = component
.getValueExpression("value");
if (null != valueExpression) {
- // TODO - check EL Exceptions ?
- String[] messages = HibernateValidator.getInstance(context)
+ String[] messages = ObjectValidator.getInstance(context)
.validate(context, valueExpression, convertedValue, getProfiles());
if (null != messages) {
input.setValid(false);
+ Object label = getLabel(context, component);
+ Locale locale = context.getViewRoot().getLocale();
// send all validation messages.
for (String msg : messages) {
- // TODO - create Summary message ?
- String summaryString = getSummary()!=null?getSummary():msg;
-
+ // https://jira.jboss.org/jira/browse/RF-7636 -
+ // format values.
+ msg = formatMessage(msg, locale, label,convertedValue); // create Summary message ?
+ String summaryString = getSummary() != null ? getSummary()
+ : msg;
+ summaryString = formatMessage(summaryString, locale, label,convertedValue);
context.addMessage(component.getClientId(context), new FacesMessage(
FacesMessage.SEVERITY_ERROR, summaryString , msg));
}
@@ -120,9 +126,27 @@
}
}
+ static String formatMessage(String msg, Locale locale, Object... messageParams) {
+ if (msg.contains("{")) {
+ MessageFormat messageFormat = new MessageFormat(
+ msg, locale);
+ msg = messageFormat.format(messageParams);
+
+ }
+ return msg;
+ }
+
+ static Object getLabel(FacesContext context, UIComponent component) {
+ Object label = component.getAttributes().get("label");
+ if(null == label || 0 == label.toString().length()){
+ label = component.getClientId(context);
+ }
+ return label;
+ }
+
public String[] validateGraph(FacesContext context, UIComponent component,
Object value, Object profiles) throws ValidatorException {
- ObjectValidator beanValidator = HibernateValidator.getInstance(context);
+ ObjectValidator beanValidator = ObjectValidator.getInstance(context);
String[] messages = beanValidator.validateGraph(context, value,AjaxRendererUtils.asSet(profiles));
return messages;
}
Modified: branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java
===================================================================
--- branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java 2009-11-16 18:20:11 UTC (rev 15887)
+++ branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -45,7 +45,7 @@
*
* @return
*/
- protected static ObjectValidator createInstance() {
+ static ObjectValidator createInstance() {
// TODO - get instance class name from a "META-INF/service"
// If the Seam framework is active, org.jboss.seam.core.Validators
// component should be used.
@@ -119,7 +119,6 @@
context, elContext.getELResolver(),profiles);
ELContextWrapper wrappedElContext = new ELContextWrapper(elContext,
validationResolver);
- // TODO - handle ELExceptions ?
try {
target.setValue(wrappedElContext, value);
} catch (ELException e) {
@@ -133,16 +132,6 @@
return validationMessages;
}
- protected Locale calculateLocale(FacesContext context) {
- if (null == context.getViewRoot()) {
- throw new FacesException(VIEW_ROOT_IS_NOT_INITIALIZED);
- } else if (null == context.getViewRoot().getLocale()) {
- throw new FacesException(LOCALE_IS_NOT_SET);
- }
- Locale locale = context.getViewRoot().getLocale();
- return locale;
- }
-
/**
* Validate bean property for a new value.
* @param facesContext TODO
@@ -160,8 +149,17 @@
protected abstract String[] validate(FacesContext facesContext, Object base,
String property, Object value, Set<String> profiles);
- protected ResourceBundle getResourceBundle(FacesContext facesContext, String name) {
- // TODO - cache resource bundles.
+ static Locale calculateLocale(FacesContext context) {
+ if (null == context.getViewRoot()) {
+ throw new FacesException(VIEW_ROOT_IS_NOT_INITIALIZED);
+ } else if (null == context.getViewRoot().getLocale()) {
+ throw new FacesException(LOCALE_IS_NOT_SET);
+ }
+ Locale locale = context.getViewRoot().getLocale();
+ return locale;
+ }
+
+ static ResourceBundle getResourceBundle(FacesContext facesContext, String name) {
ResourceBundle bundle = null;
if (null != facesContext) {
Application application = facesContext.getApplication();
@@ -177,7 +175,7 @@
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
if (null == classLoader) {
- classLoader = this.getClass().getClassLoader();
+ classLoader = ObjectValidator.class.getClassLoader();
}
try {
bundle = ResourceBundle.getBundle(name, calculateLocale(facesContext),
Added: branches/community/3.3.X/ui/beanValidator/src/test/java/org/richfaces/validator/FacesValidatorTest.java
===================================================================
--- branches/community/3.3.X/ui/beanValidator/src/test/java/org/richfaces/validator/FacesValidatorTest.java (rev 0)
+++ branches/community/3.3.X/ui/beanValidator/src/test/java/org/richfaces/validator/FacesValidatorTest.java 2009-11-16 23:56:33 UTC (rev 15888)
@@ -0,0 +1,48 @@
+package org.richfaces.validator;
+
+import java.util.Locale;
+
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlInputText;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+public class FacesValidatorTest extends AbstractAjax4JsfTestCase {
+
+ public FacesValidatorTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testValidate() {
+
+ }
+
+ public void testFormatMessage() {
+ String message = FacesBeanValidator.formatMessage("foo {0}", Locale.ENGLISH, "bar");
+ assertEquals("foo bar", message);
+ }
+
+ public void testGetLabel() {
+ UIInput input = new UIInput();
+ input.setId("foo");
+ facesContext.getViewRoot().getChildren().add(input);
+ assertEquals("foo", FacesBeanValidator.getLabel(facesContext, input));
+ }
+
+ public void testGetLabel1() {
+ HtmlInputText input = new HtmlInputText();
+ input.setId("foo");
+ input.setLabel("bar");
+ facesContext.getViewRoot().getChildren().add(input);
+ assertEquals("bar", FacesBeanValidator.getLabel(facesContext, input));
+ }
+
+}
Property changes on: branches/community/3.3.X/ui/beanValidator/src/test/java/org/richfaces/validator/FacesValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
JBoss Rich Faces SVN: r15887 - in branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test: java/org/jboss/richfaces/integrationTest/listShuttle and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2009-11-16 13:20:11 -0500 (Mon, 16 Nov 2009)
New Revision: 15887
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties
Log:
* test cases refactored to provide more stable results
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java 2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java 2009-11-16 18:20:11 UTC (rev 15887)
@@ -268,9 +268,10 @@
int count = getJQueryCount(LOC_UPLOADED_LIST_TR);
assertEquals(count, 0, MSG_RIGHT_PANEL_NUMBER_OF_ITEMS);
-
+
+ waitFor(3000);
selenium.attachFile(LOC_ADD_BUTTON, "file://" + FILE_CYAN);
-
+
waitForElement(LOC_UPLOADED_LIST_TR);
count = getJQueryCount(LOC_UPLOADED_LIST_TR);
assertEquals(count, 1, MSG_RIGHT_PANEL_NUMBER_OF_ITEMS);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java 2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java 2009-11-16 18:20:11 UTC (rev 15887)
@@ -26,6 +26,8 @@
import static org.testng.Assert.assertTrue;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -62,21 +64,30 @@
*/
@Test
public void testCopyButton() {
- int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
- int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+ final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+ final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
selenium.click(LOC_LEFT_TABLE_LINE_1);
assertTrue(isDisplayed(LOC_COPY_BUTTON), "Copy button should be enabled.");
selenium.click(LOC_COPY_BUTTON);
- int tmpInt = getJQueryCount(LOC_LEFT_TABLE_LINES);
- assertEquals(tmpInt, leftCount - 1, "In left table, one item should be removed.");
+
+ Wait.failWith("In left table, one item should be removed.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_LEFT_TABLE_LINES) == leftCount - 1;
+ }
+ });
- tmpInt = getJQueryCount(LOC_RIGHT_TABLE_LINES);
- assertEquals(tmpInt, rightCount + 1, "In right table, one item should be added.");
+ Wait.failWith("In right table, one item should be added.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_RIGHT_TABLE_LINES) == rightCount + 1;
+ }
+ });
- // check that it was added also to the toolbar
- tmpInt = getJQueryCount(LOC_TOOLBAR_ITEMS);
- assertEquals(tmpInt, rightCount + 1, "Number of items in toolbar.");
+ Wait.failWith("Number of items in toolbar.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_TOOLBAR_ITEMS) == rightCount + 1;
+ }
+ });
}
// @Test
@@ -96,22 +107,30 @@
*/
@Test
public void testCopyAllButton() {
- int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
- int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+ final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+ final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
assertTrue(isDisplayed(LOC_COPY_ALL_BUTTON), "Copy all button should be enabled.");
selenium.click(LOC_COPY_ALL_BUTTON);
- int count = getJQueryCount(LOC_LEFT_TABLE_LINES);
- assertEquals(count, 0, "All items from left table should be removed.");
-
- count = getJQueryCount(LOC_RIGHT_TABLE_LINES);
- assertEquals(count, rightCount + leftCount, "All items should be added to the right table.");
-
- // check that they were added also to the toolbar
- count = getJQueryCount(LOC_TOOLBAR_ITEMS);
- assertEquals(count, rightCount + leftCount, "Number of items in toolbar.");
+ Wait.failWith("All items from left table should be removed.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_LEFT_TABLE_LINES) == 0;
+ }
+ });
+
+ Wait.failWith("All items should be added to the right table.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_RIGHT_TABLE_LINES) == rightCount + leftCount;
+ }
+ });
+
+ Wait.failWith("Number of items in toolbar.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_TOOLBAR_ITEMS) == rightCount + leftCount;
+ }
+ });
}
/**
@@ -122,23 +141,31 @@
*/
@Test
public void testRemoveButton() {
- int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
- int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+ final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+ final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
selenium.click(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
assertTrue(isDisplayed(LOC_REMOVE_BUTTON), "Remove button should be enabled.");
selenium.click(LOC_REMOVE_BUTTON);
- int tmpInt = getJQueryCount(LOC_LEFT_TABLE_LINES);
- assertEquals(tmpInt, leftCount + 1, "One item should be added to the left table.");
-
- tmpInt = getJQueryCount(LOC_RIGHT_TABLE_LINES);
- assertEquals(tmpInt, rightCount - 1, "One item should be removed from the right table.");
-
- // check that one item was removed from toolbar
- tmpInt = getJQueryCount(LOC_TOOLBAR_ITEMS);
- assertEquals(tmpInt, rightCount - 1, "Number of items in toolbar.");
+ Wait.failWith("One item should be added to the left table.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_LEFT_TABLE_LINES) == leftCount + 1;
+ }
+ });
+
+ Wait.failWith("One item should be removed from the right table.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_RIGHT_TABLE_LINES) == rightCount - 1;
+ }
+ });
+
+ Wait.failWith("Number of items in toolbar.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_TOOLBAR_ITEMS) == rightCount - 1;
+ }
+ });
}
// @Test
@@ -158,22 +185,30 @@
*/
@Test
public void testRemoveAllButton() {
- int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
- int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
+ final int leftCount = getJQueryCount(LOC_LEFT_TABLE_LINES);
+ final int rightCount = getJQueryCount(LOC_RIGHT_TABLE_LINES);
assertTrue(isDisplayed(LOC_REMOVE_ALL_BUTTON), "Remove all button should be enabled.");
selenium.click(LOC_REMOVE_ALL_BUTTON);
- int tmpInt = getJQueryCount(LOC_LEFT_TABLE_LINES);
- assertEquals(tmpInt, leftCount + rightCount, "All items should be added to the left table.");
-
- tmpInt = getJQueryCount(LOC_RIGHT_TABLE_LINES);
- assertEquals(tmpInt, 0, "All items from right table should be removed.");
-
- // check that everything was removed from toolbar
- tmpInt = getJQueryCount(LOC_TOOLBAR_ITEMS);
- assertEquals(tmpInt, 0, "Number of items in toolbar.");
+ Wait.failWith("All items should be added to the left table.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_LEFT_TABLE_LINES) == leftCount + rightCount;
+ }
+ });
+
+ Wait.failWith("All items from right table should be removed.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_RIGHT_TABLE_LINES) == 0;
+ }
+ });
+
+ Wait.failWith("Number of items in toolbar.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(LOC_TOOLBAR_ITEMS) == 0;
+ }
+ });
}
/**
@@ -183,10 +218,10 @@
*/
@Test
public void testUpButton() {
- String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+ final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+ final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+ final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+ final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
assertEquals(secondItemFromToolbar, secondItemFromTable,
"The second item in right table and toolbar should be the same.");
@@ -195,17 +230,29 @@
selenium.click(LOC_UP_BUTTON);
// check items in the table
- String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- assertEquals(tmpString, secondItemFromTable, "The first and the second item in the table should be swapped.");
- tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- assertEquals(tmpString, firstItemFromTable, "The first and the second item in the table should be swapped.");
-
- // check items in the toolbar
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- assertEquals(tmpString, secondItemFromToolbar,
- "The first and the second item in the toolbar should be swapped.");
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
- assertEquals(tmpString, firstItemFromToolbar, "The first and the second item in the toolbar should be swapped.");
+ Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(secondItemFromTable);
+ }
+ });
+
+ Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(firstItemFromTable);
+ }
+ });
+
+ Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(secondItemFromToolbar);
+ }
+ });
+
+ Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(firstItemFromToolbar);
+ }
+ });
}
// @Test
@@ -225,12 +272,12 @@
*/
@Test
public void testFirstButton() {
- String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
- String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
- String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
+ final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+ final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+ final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+ final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+ final String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
+ final String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
assertEquals(secondItemFromToolbar, secondItemFromTable,
"The second item in right table and toolbar should be the same.");
@@ -238,21 +285,41 @@
selenium.click(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
selenium.click(LOC_FIRST_BUTTON);
+
// check items in the table
- String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- assertEquals(tmpString, firstItemFromTable, "The first item from the table should be now the second.");
- tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
- assertEquals(tmpString, secondItemFromTable, "The second item from the table should be now the third.");
- tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- assertEquals(tmpString, thirdItemFromTable, "The third item from the table should be now the first.");
-
+ Wait.failWith("The first item from the table should be now the second.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(firstItemFromTable);
+ }
+ });
+ Wait.failWith("The second item from the table should be now the third.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2)).equals(secondItemFromTable);
+ }
+ });
+ Wait.failWith("The third item from the table should be now the first.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(thirdItemFromTable);
+ }
+ });
+
+
// check items in the toolbar
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
- assertEquals(tmpString, firstItemFromToolbar, "The first item from the toolbar should be now the second.");
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
- assertEquals(tmpString, secondItemFromToolbar, "The second item from the toolbar should be now the third.");
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- assertEquals(tmpString, thirdItemFromToolbar, "The third item from the toolbar should be now the first.");
+ Wait.failWith("The first item from the toolbar should be now the second.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(firstItemFromToolbar);
+ }
+ });
+ Wait.failWith("The second item from the toolbar should be now the third.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2)).equals(secondItemFromToolbar);
+ }
+ });
+ Wait.failWith("The third item from the toolbar should be now the first.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(thirdItemFromToolbar);
+ }
+ });
}
/**
@@ -262,10 +329,10 @@
*/
@Test
public void testDownButton() {
- String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+ final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+ final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+ final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+ final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
assertEquals(secondItemFromToolbar, secondItemFromTable,
"The second item in right table and toolbar should be the same.");
@@ -273,18 +340,31 @@
selenium.click(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
selenium.click(LOC_DOWN_BUTTON);
+
// check items in the table
- String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- assertEquals(tmpString, secondItemFromTable, "The first and the second item in the table should be swapped.");
- tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- assertEquals(tmpString, firstItemFromTable, "The first and the second item in the table should be swapped.");
-
+ Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(secondItemFromTable);
+ }
+ });
+ Wait.failWith("The first and the second item in the table should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(firstItemFromTable);
+ }
+ });
+
+
// check items in the toolbar
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- assertEquals(tmpString, secondItemFromToolbar,
- "The first and the second item in the toolbar should be swapped.");
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
- assertEquals(tmpString, firstItemFromToolbar, "The first and the second item in the toolbar should be swapped.");
+ Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(secondItemFromToolbar);
+ }
+ });
+ Wait.failWith("The first and the second item in the toolbar should be swapped.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(firstItemFromToolbar);
+ }
+ });
}
// @Test
@@ -304,12 +384,12 @@
*/
@Test
public void testLastButton() {
- String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
- String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
- String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
+ final String firstItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
+ final String firstItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
+ final String secondItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
+ final String secondItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
+ final String thirdItemFromTable = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
+ final String thirdItemFromToolbar = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
assertEquals(secondItemFromToolbar, secondItemFromTable,
"The second item in right table and toolbar should be the same.");
@@ -318,20 +398,38 @@
selenium.click(LOC_LAST_BUTTON);
// check items in the table
- String tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2));
- assertEquals(tmpString, firstItemFromTable, "The first item from the table should be now last.");
- tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0));
- assertEquals(tmpString, secondItemFromTable, "The second item from the table should be now the first.");
- tmpString = selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1));
- assertEquals(tmpString, thirdItemFromTable, "The third item from the table should be now the second.");
-
+ Wait.failWith("The first item from the table should be now last.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 2)).equals(firstItemFromTable);
+ }
+ });
+ Wait.failWith("The second item from the table should be now the first.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 0)).equals(secondItemFromTable);
+ }
+ });
+ Wait.failWith("The third item from the table should be now the second.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_RIGHT_TABLE_LINE_PREFORMATTED, 1)).equals(thirdItemFromTable);
+ }
+ });
+
// check items in the toolbar
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2));
- assertEquals(tmpString, firstItemFromToolbar, "The first item from the toolbar should be now last.");
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0));
- assertEquals(tmpString, secondItemFromToolbar, "The second item from the toolbar should be now the first.");
- tmpString = selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1));
- assertEquals(tmpString, thirdItemFromToolbar, "The third item from the toolbar should be now the second.");
+ Wait.failWith("The first item from the toolbar should be now last.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 2)).equals(firstItemFromToolbar);
+ }
+ });
+ Wait.failWith("The second item from the toolbar should be now the first.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 0)).equals(secondItemFromToolbar);
+ }
+ });
+ Wait.failWith("The third item from the toolbar should be now the second.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_TOOLBAR_ITEM_PREFORMATTED, 1)).equals(thirdItemFromToolbar);
+ }
+ });
}
/**
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java 2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java 2009-11-16 18:20:11 UTC (rev 15887)
@@ -27,6 +27,8 @@
import static org.testng.Assert.assertTrue;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -39,16 +41,16 @@
public class TreeTestCase extends AbstractSeleniumRichfacesTestCase {
private final String LOC_HEADER_PREFORMATTED = getLoc("HEADER_PREFORMATTED");
- private final String LOC_NODE_1_LINK_PREFORMATTED = getLoc("NODE_1_LINK_PREFORMATTED");
- private final String LOC_NODE_1_1_LABEL_PREFORMATTED = getLoc("NODE_1_1_LABEL_PREFORMATTED");
- private final String LOC_NODE_1_1_IMAGE_FIRST_PREFORMATTED = getLoc("NODE_1_1_IMAGE_FIRST_PREFORMATTED");
- private final String LOC_NODE_1_1_IMAGE_SECOND_PREFORMATTED = getLoc("NODE_1_1_IMAGE_SECOND_PREFORMATTED");
- private final String LOC_NODE_1_1_LINK_PREFORMATTED = getLoc("NODE_1_1_LINK_PREFORMATTED");
- private final String LOC_NODE_1_1_4_LABEL_PREFORMATTED = getLoc("NODE_1_1_4_LABEL_PREFORMATTED");
- private final String LOC_NODE_1_1_N_LABEL_PREFORMATTED = getLoc("NODE_1_1_N_LABEL_PREFORMATTED");
+ private final String LOC_CHRIS_REA_LINK_PREFORMATTED = getLoc("CHRIS_REA_LINK_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_LABEL_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_LABEL_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_LINK_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_LINK_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_4_LABEL_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_4_LABEL_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED");
private final String LOC_NODE_N_PREFORMATTED = getLoc("NODE_N_PREFORMATTED");
- private final String LOC_CHILDREN_1_1_PREFORMATTED = getLoc("CHILDREN_1_1_PREFORMATTED");
- private final String LOC_CHILDREN_1_PREFORMATTED = getLoc("CHILDREN_1_PREFORMATTED");
+ private final String LOC_CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED = getLoc("CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED");
+ private final String LOC_CHILDREN_PREFORMATTED = getLoc("CHILDREN_PREFORMATTED");
private final String[] MSG_NODE_1_1_N_LABEL = new String[] { getMsg("NODE_1_1_1_LABEL"),
getMsg("NODE_1_1_2_LABEL"), getMsg("NODE_1_1_3_LABEL"), getMsg("NODE_1_1_4_LABEL"),
@@ -159,47 +161,46 @@
* @param index
* which tree is being tested
*/
- private void abstractTestTree(int index) {
+ private void abstractTestTree(final int index) {
scrollIntoView(format(LOC_HEADER_PREFORMATTED, index), true);
// click 'Chris Rea'
- waitForElement(format(LOC_NODE_1_LINK_PREFORMATTED, index));
- selenium.click(format(LOC_NODE_1_LINK_PREFORMATTED, index));
+ waitForElement(format(LOC_CHRIS_REA_LINK_PREFORMATTED, index));
+ selenium.click(format(LOC_CHRIS_REA_LINK_PREFORMATTED, index));
// check Rea's child node
- waitForElement(format(LOC_NODE_1_1_LABEL_PREFORMATTED, index));
- String text = selenium.getText(format(LOC_NODE_1_1_LABEL_PREFORMATTED, index));
- assertEquals(text, MSG_NODE_1_1_LABEL, "Name of the first child of first node.");
-
+ Wait.interval(2000).failWith("Name of the first child of first node.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getText(format(LOC_CHRIS_REA_NODE_1_LABEL_PREFORMATTED, index)).equals(MSG_NODE_1_1_LABEL);
+ }
+ });
+
// check the icon of node
- assertTrue(isDisplayed(format(LOC_NODE_1_1_IMAGE_FIRST_PREFORMATTED, index)),
+ assertTrue(isDisplayed(format(LOC_CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED, index)),
"Node 1.1 should be collapsed -- wrong image.");
- assertFalse(isDisplayed(format(LOC_NODE_1_1_IMAGE_SECOND_PREFORMATTED, index)),
+ assertFalse(isDisplayed(format(LOC_CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED, index)),
"Node 1.1 should be collapsed -- wrong image.");
// click 'The Road to Hell'
- selenium.click(format(LOC_NODE_1_1_LINK_PREFORMATTED, index));
+ selenium.click(format(LOC_CHRIS_REA_NODE_1_LINK_PREFORMATTED, index));
// check the number of nodes
- waitForElement(format(LOC_NODE_1_1_4_LABEL_PREFORMATTED, index));
- int numberOfNodes = getJQueryCount(format(LOC_CHILDREN_1_1_PREFORMATTED, index));
- assertEquals(numberOfNodes, MSG_CHILDREN_COUNT_1_1, "Number of children of node 1.1.");
-
+ Wait.interval(2000).failWith("Number of children of node 1.1.").until(new Condition() {
+ public boolean isTrue() {
+ return getJQueryCount(format(LOC_CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED, index)) == MSG_CHILDREN_COUNT_1_1;
+ }
+ });
+
// get all nodes
String label = null;
for (int i = 0; i < 11; i++) {
- label = selenium.getText(format(LOC_NODE_1_1_N_LABEL_PREFORMATTED, index, i));
+ label = selenium.getText(format(LOC_CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED, index, i));
assertEquals(label, MSG_NODE_1_1_N_LABEL[i], format("Node 1.1.{0} should have name {1}.", i + 1, MSG_NODE_1_1_N_LABEL[0]));
}
// check the number of expanded nodes on first level
- numberOfNodes = getJQueryCount(format(LOC_CHILDREN_1_PREFORMATTED, index));
+ int numberOfNodes = getJQueryCount(format(LOC_CHILDREN_PREFORMATTED, index));
assertEquals(numberOfNodes, MSG_CHILDREN_COUNT_TOP, format("There should be {0} top nodes.", MSG_CHILDREN_COUNT_TOP));
-
- // check that only the first node is expanded
- for (int i = 1; i < 4; i++) {
- assertFalse(isDisplayed(format(LOC_NODE_N_PREFORMATTED, index, i)), format("Node nr. {0} should be collapsed.", i+1));
- }
}
/**
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties 2009-11-16 17:19:59 UTC (rev 15886)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tree/locators.properties 2009-11-16 18:20:11 UTC (rev 15887)
@@ -1,15 +1,15 @@
# TreeTestCase -- first tab
HEADER_PREFORMATTED=jquery=fieldset:eq({0}) > legend
-NODE_1_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:eq(0) a
-NODE_1_1_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(2)
-NODE_1_1_IMAGE_FIRST_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(0) img:eq(0)
-NODE_1_1_IMAGE_SECOND_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(0) img:eq(1)
-NODE_1_1_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) td:eq(0) a
-NODE_1_1_4_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) > div:eq(0) > table:eq(3) td:eq(2)
-NODE_1_1_N_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) > div:eq(0) > table:eq({1}) td:eq(2)
+CHRIS_REA_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) a
+CHRIS_REA_NODE_1_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(2)
+CHRIS_REA_NODE_1_IMAGE_FIRST_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(0) img:eq(0)
+CHRIS_REA_NODE_1_IMAGE_SECOND_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(0) img:eq(1)
+CHRIS_REA_NODE_1_LINK_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div td:eq(0) a
+CHRIS_REA_NODE_1_4_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div div table:eq(3) td:eq(2)
+CHRIS_REA_NODE_1_N_LABEL_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div div table:eq({1}) td:eq(2)
NODE_N_PREFORMATTED=jquery=fieldset:eq({0}) > div > form > div > div:eq(0) > div:eq({1})
-CHILDREN_1_1_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > div:eq(0) > div:eq(0) > table
-CHILDREN_1_PREFORMATTED=jquery=fieldset:eq({0}) > div > form > div > div:eq(0) > table
+CHRIS_REA_NODE_1_CHILDREN_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table:has(td:textEquals(Chris Rea)) + div > div:eq(0) > table
+CHILDREN_PREFORMATTED=jquery=fieldset:eq({0}) div[id$=childs]:eq(0) > table
# TreeNodesAdaptorTestCase
EXAMPLE_HEADER=jquery=fieldset:eq(0) > legend
15 years, 1 month
JBoss Rich Faces SVN: r15886 - in root: framework/trunk/impl/src/main/resources/META-INF/resources and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2009-11-16 12:19:59 -0500 (Mon, 16 Nov 2009)
New Revision: 15886
Added:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
Modified:
root/examples/trunk/components/core-demo/pom.xml
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
Log:
ajax queue prototype (not tested yet)
Modified: root/examples/trunk/components/core-demo/pom.xml
===================================================================
--- root/examples/trunk/components/core-demo/pom.xml 2009-11-16 07:47:06 UTC (rev 15885)
+++ root/examples/trunk/components/core-demo/pom.xml 2009-11-16 17:19:59 UTC (rev 15886)
@@ -66,6 +66,16 @@
<version>1.5.8</version>
<scope>provided</scope>
</dependency>
+<dependency>
+<groupId>com.sun.faces</groupId>
+<artifactId>jsf-api</artifactId>
+<version>2.0.2-SNAPSHOT</version>
+</dependency>
+<dependency>
+<groupId>com.sun.faces</groupId>
+<artifactId>jsf-impl</artifactId>
+<version>2.0.2-SNAPSHOT</version>
+</dependency>
</dependencies>
</project>
\ No newline at end of file
Added: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js (rev 0)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2009-11-16 17:19:59 UTC (rev 15886)
@@ -0,0 +1,202 @@
+(function(jQuery, richfaces, jsf) {
+
+ richfaces.ajax = richfaces.ajax || {};
+ richfaces.ajax.request = jsf.ajax.request;
+ jsf.ajax.request = function request(source, event, options) {
+ //richfaces.ajax.request(source, event, options);
+ richfaces.queue.push(source, event, options);
+ }
+
+ richfaces.queue = function(opts){
+
+ var queueEntry = function(query, event, options) {
+ this.query = query;
+ this.options = options || {};
+ this.event = event;
+
+ this.similarityGroupingId = this.options.similarityGroupingId;
+ this.eventsCount = 1;
+ };
+
+ jQuery.extend(queueEntry.prototype, {
+
+ isIgnoreDupResponses: function() {
+ return this.options.ignoreDupResponses;
+ },
+
+ getSimilarityGroupingId: function() {
+ return this.similarityGroupingId;
+ },
+
+ setSimilarityGroupingId: function(id) {
+ this.similarityGroupingId = id;
+ },
+
+ ondrop: function() {
+ var callback = this.options.onqueuerequestdrop;
+ if (callback) {
+ callback.call(this.queue, this.query, this.options, this.event);
+ }
+ },
+
+ onRequestDelayPassed: function() {
+ this.readyToSubmit = true;
+ this.queue.submitFirst(); // TODO: here we need to call query.submitFirst
+ },
+
+ startTimer: function() {
+ var delay = this.options.requestDelay;
+
+ log.debug("Queue will wait " + (delay || 0) + "ms before submit");
+
+ if (delay) {
+ var _this = this;
+ this.timer = setTimeout(function() {
+ try {
+ _this.onRequestDelayPassed();
+ } finally {
+ _this.timer = undefined;
+ _this = undefined;
+ }
+ }, delay);
+ } else {
+ this.onRequestDelayPassed();
+ }
+ },
+
+ stopTimer: function() {
+ if (this.timer) {
+ clearTimeout(this.timer);
+ this.timer = undefined;
+ }
+ },
+
+ clearEntry: function() { //???
+ this.stopTimer();
+ if (this.request) {
+ this.request.shouldNotifyQueue = false;
+ this.request = undefined;
+ }
+ },
+
+ getEventsCount: function() {
+ return this.eventsCount;
+ },
+
+ setEventsCount: function(newCount) {
+ this.eventsCount = newCount;
+ },
+
+ });
+
+ // TODO: add this two variables to richfaces and report bug to jsf about constants
+ var jsfDataTypes = {'event' : 'event'};
+ var jsfEventNames = {'success' : 'success'};
+
+ var log = richfaces.log;
+ var items = [];
+ var queueOptions = opts || {};
+ var last;
+
+ var onError = function (data) {
+ log.debug("richfaces.queue: ajax submit error");
+ last = null;
+ submitFirst();
+ };
+
+ var onComplete = function (data) {
+ if (jsfDataTypes[data.type]=='event' && jsfEventNames[data.status]=='success') {
+ log.debug("richfaces.queue: ajax submit successfull");
+ last = null;
+ submitFirst();
+ }
+ };
+
+ jsf.ajax.addOnEvent(onComplete);
+ jsf.ajax.addOnError(onError);
+
+ var submitFirst = function() {
+ if (last) {
+ log.debug("richfaces.queue: Waiting for previous submit results");
+ return;
+ }
+ if (isEmpty()) {
+ log.debug("richfaces.queue: Nothing to submit");
+ return;
+ }
+ last = items.shift();
+ if (last.readyToSubmit) {
+ log.debug("richfaces.queue: will submit request NOW");
+ last.query.appendParameter("AJAX:EVENTS_COUNT", last.eventsCount);
+ richfaces.ajax.request(last.query, last.event, last.options);
+ if (last.options.queueonsubmit) {
+ last.options.queueonsubmit.call(last);
+ }
+ }
+ };
+
+ var isEmpty = function() {
+ return (getSize()==0)
+ };
+ var getSize = function() {
+ return items.length;
+ };
+
+ var getLastEntry = function () {
+ var lastIdx = items.length - 1;
+ return items[lastIdx];
+ };
+
+ var updateLastEntry = function (entry) {
+ var lastIdx = items.length - 1;
+ items[lastIdx] = entry;
+ };
+
+ return {
+
+ getSize: getSize,
+ isEmpty: isEmpty,
+
+ push: function (source, event, options) {
+ var entry = new queueEntry(source, event, options);
+ var similarityGroupingId = entry.getSimilarityGroupingId();
+
+ var lastEntry = getLastEntry();
+
+ if (lastEntry) {
+ if (lastEntry.getSimilarityGroupingId() == similarityGroupingId) {
+ log.debug("Similar request currently in queue");
+
+ log.debug("Combine similar requests and reset timer");
+
+ lastEntry.stopTimer();
+ entry.setEventsCount(lastEntry.getEventsCount() + 1);
+
+ this.items[lastIdx] = entry;
+ } else {
+ log.debug("Last queue entry is not the last anymore. Stopping requestDelay timer and marking entry as ready for submission")
+
+ lastEntry.stopTimer();
+ lastEntry.setSimilarityGroupingId(undefined);
+ lastEntry.readyToSubmit = true;
+
+ items.push(entry);
+ log.debug("New request added to queue. Queue similarityGroupingId changed to " + similarityGroupingId);
+ }
+ } else {
+ items.push(entry);
+ log.debug("New request added to queue. Queue similarityGroupingId changed to " + similarityGroupingId);
+ }
+
+ entry.startTimer();
+ submitFirst();
+ },
+
+ pop: function () {
+ },
+
+ clear: function () {
+ }
+ }
+ }();
+}(jQuery, RichFaces, jsf));
\ No newline at end of file
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-11-16 07:47:06 UTC (rev 15885)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-11-16 17:19:59 UTC (rev 15886)
@@ -48,7 +48,7 @@
*
*/
@ResourceDependencies({@ResourceDependency(library = "javax.faces", name = "jsf.js") ,
- @ResourceDependency(name = "jquery.js") , @ResourceDependency(name = "richfaces.js") })
+ @ResourceDependency(name = "jquery.js") , @ResourceDependency(name = "richfaces.js"), @ResourceDependency(name = "richfaces-queue.js") })
public abstract class AjaxCommandRendererBase extends RendererBase {
private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2009-11-16 07:47:06 UTC (rev 15885)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2009-11-16 17:19:59 UTC (rev 15886)
@@ -47,7 +47,8 @@
@ResourceDependencies( {
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js") })
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-queue.js") })
public class AjaxStatusRenderer extends RendererBase {
private static final String START = "start";
15 years, 1 month
JBoss Rich Faces SVN: r15885 - branches/community/3.3.X/test-applications/selenium-testing-lib.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2009-11-16 02:47:06 -0500 (Mon, 16 Nov 2009)
New Revision: 15885
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/pom.xml
Log:
- moved generating and installing javadoc and sources to separated profile 'generate-all-jars'
Modified: branches/community/3.3.X/test-applications/selenium-testing-lib/pom.xml
===================================================================
--- branches/community/3.3.X/test-applications/selenium-testing-lib/pom.xml 2009-11-16 05:49:10 UTC (rev 15884)
+++ branches/community/3.3.X/test-applications/selenium-testing-lib/pom.xml 2009-11-16 07:47:06 UTC (rev 15885)
@@ -49,69 +49,78 @@
<target>1.5</target>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>source-jar</id>
- <phase>install</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <executions>
- <execution>
- <id>javadoc-jar</id>
- <phase>install</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <executions>
- <execution>
- <id>install-sources</id>
- <phase>install</phase>
- <goals>
- <goal>install-file</goal>
- </goals>
- <configuration>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <version>${version}</version>
- <packaging>jar</packaging>
- <file>${project.build.directory}/${artifactId}-${version}-sources.jar</file>
- <classifier>sources</classifier>
- </configuration>
- </execution>
- <execution>
- <id>install-javadoc</id>
- <phase>install</phase>
- <goals>
- <goal>install-file</goal>
- </goals>
- <configuration>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <version>${version}</version>
- <packaging>jar</packaging>
- <file>${project.build.directory}/${artifactId}-${version}-javadoc.jar</file>
- <classifier>javadoc</classifier>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>generate-all-jars</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>source-jar</id>
+ <phase>install</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>javadoc-jar</id>
+ <phase>install</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install-sources</id>
+ <phase>install</phase>
+ <goals>
+ <goal>install-file</goal>
+ </goals>
+ <configuration>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>jar</packaging>
+ <file>${project.build.directory}/${artifactId}-${version}-sources.jar</file>
+ <classifier>sources</classifier>
+ </configuration>
+ </execution>
+ <execution>
+ <id>install-javadoc</id>
+ <phase>install</phase>
+ <goals>
+ <goal>install-file</goal>
+ </goals>
+ <configuration>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>jar</packaging>
+ <file>${project.build.directory}/${artifactId}-${version}-javadoc.jar</file>
+ <classifier>javadoc</classifier>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
15 years, 1 month