Author: Alex.Kolonitsky
Date: 2010-07-07 07:46:04 -0400 (Wed, 07 Jul 2010)
New Revision: 17757
Removed:
root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
Modified:
root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
Log:
RF-8745 TogglePanel component
Modified: root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-07-07
11:35:05 UTC (rev 17756)
+++ root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-07-07
11:46:04 UTC (rev 17757)
@@ -63,6 +63,8 @@
public abstract void setOncomplete(Object oncompleteFunction);
+ public abstract void appendOncomplete(Object oncompleteFunction);
+
public abstract Object getOncomplete();
public abstract void setOnbeforedomupdate(Object onbeforedomupdateFunction);
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-07
11:35:05 UTC (rev 17756)
+++
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-07
11:46:04 UTC (rev 17757)
@@ -575,6 +575,18 @@
this.oncomplete = oncomplete;
}
+ public void appendOncomplete(Object onComplete) {
+ StringBuilder res = new StringBuilder();
+ if (this.oncomplete != null) {
+ res.append(this.oncomplete);
+ res.append(';');
+ }
+
+ res.append(onComplete).append(';');
+
+ this.oncomplete = res.toString();
+ }
+
/* (non-Javadoc)
* @see org.ajax4jsf.context.AjaxContext#getOnbeforedomupdate()
*/
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-07-07
11:35:05 UTC (rev 17756)
+++
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-07-07
11:46:04 UTC (rev 17757)
@@ -76,12 +76,14 @@
/**
* Substitutions for components properies names and HTML attributes names.
*/
- private static Map<String, String> substitutions = new HashMap<String,
String>();
- private static Set<String> requiredAttributes = new HashSet<String>();
+ private static final Map<String, String> SUBSTITUTIONS = new HashMap<String,
String>();
+
+ private static final Set<String> REQUIRED_ATTRIBUTES = new
HashSet<String>();
static {
- substitutions.put(HTML.CLASS_ATTRIBUTE, "styleClass");
- requiredAttributes.add(HTML.ALT_ATTRIBUTE);
+ SUBSTITUTIONS.put(HTML.CLASS_ATTRIBUTE, "styleClass");
+
+ REQUIRED_ATTRIBUTES.add(HTML.ALT_ATTRIBUTE);
Arrays.sort(HTML.PASS_THRU);
Arrays.sort(HTML.PASS_THRU_EVENTS);
@@ -460,12 +462,12 @@
}
public boolean shouldRenderAttribute(String attributeName, Object attributeVal) {
- if (!requiredAttributes.contains(attributeName)) {
- return shouldRenderAttribute(attributeVal);
- } else {
- if (null == attributeVal) {
+ if (REQUIRED_ATTRIBUTES.contains(attributeName)) {
+ if (attributeVal == null) {
return false;
}
+ } else {
+ return shouldRenderAttribute(attributeVal);
}
return true;
@@ -604,7 +606,7 @@
* @return
*/
protected Object getComponentAttributeName(Object key) {
- Object converted = substitutions.get(key);
+ Object converted = SUBSTITUTIONS.get(key);
if (null == converted) {
return key;
Deleted:
root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2010-07-07
11:35:05 UTC (rev 17756)
+++
root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2010-07-07
11:46:04 UTC (rev 17757)
@@ -1,261 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - 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.component;
-
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.event.SwitchablePanelSwitchEvent;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.ValueChangeEvent;
-import java.util.Iterator;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.01.2007
- */
-public abstract class UISwitchablePanel extends UIInput {
-
- /**
- * value for tab change method - ajax tabs
- */
- public static final String AJAX_METHOD = "ajax";
-
- /**
- * value for tab change method for - client-side tabs.
- */
- public static final String CLIENT_METHOD = "client";
-
- /**
- * value for tab change method - server-side tabs
- */
- public static final String SERVER_METHOD = "server";
-
- /**
- * default tab change method - server.
- */
- public static final String DEFAULT_METHOD = SERVER_METHOD;
- private String switchType;
-
- public String getSwitchType() {
- if (this.switchType != null) {
- return switchType;
- }
-
- ValueExpression switchTypeExpression =
getValueExpression("switchType");
-
- if (switchTypeExpression != null) {
- return (String)
switchTypeExpression.getValue(FacesContext.getCurrentInstance().getELContext());
- }
-
- return DEFAULT_METHOD;
- }
-
- public void setSwitchType(String switchType) {
- this.switchType = switchType;
- }
-
- public Object convertSwitchValue(UIComponent component, Object object) {
- return object;
- }
-
- public void queueEvent(FacesEvent event) {
- if ((event instanceof SwitchablePanelSwitchEvent) &&
this.equals(event.getComponent())) {
- if (isImmediate()) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else {
- event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
- }
- }
-
- super.queueEvent(event);
- }
-
- public void broadcast(FacesEvent facesEvent) throws AbortProcessingException {
- if (facesEvent instanceof ActionEvent) {
-
- // TODO invoke action listener or remove it
- if (isImmediate()) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- facesContext.renderResponse();
- }
- } // TODO else here
-
- if (facesEvent instanceof SwitchablePanelSwitchEvent) {
- if (isRendered()) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- SwitchablePanelSwitchEvent switchEvent = (SwitchablePanelSwitchEvent)
facesEvent;
- Object newValue = convertSwitchValue(switchEvent.getEventSource(),
switchEvent.getValue());
- Object oldValue = getValue();
-
- if (((oldValue == null) && (newValue != null)) || ((oldValue !=
null) && !oldValue.equals(newValue))) {
- queueEvent(new ValueChangeEvent(this, oldValue, newValue));
- }
-
- // TODO UIInput should update the model, not the switchable panel itself
- ValueExpression valueBinding = getValueExpression("value");
-
- if (valueBinding != null) {
- valueBinding.setValue(facesContext.getELContext(), newValue);
- setValue(null);
- setLocalValueSet(false);
- } else {
- setValue(newValue);
- }
-
- if (AjaxRendererUtils.isAjaxRequest(facesContext)
-
- /* && this.getSwitchType().equals(AJAX_METHOD) */
- ) { // RF-7292
- AjaxRendererUtils.addRegionByName(facesContext, this, this.getId());
- }
- }
- } else /* component should throw IllegalArgumentException for unknown events -
RF-30 */ {
- super.broadcast(facesEvent);
- }
- }
-
- public void updateModel(FacesContext context) {
-
- // no processing here
- }
-
- protected Iterator<UIComponent> getSwitchedFacetsAndChildren() {
- return getFacetsAndChildren();
- }
-
- public void processDecodes(FacesContext context) {
- if (context == null) {
- throw new NullPointerException("FacesContext is null!");
- }
-
- if (!isRendered()) {
- return;
- }
-
- // Process all facets and children of this component
- Iterator<UIComponent> kids = getSwitchedFacetsAndChildren();
-
- while (kids.hasNext()) {
- UIComponent kid = kids.next();
-
- kid.processDecodes(context);
- }
-
- try {
- decode(context);
-
- if (isImmediate()) {
- validate(context);
- }
- } catch (RuntimeException e) {
- context.renderResponse();
-
- throw e;
- }
- }
-
- public void processUpdates(FacesContext context) {
- if (context == null) {
- throw new NullPointerException("FacesContext is null!");
- }
-
- if (!isRendered()) {
- return;
- }
-
- Iterator<UIComponent> kids = getSwitchedFacetsAndChildren();
-
- while (kids.hasNext()) {
- UIComponent kid = kids.next();
-
- kid.processUpdates(context);
- }
-
- try {
- updateModel(context);
-
- if (!isValid()) {
- context.renderResponse();
- }
- } catch (RuntimeException e) {
- context.renderResponse();
-
- throw e;
- }
- }
-
- public void processValidators(FacesContext context) {
- if (context == null) {
- throw new NullPointerException("FacesContext is null!");
- }
-
- if (!isRendered()) {
- return;
- }
-
- Iterator<UIComponent> kids = getSwitchedFacetsAndChildren();
-
- while (kids.hasNext()) {
- UIComponent kid = (UIComponent) kids.next();
-
- kid.processValidators(context);
- }
-
- try {
- if (!isImmediate()) {
- validate(context);
-
- if (!isValid()) {
- context.renderResponse();
- }
- }
- } catch (RuntimeException e) {
- context.renderResponse();
-
- throw e;
- }
- }
-
- public Object saveState(FacesContext context) {
- Object[] states = new Object[2];
-
- states[0] = super.saveState(context);
- states[1] = switchType;
-
- return states;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] states = (Object[]) state;
-
- super.restoreState(context, states[0]);
- this.switchType = (String) states[1];
- }
-}
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-07-07
11:35:05 UTC (rev 17756)
+++
root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-07-07
11:46:04 UTC (rev 17757)
@@ -271,7 +271,7 @@
//TODO - review
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
ajaxContext.setOnbeforedomupdate(callback.getOnbeforedomupdate());
- ajaxContext.setOncomplete(callback.getOncomplete());
+ ajaxContext.appendOncomplete(callback.getOncomplete());
ajaxContext.setResponseData(callback.getData());
}
} else {