Author: nbelaevski
Date: 2007-07-19 18:20:58 -0400 (Thu, 19 Jul 2007)
New Revision: 1715
Added:
trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
Modified:
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
trunk/ui/panel/src/main/config/component/panel.xml
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/tree/src/main/java/org/richfaces/component/state/TreeState.java
trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/ui/tree/src/main/templates/htmlTree.jspx
trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
Log:
merged changes commit
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-07-19
22:11:59 UTC (rev 1714)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -21,9 +21,14 @@
package org.richfaces.component;
+import org.ajax4jsf.component.AjaxActionComponent;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.event.DataScrollerEvent;
+import org.richfaces.event.DataScrollerListener;
+import org.richfaces.event.DataScrollerSource;
+
import javax.faces.FacesException;
import javax.faces.component.ActionSource;
-import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
@@ -31,19 +36,13 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.event.DataScrollerEvent;
-import org.richfaces.event.DataScrollerListener;
-import org.richfaces.event.DataScrollerSource;
-
-/**
- * JSF component class
- */
+/** JSF component class */
//xxxx nick -> alex - extend UIComponentBase and
//create event listener & event classes to define PageSwitchEvent
//public abstract class UIDatascroller extends UIComponentBase implements
DataScrollerSource{
-public abstract class UIDatascroller extends UICommand implements
DataScrollerSource,ActionSource{
+public abstract class UIDatascroller extends AjaxActionComponent
+ implements DataScrollerSource, ActionSource {
public static final String COMPONENT_TYPE = "org.richfaces.Datascroller";
public static final String COMPONENT_FAMILY =
"org.richfaces.Datascroller";
@@ -67,18 +66,22 @@
public static final String NEXT_DISABLED_FACET_NAME = "next_disabled";
- public static final String PREVIOUS_DISABLED_FACET_NAME =
"previous_disabled";
+ public static final String PREVIOUS_DISABLED_FACET_NAME
+ = "previous_disabled";
- public static final String FAST_FORWARD_DISABLED_FACET_NAME =
"fastforward_disabled";
+ public static final String FAST_FORWARD_DISABLED_FACET_NAME
+ = "fastforward_disabled";
- public static final String FAST_REWIND_DISABLED_FACET_NAME =
"fastrewind_disabled";
-
+ public static final String FAST_REWIND_DISABLED_FACET_NAME
+ = "fastrewind_disabled";
+
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
}
public DataScrollerListener[] getScrollerListeners() {
- return (DataScrollerListener[]) getFacesListeners(DataScrollerListener.class);
+ return (DataScrollerListener[]) getFacesListeners(
+ DataScrollerListener.class);
}
public void removeScrollerListener(DataScrollerListener listener) {
@@ -88,16 +91,18 @@
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
if (event instanceof DataScrollerEvent) {
- DataScrollerEvent dataScrollerEvent = (DataScrollerEvent) event;
- setPage(dataScrollerEvent.getNewScrolVal());
+ DataScrollerEvent dataScrollerEvent = (DataScrollerEvent) event;
+ setPage(dataScrollerEvent.getNewScrolVal());
- FacesContext context = FacesContext.getCurrentInstance();
+ FacesContext context = FacesContext.getCurrentInstance();
AjaxRendererUtils.addRegionByName(context, this, this.getId());
AjaxRendererUtils.addRegionByName(context, this, this.getFor());
-
+
+ setupReRender(context);
+
MethodBinding scrollerListener = getScrollerListener();
if (scrollerListener != null) {
- scrollerListener.invoke(context, new Object[] {event});
+ scrollerListener.invoke(context, new Object[]{event});
}
}
}
@@ -153,20 +158,23 @@
public abstract void setStyleClass(String styleClass);
public abstract void setStyle(String styleClass);
-
+
public abstract String getAlign();
public abstract void setAlign(String align);
-
+
public abstract String getBoundaryControls();
+
public abstract void setBoundaryControls(String boundaryControls);
public abstract String getFastControls();
+
public abstract void setFastControls(String fastControls);
public abstract String getStepControls();
+
public abstract void setStepControls(String stepControls);
-
+
/**
* Finds the dataTable which id is mapped to the "for" property
*
@@ -183,16 +191,19 @@
return (UIData) forComp;
}
}
- throw new FacesException("could not dataTable for datascroller " +
this.getId());
+ throw new FacesException(
+ "could not dataTable for datascroller " + this.getId());
} else {
forComp = findComponent(forAttribute);
}
if (forComp == null) {
throw new IllegalArgumentException("could not dataTable with id
'"
- + forAttribute + "'");
+ + forAttribute + "'");
} else if (!(forComp instanceof UIData)) {
- throw new IllegalArgumentException("component with id '" +
forAttribute
- + "' must be of type " + UIData.class.getName() +
", not type "
+ throw new IllegalArgumentException(
+ "component with id '" + forAttribute
+ + "' must be of type " + UIData.class.getName()
+ + ", not type "
+ forComp.getClass().getName());
}
return (UIData) forComp;
@@ -203,7 +214,7 @@
int rows = getRows(uiData);
if (0 == rows) {
throw new FacesException("Missing 'rows' attribute on component
'"
- + uiData.getId() + "'");
+ + uiData.getId() + "'");
}
int pageIndex;
@@ -219,7 +230,7 @@
}
return pageIndex;
}
-
+
/**
* Gets the index of the current page
*
@@ -234,7 +245,8 @@
* Sets the page number according to the parameter recived from the
* commandLink
*
- * @param facetName - can be "first:, "last", "next",
"previous", "fastforward", "fastrewind"
+ * @param facetName - can be "first:, "last", "next",
"previous",
+ * "fastforward", "fastrewind"
*/
public void setPage(String facetName) {
@@ -246,11 +258,15 @@
dataTable.setFirst(0);
} else if (PREVIOUS_FACET_NAME.equals(facetName)) {
int previous = dataTable.getFirst() - getRows(dataTable);
- if (previous >= 0) setFirstRow(previous);
+ if (previous >= 0) {
+ setFirstRow(previous);
+ }
} else if (NEXT_FACET_NAME.equals(facetName)) {
int rows = getRows(dataTable);
int next = dataTable.getFirst() + rows;
- if (next < getRowCount(dataTable)) setFirstRow(next);
+ if (next < getRowCount(dataTable)) {
+ setFirstRow(next);
+ }
//if (rows>0){
// if (((next+rows)/rows)>getMaxPages()){
// next=getMaxPages()*rows-rows;;
@@ -259,11 +275,14 @@
} else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
int fastStep = getFastStep();
int rows = getRows(dataTable);
- if (fastStep <= 0) fastStep = 1;
+ if (fastStep <= 0) {
+ fastStep = 1;
+ }
int next = dataTable.getFirst() + rows * fastStep;
int rowcount = getRowCount(dataTable);
- if (next >= rowcount)
+ if (next >= rowcount) {
next = (rowcount - 1) - ((rowcount - 1) % rows);
+ }
//if (rows>0){
// if (((next+rows)/rows)>getMaxPages()){
// next=getMaxPages()*rows-rows;;
@@ -272,16 +291,20 @@
setFirstRow(next);
} else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
int fastStep = getFastStep();
- if (fastStep <= 0) fastStep = 1;
+ if (fastStep <= 0) {
+ fastStep = 1;
+ }
int previous = dataTable.getFirst() - getRows(dataTable) * fastStep;
- if (previous < 0) previous = 0;
+ if (previous < 0) {
+ previous = 0;
+ }
setFirstRow(previous);
} else if (LAST_FACET_NAME.equals(facetName)) {
int rowcount = getRowCount(dataTable);
int rows = getRows(dataTable);
int delta = rowcount % rows;
int first = delta > 0 && delta < rows ? rowcount - delta :
rowcount
- - rows;
+ - rows;
if (first >= 0) {
//if (rows>0){
//if (((first+rows)/rows)>getMaxPages()){
@@ -311,7 +334,7 @@
int rows = getRows(data);
int pageCount;
if (rows > 0) {
- int rowCount = getRowCount(data);
+ int rowCount = getRowCount(data);
pageCount = rows <= 0 ? 1 : rowCount / rows;
if (rowCount % rows > 0) {
pageCount++;
@@ -325,26 +348,22 @@
}
return pageCount;
}
-
- /**
- * @return the page count of the uidata
- */
+
+ /** @return the page count of the uidata */
public int getPageCount() {
return getPageCount(getDataTable());
}
public int getRowCount(UIData data) {
int rowCount = data.getRowCount();
- if (rowCount >= 0) {
- return rowCount;
+ if (rowCount >= 0) {
+ return rowCount;
}
-
- return BinarySearch.search(data);
+
+ return BinarySearch.search(data);
}
-
- /**
- * @return int
- */
+
+ /** @return int */
public int getRowCount() {
//xxx nick -> alex - scrollable models can return -1 here
//let's implement "dychotomic" discovery
@@ -352,7 +371,7 @@
// setPage() { setRowIndex(pageIdx * rows); }
// isPageAvailable() { return isRowAvailable() }
//return getUIData().getRowCount();
- return getRowCount(getDataTable());
+ return getRowCount(getDataTable());
}
public int getRows(UIData data) {
@@ -364,7 +383,7 @@
return row;
}
-
+
// facet getter methods
public UIComponent getFirst() {
return getFacet(FIRST_FACET_NAME);
@@ -391,11 +410,11 @@
}
public int getFirstRow(UIData data) {
- return data.getFirst();
+ return data.getFirst();
}
-
- public void setFirstRow(int rows) {
- getDataTable().setFirst(rows);
+
+ public void setFirstRow(int rows) {
+ getDataTable().setFirst(rows);
//setControls();
}
@@ -404,10 +423,11 @@
}
static class BinarySearch {
+
public static int search(UIData data) {
- int rowIndex = data.getRowIndex();
+ int rowIndex = data.getRowIndex();
try {
- int n = 1;
+ int n = 1;
int k = 2;
for (; ;) {
data.setRowIndex(k - 1);
Added: trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
--- trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
(rev 0)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -0,0 +1,76 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import org.ajax4jsf.event.AjaxActionEvent;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesListener;
+
+/** @author Wesley Hales */
+public class DataScrollerEvent extends AjaxActionEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2657353903701932561L;
+ private String oldScrolVal;
+ private String newScrolVal;
+
+ /**
+ * Creates a new ScrollerEvent.
+ *
+ * @param component the source of the event
+ * @param thisOldScrolVal the previously showing item identifier
+ * @param thisNewScrolVal the currently showing item identifier
+ */
+ public DataScrollerEvent(UIComponent component, String thisOldScrolVal,
+ String thisNewScrolVal) {
+ super(component);
+ oldScrolVal = thisOldScrolVal;
+ newScrolVal = thisNewScrolVal;
+ }
+
+ public String getOldScrolVal() {
+ return oldScrolVal;
+ }
+
+ public String getNewScrolVal() {
+ return newScrolVal;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return super.isAppropriateListener(listener)
+ || (listener instanceof DataScrollerListener);
+ }
+
+ /**
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener) {
+ if (super.isAppropriateListener(listener)) {
+ super.processListener(listener);
+ }
+ }
+}
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-07-19
22:11:59 UTC (rev 1714)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -30,9 +30,9 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.UIDragIndicator;
import org.richfaces.component.nsutils.NSUtils;
+//import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
/**
* Base renderer class for drag indicator ( marker ).
@@ -68,7 +68,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
return UIDragIndicator.class;
@@ -102,8 +102,8 @@
protected String getPredefinedMarker(FacesContext context, Object facetName) {
if (MARKERS_PREDEFINED.contains(facetName)) {
- return ScriptUtils.toScript("<img alt=\"\" border=\"0\"
width=\"16\" height=\"16\" src=\"" +
- getResource("/org/richfaces/renderkit/html/images/" + facetName +
".gif").getUri(context, null) +"\" />");
+ //return StringEscapeUtils.escapeJavaScript("<img alt=\"\"
border=\"0\" width=\"16\" height=\"16\" src=\"" +
+ // getResource("/org/richfaces/renderkit/html/images/" + facetName +
".gif").getUri(context, null) +"\" />");
}
throw new IllegalArgumentException("No predefined marker with [" + facetName
+ "] name exists!");
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-19
22:11:59 UTC (rev 1714)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -30,11 +30,11 @@
import javax.faces.event.FacesEvent;
import org.ajax4jsf.javascript.DnDScript;
-import org.ajax4jsf.javascript.PrototypeScript;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DragEvent;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.javascript.PrototypeScript;
import org.richfaces.renderkit.DnDEventsExchangeMailer.EventCallback;
/**
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-19
22:11:59 UTC (rev 1714)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -29,15 +29,15 @@
import javax.faces.event.FacesEvent;
import org.ajax4jsf.javascript.DnDScript;
+import org.richfaces.component.Draggable;
+import org.richfaces.component.Dropzone;
+import org.richfaces.event.DropEvent;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.javascript.PrototypeScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.PrototypeScript;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.component.Draggable;
-import org.richfaces.component.Dropzone;
-import org.richfaces.event.DropEvent;
import org.richfaces.json.JSONCollection;
import org.richfaces.json.JSONException;
import org.richfaces.json.JSONMap;
Modified: trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java
===================================================================
--- trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java 2007-07-19
22:11:59 UTC (rev 1714)
+++ trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -40,8 +40,8 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
- javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
javaScripts.add("scripts/browser_info.js");
javaScripts.add("org.ajax4jsf.dnd.DnDScript");
javaScripts.add("scripts/events.js");
Modified:
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
===================================================================
---
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2007-07-19
22:11:59 UTC (rev 1714)
+++
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -31,10 +31,10 @@
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
-import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.UIModalPanel;
/**
Modified: trunk/ui/panel/src/main/config/component/panel.xml
===================================================================
--- trunk/ui/panel/src/main/config/component/panel.xml 2007-07-19 22:11:59 UTC (rev 1714)
+++ trunk/ui/panel/src/main/config/component/panel.xml 2007-07-19 22:20:58 UTC (rev 1715)
@@ -47,6 +47,10 @@
<description>
A class that defines a style for a panel content
</description>
+ </property>
+ <property>
+ <name>header</name>
+ <classname>java.lang.String</classname>
</property>
<property>
<name>header</name>
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-19
22:11:59 UTC (rev 1714)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -22,8 +22,6 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererBase;
@@ -33,10 +31,12 @@
import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.TemplateCSSResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.richfaces.component.AjaxSuggestionEvent;
import org.richfaces.component.UISuggestionBox;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
import javax.faces.FacesException;
import javax.faces.component.NamingContainer;
@@ -122,7 +122,7 @@
* @param context {@link javax.faces.context.FacesContext}
* @param component {@link javax.faces.component.UIComponent}
*
- * @see org.ajax4jsf.renderkit.RendererBase#doDecode(
+ * @see org.ajax4jsf.framework.renderer.RendererBase#doDecode(
* javax.faces.context.FacesContext,
* javax.faces.component.UIComponent)
*/
@@ -152,7 +152,7 @@
* @param component {@link javax.faces.component.UIComponent}
* @throws IOException
*
- * @see {@link org.ajax4jsf.renderkit.RendererBase#doEncodeBegin}
+ * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin}
*/
protected final void doEncodeBegin(final ResponseWriter writer,
final FacesContext context,
@@ -171,7 +171,7 @@
* @param component {@link javax.faces.component.UIComponent}
* @throws IOException
*
- * @see {@link org.ajax4jsf.renderkit.RendererBase#doEncodeEnd}
+ * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
*/
protected void doEncodeEnd(final ResponseWriter writer,
final FacesContext context,
@@ -340,7 +340,7 @@
*
* @param context {@link javax.faces.context.FacesContext}
* @param data
- * @return {@link org.ajax4jsf.renderkit.compiler.TemplateContext}
+ * @return {@link org.ajax4jsf.framework.renderer.compiler.TemplateContext}
*/
private TemplateContext getTemplateContext(final FacesContext context,
final UIData data) {
@@ -376,7 +376,7 @@
/**
* Constructor.
*
- * @param renderer {@link org.ajax4jsf.renderkit.RendererBase}
+ * @param renderer {@link org.ajax4jsf.framework.renderer.RendererBase}
* @param facesContext {@link javax.faces.context.FacesContext}
* @param component {@link javax.faces.component.UIComponent}
*/
@@ -693,7 +693,7 @@
* Gets additional scripts.
*
* @return array of resources
- * {@link org.ajax4jsf.resource.InternetResource}
+ * {@link org.ajax4jsf.framework.resource.InternetResource}
*/
protected final InternetResource[] getAdditionalScripts() {
return additionalScripts;
@@ -703,7 +703,7 @@
* Gets styles.
*
* @return array of styles
- * {@link org.ajax4jsf.resource.InternetResource}
+ * {@link org.ajax4jsf.framework.resource.InternetResource}
*/
protected final InternetResource[] getStyles() {
return styles;
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/state/TreeState.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/state/TreeState.java 2007-07-19
22:11:59 UTC (rev 1714)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/state/TreeState.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -32,10 +32,10 @@
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.Range;
+import org.richfaces.model.TreeRange;
+import org.richfaces.model.TreeRowKey;
import org.richfaces.component.UITree;
import org.richfaces.component.state.events.TreeStateCommandsListener;
-import org.richfaces.model.TreeRange;
-import org.richfaces.model.TreeRowKey;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com created 23.11.2006
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-07-19
22:11:59 UTC (rev 1714)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -35,22 +35,21 @@
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.model.LastElementAware;
+import org.richfaces.model.TreeRowKey;
import org.richfaces.component.UITree;
import org.richfaces.component.UITreeNode;
import org.richfaces.component.nsutils.NSUtils;
+import org.richfaces.model.TreeRange;
import org.richfaces.component.state.TreeState;
import org.richfaces.component.state.TreeStateAdvisor;
-import org.richfaces.model.LastElementAware;
-import org.richfaces.model.TreeRange;
-import org.richfaces.model.TreeRowKey;
public abstract class TreeRendererBase extends CompositeRenderer {
@@ -147,8 +146,6 @@
private final ResponseWriter writer;
- private final StringHolder holder;
-
private final Flag flag;
private final UITree tree;
@@ -158,10 +155,9 @@
private TreeStateAdvisor methodBindingAdvisor = null;
private DataVisitorWithLastElement(ResponseWriter writer,
- StringHolder holder, Flag flag, UITree tree,
+ Flag flag, UITree tree,
TreeDataModelEventNavigator navigator) {
this.writer = writer;
- this.holder = holder;
this.flag = flag;
this.tree = tree;
this.navigator = navigator;
@@ -174,10 +170,6 @@
processAdvisors(context, (TreeRowKey)rowKey);
- if (tree.isSelected()) {
- holder.setValue(tree.getNodeFacet().getClientId(context));
- }
-
if (!flag.isFlagSet()) {
closeLevelDownTable(context, tree, writer);
openLevelDownTable(context, tree, writer);
@@ -350,24 +342,34 @@
}
public String encodeSelectionStateInput(FacesContext context, UITree tree) throws
IOException {
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, tree);
- Object object = variables.getVariable("selectionId");
- if (object != null) {
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement("input", tree);
- writer.writeAttribute("type", "hidden", null);
- String selectionHolderInputId = tree.getSelectionStateInputName(context);
- writer.writeAttribute("id", selectionHolderInputId, null);
- writer.writeAttribute("name", selectionHolderInputId, null);
-
- writer.writeAttribute("value", object,
- null);
- writer.endElement("input");
-
- return selectionHolderInputId;
+ String result = "";
+ TreeState treeState = (TreeState) tree.getComponentState();
+ TreeRowKey selectedNodeKey = treeState.getSelectedNode();
+ if (selectedNodeKey != null) {
+ Object rowKey = tree.getRowKey();
+ try {
+ tree.setRowKey(selectedNodeKey);
+ result = tree.getNodeFacet().getClientId(context);
+ } finally {
+ try {
+ tree.setRowKey(rowKey);
+ } catch (Exception e) {
+ context.getExternalContext().log(e.getMessage(), e);
+ }
+ }
}
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("input", tree);
+ writer.writeAttribute("type", "hidden", null);
+ String selectionHolderInputId = tree.getSelectionStateInputName(context);
+ writer.writeAttribute("id", selectionHolderInputId, null);
+ writer.writeAttribute("name", selectionHolderInputId, null);
- return null;
+ writer.writeAttribute("value", result, null);
+ writer.endElement("input");
+
+ return selectionHolderInputId;
}
protected String getAjaxScript(FacesContext context, UITree tree) {
@@ -457,8 +459,6 @@
TreeRowKey rowKey = (TreeRowKey) key;
- final StringHolder selectionValueHolder = new StringHolder();
-
//Object savedRowKey = input.getRowKey();
try {
input.captureOrigValue();
@@ -500,7 +500,7 @@
};
input.walk(context, new DataVisitorWithLastElement(writer,
- selectionValueHolder, droppedDownToLevelFlag, input,
+ droppedDownToLevelFlag, input,
levelNavigator), treeRange, key, null);
if (key != null) {
@@ -508,14 +508,6 @@
}
levelNavigator.followRowKey(context, null);
-
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, input);
- String value = selectionValueHolder.getValue();
- if (value != null) {
- variables.setVariable("selectionId", value);
- } else if (rowKey == null) {
- variables.setVariable("selectionId", "");
- }
} finally {
input.setRowKey(context, null);
input.restoreOrigValue();
@@ -559,16 +551,4 @@
public boolean isFlagSet() {
return flag;
}
-}
-
-class StringHolder {
- private String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
}
\ No newline at end of file
Modified: trunk/ui/tree/src/main/templates/htmlTree.jspx
===================================================================
--- trunk/ui/tree/src/main/templates/htmlTree.jspx 2007-07-19 22:11:59 UTC (rev 1714)
+++ trunk/ui/tree/src/main/templates/htmlTree.jspx 2007-07-19 22:20:58 UTC (rev 1715)
@@ -17,7 +17,7 @@
new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
- /org/ajax4jsf/javascript/scripts/form.js,
+ /org/ajax4jsf/renderkit/html/scripts/form.js,
/org/richfaces/renderkit/html/scripts/form.js,
/org/richfaces/renderkit/html/scripts/events.js,
/org/richfaces/renderkit/html/scripts/tree.js,
@@ -44,11 +44,7 @@
<f:parameter value="id,style,class"/>
</f:call>
- <table width="100%" cellpadding="0">
- <tbody>
- <vcp:body />
- </tbody>
- </table>
+ <vcp:body />
<f:call name="encodeSelectionStateInput" />
<f:clientId var="clientId" />
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-19
22:11:59 UTC (rev 1714)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-19
22:20:58 UTC (rev 1715)
@@ -38,22 +38,22 @@
import javax.faces.event.PhaseId;
import javax.servlet.http.HttpServletResponse;
+import org.richfaces.event.DragEvent;
+import org.richfaces.event.DragListener;
+import org.richfaces.event.DropEvent;
+import org.richfaces.event.DropListener;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
-import org.richfaces.component.state.events.ExpandAllCommandEvent;
-import org.richfaces.component.xml.XmlTreeDataBuilder;
-import org.richfaces.event.DragEvent;
-import org.richfaces.event.DragListener;
-import org.richfaces.event.DropEvent;
-import org.richfaces.event.DropListener;
import org.richfaces.event.NodeExpandedEvent;
import org.richfaces.event.NodeExpandedListener;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.event.NodeSelectedListener;
+import org.richfaces.component.state.events.ExpandAllCommandEvent;
+import org.richfaces.component.xml.XmlTreeDataBuilder;
import org.xml.sax.InputSource;
import com.gargoylesoftware.htmlunit.Page;
@@ -73,7 +73,7 @@
static {
javaScripts.add("/org/richfaces/renderkit/html/scripts/json/json-mini.js");
- javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("scripts/AJAX.js");
javaScripts.add("org.ajax4jsf.dnd.DnDScript");
@@ -83,7 +83,7 @@
javaScripts.add("/org/richfaces/renderkit/html/scripts/dnd/dnd-dropzone.js");
- javaScripts.add("/org/ajax4jsf/javascript/scripts/form.js");
+ javaScripts.add("/org/ajax4jsf/renderkit/html/scripts/form.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/form.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/events.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/tree.js");
@@ -330,7 +330,7 @@
/**
- * Test method for {@link
org.richfaces.component.UITreeNode#addChangeExpandListener(org.richfaces.event.NodeExpandedListener)}.
+ * Test method for {@link
org.richfaces.component.UITreeNode#addChangeExpandListener(org.richfaces.component.events.NodeExpandedListener)}.
*/
public final void testAddChangeExpandListener() {
NodeExpandedListener listener = new NodeExpandedListener() {
@@ -360,7 +360,7 @@
}
/**
- * Test method for {@link
org.richfaces.component.UITreeNode#addNodeSelectListener(org.richfaces.event.NodeSelectedListener)}.
+ * Test method for {@link
org.richfaces.component.UITreeNode#addNodeSelectListener(org.richfaces.component.events.NodeSelectedListener)}.
*/
public final void testAddNodeSelectListener() {
NodeSelectedListener listener = new NodeSelectedListener() {
@@ -410,7 +410,7 @@
}
/**
- * Test method for {@link
org.richfaces.component.UITreeNode#addDropListener(org.richfaces.event.DropListener)}.
+ * Test method for {@link
org.richfaces.component.UITreeNode#addDropListener(org.ajax4jsf.dnd.event.DropListener)}.
*/
public final void testAddDropListener() {
DropListener listener = new DropListener() {
@@ -439,7 +439,7 @@
}
/**
- * Test method for {@link
org.richfaces.component.UITreeNode#addDragListener(org.richfaces.event.DragListener)}.
+ * Test method for {@link
org.richfaces.component.UITreeNode#addDragListener(org.ajax4jsf.dnd.event.DragListener)}.
*/
public final void testAddDragListener() {
DragListener listener = new DragListener() {