You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/04/02 21:37:18 UTC
svn commit: r644014 [2/10] - in /myfaces/tobago/trunk: ./ core/
core/src/main/faces-config/
core/src/main/java/org/apache/myfaces/tobago/ajax/api/
core/src/main/java/org/apache/myfaces/tobago/application/
core/src/main/java/org/apache/myfaces/tobago/co...
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIForm.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIForm.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIForm.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIForm.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIForm.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIForm.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIForm.java Wed Apr 2 12:36:26 2008
@@ -22,6 +22,7 @@
import org.apache.myfaces.tobago.compat.FacesUtils;
import org.apache.myfaces.tobago.compat.InvokeOnComponent;
import org.apache.myfaces.tobago.util.TobagoCallback;
+import org.apache.myfaces.tobago.util.ComponentUtil;
import javax.faces.component.UIComponent;
import javax.faces.component.ContextCallback;
@@ -30,10 +31,9 @@
import javax.faces.event.PhaseId;
import java.util.Iterator;
+public class AbstractUIForm extends javax.faces.component.UIForm implements InvokeOnComponent, Form {
-public class UIForm extends javax.faces.component.UIForm implements InvokeOnComponent {
-
- private static final Log LOG = LogFactory.getLog(UIForm.class);
+ private static final Log LOG = LogFactory.getLog(AbstractUIForm.class);
public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Form";
public static final String SUBMITTED_MARKER = COMPONENT_TYPE + ".InSubmitted";
@@ -56,7 +56,7 @@
super.setSubmitted(b);
// set submitted for all subforms
- for (UIForm subForm : ComponentUtil.findSubForms(this)) {
+ for (AbstractUIForm subForm : ComponentUtil.findSubForms(this)) {
subForm.setSubmitted(b);
}
}
@@ -67,7 +67,7 @@
LOG.debug("processValidators for form: " + getClientId(facesContext));
}
if (!isSubmitted()) {
- for (UIForm subForm : ComponentUtil.findSubForms(this)) {
+ for (AbstractUIForm subForm : ComponentUtil.findSubForms(this)) {
subForm.processValidators(facesContext);
}
} else {
@@ -86,7 +86,7 @@
LOG.debug("processUpdates for form: " + getClientId(facesContext));
}
if (!isSubmitted()) {
- for (UIForm subForm : ComponentUtil.findSubForms(this)) {
+ for (AbstractUIForm subForm : ComponentUtil.findSubForms(this)) {
subForm.processUpdates(facesContext);
}
} else {
@@ -107,7 +107,7 @@
decode(context);
}
}
- context.getExternalContext().getRequestMap().put(UIForm.SUBMITTED_MARKER, isSubmitted());
+ context.getExternalContext().getRequestMap().put(AbstractUIForm.SUBMITTED_MARKER, isSubmitted());
return FacesUtils.invokeOnComponent(context, this, clientId, callback);
}
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIForm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIForm.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIGridLayout.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIGridLayout.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIGridLayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java Wed Apr 2 12:36:26 2008
@@ -19,47 +19,26 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_COLUMNS;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SPAN_X;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SPAN_Y;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_BORDER;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CELLSPACING;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARGIN;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARGIN_BOTTOM;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARGIN_LEFT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARGIN_RIGHT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARGIN_TOP;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ROWS;
import org.apache.myfaces.tobago.util.LayoutUtil;
+import org.apache.myfaces.tobago.util.ComponentUtil;
+import org.apache.myfaces.tobago.layout.LayoutTokens;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-public class UIGridLayout extends UILayout {
+public abstract class AbstractUIGridLayout extends UILayout {
- private static final Log LOG = LogFactory.getLog(UIGridLayout.class);
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.GridLayout";
- public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.GridLayout";
+ private static final Log LOG = LogFactory.getLog(AbstractUIGridLayout.class);
public static final Marker FREE = new Marker("free");
public static final String USED = "used";
- private String border;
- private String cellspacing;
-
- private String margin;
- private String marginTop;
- private String marginRight;
- private String marginBottom;
- private String marginLeft;
- private String columns;
- private String rows;
private boolean ignoreFree;
private transient LayoutTokens columnLayout;
private transient LayoutTokens rowLayout;
@@ -80,184 +59,17 @@
return columnLayout;
}
- public String getMarginTop() {
- if (marginTop != null) {
- return marginTop;
- }
- ValueBinding vb = getValueBinding(ATTR_MARGIN_TOP);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return getMargin();
- }
- }
-
- public String getMarginRight() {
- if (marginRight != null) {
- return marginRight;
- }
- ValueBinding vb = getValueBinding(ATTR_MARGIN_RIGHT);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return getMargin();
- }
- }
-
- public String getMarginBottom() {
- if (marginBottom != null) {
- return marginBottom;
- }
- ValueBinding vb = getValueBinding(ATTR_MARGIN_BOTTOM);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return getMargin();
- }
- }
-
- public String getMarginLeft() {
- if (marginLeft != null) {
- return marginLeft;
- }
- ValueBinding vb = getValueBinding(ATTR_MARGIN_LEFT);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return getMargin();
- }
- }
- public String getMargin() {
- if (margin != null) {
- return margin;
- }
- ValueBinding vb = getValueBinding(ATTR_MARGIN);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return margin;
- }
- }
+ public abstract String getRows();
- public String getRows() {
- if (rows != null) {
- return rows;
- }
- ValueBinding vb = getValueBinding(ATTR_ROWS);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return "1*";
- }
- }
+ public abstract String getColumns();
- public String getColumns() {
- if (columns != null) {
- return columns;
- }
- ValueBinding vb = getValueBinding(ATTR_COLUMNS);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return "1*";
- }
- }
-
- public String getCellspacing() {
- if (cellspacing != null) {
- return cellspacing;
- }
- ValueBinding vb = getValueBinding(ATTR_CELLSPACING);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return cellspacing;
- }
- }
-
- public String getBorder() {
- if (border != null) {
- return border;
- }
- ValueBinding vb = getValueBinding(ATTR_BORDER);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return border;
- }
- }
-
- public void setBorder(String border) {
- this.border = border;
- }
-
- public void setCellspacing(String cellspacing) {
- this.cellspacing = cellspacing;
- }
-
- public void setMargin(String margin) {
- this.margin = margin;
- }
-
- public void setMarginTop(String marginTop) {
- this.marginTop = marginTop;
- }
-
- public void setMarginRight(String marginRight) {
- this.marginRight = marginRight;
- }
-
- public void setMarginBottom(String marginBottom) {
- this.marginBottom = marginBottom;
- }
-
- public void setMarginLeft(String marginLeft) {
- this.marginLeft = marginLeft;
- }
-
- public void setColumns(String columns) {
- this.columns = columns;
- }
-
- public void setRows(String rows) {
- this.rows = rows;
- }
public Object saveState(FacesContext context) {
clearRows();
- Object[] saveState = new Object[10];
- saveState[0] = super.saveState(context);
- saveState[1] = rows;
- saveState[2] = columns;
- saveState[3] = margin;
- saveState[4] = marginLeft;
- saveState[5] = marginRight;
- saveState[6] = marginTop;
- saveState[7] = marginBottom;
- saveState[8] = border;
- saveState[9] = cellspacing;
- return saveState;
+ return super.saveState(context);
}
- public void restoreState(FacesContext context, Object savedState) {
- Object[] values = (Object[]) savedState;
- super.restoreState(context, values[0]);
- rows = (String) values[1];
- columns = (String) values[2];
- margin = (String) values[3];
- marginLeft = (String) values[4];
- marginRight = (String) values[5];
- marginTop = (String) values[6];
- marginBottom = (String) values[7];
- border = (String) values[8];
- cellspacing = (String) values[9];
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
@Override
public boolean getRendersChildren() {
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIMessages.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIMessages.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIMessages.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java Wed Apr 2 12:36:26 2008
@@ -18,27 +18,16 @@
*/
import org.apache.commons.collections.iterators.SingletonIterator;
-import org.apache.myfaces.tobago.TobagoConstants;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-public class UIMessages extends javax.faces.component.UIMessages {
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Messages";
-
- private FacesMessage.Severity minSeverity;
- private FacesMessage.Severity maxSeverity;
- private Integer maxNumber;
- // todo: emnum
- private OrderBy orderBy;
- private String forValue;
+public abstract class AbstractUIMessages extends javax.faces.component.UIMessages {
public List<Item> createMessageList(FacesContext facesContext) {
@@ -54,13 +43,10 @@
List<Item> messages = collectMessageList(facesContext, clientIds);
// todo
- if (OrderBy.SEVERITY.equals(orderBy)) {
+ if (OrderBy.SEVERITY.equals(getOrderBy())) {
// sort
Collections.sort(messages, new ItemComparator());
}
-
-
-
return messages;
}
@@ -71,7 +57,7 @@
Iterator<FacesMessage> i = facesContext.getMessages(clientId);
while (i.hasNext()) {
FacesMessage facesMessage = i.next();
- if (maxNumber != null && messages.size() >= maxNumber) {
+ if (getMaxNumber() != null && messages.size() >= getMaxNumber()) {
return messages;
}
if (facesMessage.getSeverity().getOrdinal() < getMinSeverity().getOrdinal()) {
@@ -119,108 +105,15 @@
}
}
- public FacesMessage.Severity getMinSeverity() {
- if (minSeverity != null) {
- return minSeverity;
- }
- ValueBinding vb = getValueBinding(TobagoConstants.ATTR_MIN_SEVERITY);
- if (vb != null) {
- return (FacesMessage.Severity) vb.getValue(getFacesContext());
- } else {
- return FacesMessage.SEVERITY_INFO;
- }
- }
-
- public void setMinSeverity(FacesMessage.Severity minSeverity) {
- this.minSeverity = minSeverity;
- }
+ public abstract FacesMessage.Severity getMinSeverity();
- public FacesMessage.Severity getMaxSeverity() {
- if (maxSeverity != null) {
- return maxSeverity;
- }
- ValueBinding vb = getValueBinding(TobagoConstants.ATTR_MAX_SEVERITY);
- if (vb != null) {
- return (FacesMessage.Severity) vb.getValue(getFacesContext());
- } else {
- return FacesMessage.SEVERITY_FATAL;
- }
- }
+ public abstract FacesMessage.Severity getMaxSeverity();
- public void setMaxSeverity(FacesMessage.Severity maxSeverity) {
- this.maxSeverity = maxSeverity;
- }
+ public abstract Integer getMaxNumber();
- public Integer getMaxNumber() {
- if (maxNumber != null) {
- return maxNumber;
- }
- ValueBinding vb = getValueBinding(TobagoConstants.ATTR_MAX_NUMBER);
- if (vb != null) {
- Number number = (Number) vb.getValue(getFacesContext());
- if (number != null) {
- return Integer.valueOf(number.intValue());
- }
- }
- return null;
- }
+ public abstract OrderBy getOrderBy();
- public void setMaxNumber(Integer maxNumber) {
- this.maxNumber = maxNumber;
- }
-
- public OrderBy getOrderBy() {
- if (orderBy != null) {
- return orderBy;
- }
- ValueBinding vb = getValueBinding(TobagoConstants.ATTR_ORDER_BY);
- if (vb != null) {
- return (OrderBy) vb.getValue(getFacesContext());
- } else {
- return OrderBy.OCCURENCE;
- }
- }
-
- public void setOrderBy(OrderBy orderBy) {
- this.orderBy = orderBy;
- }
-
- public void setFor(String forValue) {
- this.forValue = forValue;
- }
-
- public String getFor() {
- if (forValue != null) {
- return forValue;
- }
- ValueBinding vb = getValueBinding("for");
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[6];
- values[0] = super.saveState(context);
- values[1] = minSeverity;
- values[2] = maxSeverity;
- values[3] = maxNumber;
- values[4] = orderBy;
- values[5] = forValue;
- return values;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- minSeverity = (FacesMessage.Severity) values[1];
- maxSeverity = (FacesMessage.Severity) values[2];
- maxNumber = (Integer) values[3];
- orderBy = (OrderBy) values[4];
- forValue = (String) values[5];
- }
+ public abstract String getFor();
public enum OrderBy {
@@ -233,6 +126,5 @@
public static OrderBy parse(String key) {
return valueOf(key.toUpperCase());
}
-
}
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java Wed Apr 2 12:36:26 2008
@@ -22,23 +22,20 @@
import org.apache.commons.collections.set.ListOrderedSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_APPLICATION_ICON;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOCUS_ID;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH;
import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
import org.apache.myfaces.tobago.model.PageState;
import org.apache.myfaces.tobago.model.PageStateImpl;
import org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataRequest;
import org.apache.myfaces.tobago.compat.FacesUtils;
import org.apache.myfaces.tobago.compat.InvokeOnComponent;
+import org.apache.myfaces.tobago.util.DebugUtils;
+import org.apache.myfaces.tobago.util.ComponentUtil;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.ContextCallback;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import javax.faces.FacesException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
@@ -49,12 +46,12 @@
import java.util.Set;
import java.util.StringTokenizer;
-public class UIPage extends UIForm implements InvokeOnComponent {
+public abstract class AbstractUIPage extends AbstractUIForm implements InvokeOnComponent {
- private static final Log LOG = LogFactory.getLog(UIPage.class);
+ private static final Log LOG = LogFactory.getLog(AbstractUIPage.class);
public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Page";
- public static final String ENCTYPE_KEY = UIPanel.class.getName() + ".enctype";
+ public static final String ENCTYPE_KEY = AbstractUIPage.class.getName() + ".enctype";
public static final String DEFAULT_STYLE = "style/style.css";
@@ -64,8 +61,6 @@
private String formId;
- private String focusId;
-
private String actionId;
private String defaultActionId;
@@ -88,16 +83,11 @@
private Set<String> onsubmitScripts;
- private Set<UIPopup> popups;
-
- private Integer width;
+ private Set<AbstractUIPopup> popups;
- private Integer height;
-
- private String applicationIcon;
@SuppressWarnings("unchecked")
- public UIPage() {
+ public AbstractUIPage() {
scriptFiles = SetUniqueList.decorate(new ArrayList());
scriptBlocks = new ListOrderedSet();
styleFiles = new ListOrderedSet();
@@ -186,11 +176,11 @@
if (LOG.isTraceEnabled()) {
LOG.trace(currentActionId);
LOG.trace(command);
- LOG.trace(ComponentUtil.toString(facesContext.getViewRoot(), 0));
+ LOG.trace(DebugUtils.toString(facesContext.getViewRoot(), 0));
}
if (command != null) {
- UIForm form = ComponentUtil.findForm(command);
+ AbstractUIForm form = ComponentUtil.findForm(command);
form.setSubmitted(true);
if (LOG.isTraceEnabled()) {
@@ -284,12 +274,12 @@
}
public PageState getPageState(FacesContext facesContext) {
- ValueBinding stateBinding = getValueBinding(ATTR_STATE);
- if (stateBinding != null) {
- PageState state = (PageState) stateBinding.getValue(facesContext);
+ if (FacesUtils.hasValueBindingOrValueExpression(this, ATTR_STATE)) {
+ PageState state = (PageState)
+ FacesUtils.getValueFromValueBindingOrValueExpression(facesContext, this, ATTR_STATE);
if (state == null) {
state = new PageStateImpl();
- stateBinding.setValue(facesContext, state);
+ FacesUtils.setValueOfBindingOrExpression(facesContext, state, this, ATTR_STATE);
}
return state;
} else {
@@ -297,24 +287,6 @@
}
}
-// ///////////////////////////////////////////// bean getter + setter
-
- public String getFocusId() {
- if (focusId != null) {
- return focusId;
- }
- ValueBinding vb = getValueBinding(ATTR_FOCUS_ID);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- public void setFocusId(String focusId) {
- this.focusId = focusId;
- }
-
public String getActionId() {
return actionId;
}
@@ -364,89 +336,32 @@
return onsubmitScripts;
}
- public Set<UIPopup> getPopups() {
+ public Set<AbstractUIPopup> getPopups() {
return popups;
}
- public Integer getWidth() {
- if (width != null) {
- return width;
- }
- ValueBinding vb = getValueBinding(ATTR_WIDTH);
- if (vb != null) {
- return (Integer) vb.getValue(getFacesContext());
- } else {
- Integer requestWidth =
- (Integer) FacesContext.getCurrentInstance().getExternalContext().
- getRequestMap().get("tobago-page-clientDimension-width");
- if (requestWidth != null) {
- return requestWidth;
- } else {
- return DEFAULT_WIDTH;
- }
- }
- }
-
- public void setWidth(Integer width) {
- this.width = width;
- }
- public Integer getHeight() {
- if (height != null) {
- return height;
- }
- ValueBinding vb = getValueBinding(ATTR_HEIGHT);
- if (vb != null) {
- return (Integer) vb.getValue(getFacesContext());
+ protected Integer getWidthInternal() {
+ Integer requestWidth =
+ (Integer) FacesContext.getCurrentInstance().getExternalContext().
+ getRequestMap().get("tobago-page-clientDimension-width");
+ if (requestWidth != null) {
+ return requestWidth;
} else {
- Integer requestHeight =
- (Integer) FacesContext.getCurrentInstance().getExternalContext().
- getRequestMap().get("tobago-page-clientDimension-height");
- if (requestHeight != null) {
- return requestHeight;
- } else {
- return DEFAULT_HEIGHT;
- }
+ return DEFAULT_WIDTH;
}
}
- public void setHeight(Integer height) {
- this.height = height;
- }
- public String getApplicationIcon() {
- if (applicationIcon != null) {
- return applicationIcon;
- }
- ValueBinding vb = getValueBinding(ATTR_APPLICATION_ICON);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
+ protected Integer getHeightInternal() {
+ Integer requestHeight =
+ (Integer) FacesContext.getCurrentInstance().getExternalContext().
+ getRequestMap().get("tobago-page-clientDimension-height");
+ if (requestHeight != null) {
+ return requestHeight;
} else {
- return null;
+ return DEFAULT_HEIGHT;
}
- }
-
- public void setApplicationIcon(String applicationIcon) {
- this.applicationIcon = applicationIcon;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- this.width = (Integer) values[1];
- this.height = (Integer) values[2];
- this.focusId = (String) values[3];
- this.applicationIcon = (String) values[4];
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[5];
- values[0] = super.saveState(context);
- values[1] = width;
- values[2] = height;
- values[3] = focusId;
- values[4] = applicationIcon;
- return values;
}
public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java Wed Apr 2 12:36:26 2008
@@ -21,34 +21,24 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
import org.apache.myfaces.tobago.TobagoConstants;
+import org.apache.myfaces.tobago.util.ComponentUtil;
import org.apache.myfaces.tobago.compat.FacesUtils;
import org.apache.myfaces.tobago.compat.InvokeOnComponent;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LEFT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TOP;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.ContextCallback;
+import javax.faces.component.UICommand;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import javax.faces.FacesException;
import java.io.IOException;
import java.util.Iterator;
-public class UIPopup extends UIPanelBase implements NamingContainer, AjaxComponent, InvokeOnComponent {
+public class AbstractUIPopup extends UIPanelBase implements NamingContainer, AjaxComponent, InvokeOnComponent {
- private static final Log LOG = LogFactory.getLog(UIPopup.class);
+ private static final Log LOG = LogFactory.getLog(AbstractUIPopup.class);
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Popup";
-
- private Integer width;
- private Integer height;
- private String left;
- private String top;
private boolean activated;
- private Boolean modal;
public void setActivated(boolean activated) {
this.activated = activated;
@@ -72,9 +62,9 @@
}
public boolean isRendered() {
- ValueBinding valueBinding = getValueBinding("rendered");
- if (valueBinding != null) {
- return (Boolean) valueBinding.getValue(getFacesContext());
+ if (FacesUtils.hasValueBindingOrValueExpression(this, "rendered")) {
+ return (Boolean)
+ FacesUtils.getValueFromValueBindingOrValueExpression(FacesContext.getCurrentInstance(), this, "rendered");
} else {
return isActivated() || isRedisplay();
}
@@ -87,7 +77,7 @@
private boolean isRedisplay() {
if (isSubmitted()) {
- UIPage page = ComponentUtil.findPage(getFacesContext(), this);
+ AbstractUIPage page = ComponentUtil.findPage(getFacesContext(), this);
String action = page.getActionId();
if (action != null) {
UIComponent command = page.findComponent(SEPARATOR_CHAR + action);
@@ -103,9 +93,6 @@
return activated;
}
- public void encodeBegin(FacesContext facesContext) throws IOException {
- super.encodeBegin(facesContext);
- }
public void processValidators(FacesContext context) {
if (isSubmitted()) {
@@ -137,110 +124,21 @@
}
public Object saveState(FacesContext context) {
- Object[] saveState = new Object[7];
+ Object[] saveState = new Object[2];
saveState[0] = super.saveState(context);
- saveState[1] = width;
- saveState[2] = height;
- saveState[3] = left;
- saveState[4] = top;
- saveState[5] = activated;
- saveState[6] = modal;
+ saveState[1] = activated;
return saveState;
}
public void restoreState(FacesContext context, Object savedState) {
Object[] values = (Object[]) savedState;
super.restoreState(context, values[0]);
- width = (Integer) values[1];
- height = (Integer) values[2];
- left = (String) values[3];
- top = (String) values[4];
- activated = (Boolean) values[5];
- modal = (Boolean) values[6];
- }
-
- public Integer getWidth() {
- if (width != null) {
- return width;
- }
- ValueBinding vb = getValueBinding(ATTR_WIDTH);
- if (vb != null) {
- return (Integer) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- public void setWidth(Integer width) {
- this.width = width;
- }
-
- public Integer getHeight() {
- if (height != null) {
- return height;
- }
- ValueBinding vb = getValueBinding(ATTR_HEIGHT);
- if (vb != null) {
- return (Integer) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- public void setHeight(Integer height) {
- this.height = height;
- }
-
- public String getLeft() {
- if (left != null) {
- return left;
- }
- ValueBinding vb = getValueBinding(ATTR_LEFT);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- public void setLeft(String left) {
- this.left = left;
- }
-
- public String getTop() {
- if (top != null) {
- return top;
- }
- ValueBinding vb = getValueBinding(ATTR_TOP);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- public void setTop(String top) {
- this.top = top;
+ activated = (Boolean) values[1];
}
- public boolean isModal() {
- if (modal != null) {
- return modal;
- }
- ValueBinding vb = getValueBinding(TobagoConstants.ATTR_MODAL);
- if (vb != null) {
- return (Boolean.TRUE.equals(vb.getValue(getFacesContext())));
- } else {
- return true;
- }
- }
-
- public void setModal(boolean modal) {
- this.modal = modal;
- }
private void addToPage() {
- UIPage page = ComponentUtil.findPage(getFacesContext(), this);
+ AbstractUIPage page = ComponentUtil.findPage(getFacesContext(), this);
if (page != null) {
page.getPopups().add(this);
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectBoolean.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectBoolean.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectBoolean.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectBoolean.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectBoolean.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectBoolean.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectBoolean.java Wed Apr 2 12:36:26 2008
@@ -17,38 +17,16 @@
* limitations under the License.
*/
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
import org.apache.myfaces.tobago.util.MessageFactory;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import javax.faces.application.FacesMessage;
/*
* Date: Jan 30, 2007
* Time: 8:16:45 AM
*/
-public class UISelectBoolean extends javax.faces.component.UISelectBoolean implements SupportsMarkup {
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.SelectBoolean";
-
- private String[] markup;
- private Integer tabIndex;
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- markup = (String[]) values[1];
- tabIndex = (Integer) values[2];
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[3];
- values[0] = super.saveState(context);
- values[1] = markup;
- values[2] = tabIndex;
- return values;
- }
+public abstract class AbstractUISelectBoolean extends javax.faces.component.UISelectBoolean implements SupportsMarkup {
public boolean isSelected() {
Object value = getSubmittedValue();
@@ -60,35 +38,6 @@
} else {
return value != null && Boolean.valueOf(value.toString());
}
- }
-
- public String[] getMarkup() {
- if (markup != null) {
- return markup;
- }
- return ComponentUtil.getMarkupBinding(getFacesContext(), this);
- }
-
- public void setMarkup(String[] markup) {
- this.markup = markup;
- }
-
- public Integer getTabIndex() {
- if (tabIndex != null) {
- return tabIndex;
- }
- ValueBinding vb = getValueBinding(ATTR_TAB_INDEX);
- if (vb != null) {
- Number number = (Number) vb.getValue(getFacesContext());
- if (number != null) {
- return Integer.valueOf(number.intValue());
- }
- }
- return null;
- }
-
- public void setTabIndex(Integer tabIndex) {
- this.tabIndex = tabIndex;
}
protected void validateValue(FacesContext context, Object convertedValue) {
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectBoolean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectBoolean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectMany.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectMany.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectMany.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectMany.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectMany.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectMany.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectMany.java Wed Apr 2 12:36:26 2008
@@ -19,86 +19,25 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import java.io.IOException;
-import java.util.List;
/*
* User: weber
* Date: May 31, 2005
* Time: 7:47:11 PM
*/
-public class UISelectMany extends javax.faces.component.UISelectMany implements SupportsMarkup {
+public abstract class AbstractUISelectMany extends javax.faces.component.UISelectMany implements SupportsMarkup {
@SuppressWarnings("UnusedDeclaration")
- private static final Log LOG = LogFactory.getLog(UISelectMany.class);
+ private static final Log LOG = LogFactory.getLog(AbstractUISelectMany.class);
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.SelectMany";
-
- private String[] markup;
- private Integer tabIndex;
-
- public Object[] getSelectedValues() {
- Object value = getValue();
- if (value instanceof List) {
- List list = (List) value;
- return list.toArray();
- } else {
- return (Object[]) value;
- }
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- markup = (String[]) values[1];
- tabIndex = (Integer) values[2];
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[3];
- values[0] = super.saveState(context);
- values[1] = markup;
- values[2] = tabIndex;
- return values;
- }
-
- public String[] getMarkup() {
- if (markup != null) {
- return markup;
- }
- return ComponentUtil.getMarkupBinding(getFacesContext(), this);
- }
-
- public void setMarkup(String[] markup) {
- this.markup = markup;
- }
public void encodeBegin(FacesContext facesContext) throws IOException {
// TODO change this should be renamed to DimensionUtils.prepare!!!
UILayout.getLayout(this).layoutBegin(facesContext, this);
super.encodeBegin(facesContext);
- }
-
- public Integer getTabIndex() {
- if (tabIndex != null) {
- return tabIndex;
- }
- ValueBinding vb = getValueBinding(ATTR_TAB_INDEX);
- if (vb != null) {
- Number number = (Number) vb.getValue(getFacesContext());
- if (number != null) {
- return Integer.valueOf(number.intValue());
- }
- }
- return null;
- }
-
- public void setTabIndex(Integer tabIndex) {
- this.tabIndex = tabIndex;
}
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectMany.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectMany.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectOne.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectOne.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectOne.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectOne.java Wed Apr 2 12:36:26 2008
@@ -17,12 +17,10 @@
* limitations under the License.
*/
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
import org.apache.myfaces.tobago.util.MessageFactory;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import java.io.IOException;
/*
@@ -30,29 +28,10 @@
* Date: May 31, 2005
* Time: 7:47:11 PM
*/
-public class UISelectOne extends javax.faces.component.UISelectOne implements SupportsMarkup {
+public abstract class AbstractUISelectOne extends javax.faces.component.UISelectOne implements SupportsMarkup {
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.SelectOne";
public static final String MESSAGE_VALUE_REQUIRED = "tobago.SelectOne.MESSAGE_VALUE_REQUIRED";
- private String[] markup;
- private Integer tabIndex;
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- markup = (String[]) values[1];
- tabIndex = (Integer) values[2];
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[3];
- values[0] = super.saveState(context);
- values[1] = markup;
- values[2] = tabIndex;
- return values;
- }
-
public void encodeBegin(FacesContext facesContext) throws IOException {
// TODO change this should be renamed to DimensionUtils.prepare!!!
UILayout.getLayout(this).layoutBegin(facesContext, this);
@@ -61,7 +40,6 @@
public void validate(FacesContext facesContext) {
if (isRequired()) {
-
Object submittedValue = getSubmittedValue();
if (submittedValue == null || "".equals(submittedValue)) {
FacesMessage facesMessage = MessageFactory.createFacesMessage(
@@ -72,34 +50,4 @@
}
super.validate(facesContext);
}
-
- public String[] getMarkup() {
- if (markup != null) {
- return markup;
- }
- return ComponentUtil.getMarkupBinding(getFacesContext(), this);
- }
-
- public void setMarkup(String[] markup) {
- this.markup = markup;
- }
-
- public Integer getTabIndex() {
- if (tabIndex != null) {
- return tabIndex;
- }
- ValueBinding vb = getValueBinding(ATTR_TAB_INDEX);
- if (vb != null) {
- Number number = (Number) vb.getValue(getFacesContext());
- if (number != null) {
- return Integer.valueOf(number.intValue());
- }
- }
- return null;
- }
-
- public void setTabIndex(Integer tabIndex) {
- this.tabIndex = tabIndex;
- }
-
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectOne.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISelectOne.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java Wed Apr 2 12:36:26 2008
@@ -19,23 +19,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMMEDIATE;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_HEIGHT;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_WIDTH;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_INDEX;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SWITCH_TYPE;
import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
import org.apache.myfaces.tobago.event.TabChangeEvent;
import org.apache.myfaces.tobago.event.TabChangeListener;
import org.apache.myfaces.tobago.event.TabChangeSource;
+import org.apache.myfaces.tobago.compat.FacesUtils;
import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
@@ -45,20 +43,12 @@
import java.util.ArrayList;
import java.util.List;
-public class UITabGroup extends UIPanelBase implements TabChangeSource, ActionSource, AjaxComponent {
+public abstract class AbstractUITabGroup extends UIPanelBase implements TabChangeSource, ActionSource, AjaxComponent {
- private static final Log LOG = LogFactory.getLog(UITabGroup.class);
+ private static final Log LOG = LogFactory.getLog(AbstractUITabGroup.class);
public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TabGroup";
- private Integer selectedIndex;
- private int renderedIndex;
- private String switchType;
- private Boolean immediate;
- private MethodBinding tabChangeListener = null;
- private MethodBinding action = null;
- private MethodBinding actionListener = null;
-
public static final String SWITCH_TYPE_CLIENT = "client";
public static final String SWITCH_TYPE_RELOAD_PAGE = "reloadPage";
public static final String SWITCH_TYPE_RELOAD_TAB = "reloadTab";
@@ -73,21 +63,6 @@
super.encodeBegin(facesContext);
}
- public void setImmediate(boolean immediate) {
- this.immediate = immediate;
- }
-
- public boolean isImmediate() {
- if (immediate != null) {
- return immediate;
- }
- ValueBinding vb = getValueBinding(ATTR_IMMEDIATE);
- if (vb != null) {
- return (!Boolean.FALSE.equals(vb.getValue(getFacesContext())));
- } else {
- return false;
- }
- }
public void queueEvent(FacesEvent event) {
if (this == event.getSource()) {
@@ -199,9 +174,8 @@
super.broadcast(facesEvent);
if (facesEvent instanceof TabChangeEvent && facesEvent.getComponent() == this) {
Integer index = ((TabChangeEvent) facesEvent).getNewTabIndex();
- ValueBinding vb = getValueBinding(ATTR_SELECTED_INDEX);
- if (vb != null) {
- vb.setValue(getFacesContext(), index);
+ if (FacesUtils.hasValueBindingOrValueExpression(this, ATTR_SELECTED_INDEX)) {
+ FacesUtils.setValueOfBindingOrExpression(getFacesContext(), index, this, ATTR_SELECTED_INDEX);
} else {
setSelectedIndex(index);
}
@@ -218,7 +192,7 @@
}
}
}
- MethodBinding actionListenerBinding = getActionListener();
+ MethodBinding actionListenerBinding = getActionListener();
if (actionListenerBinding != null) {
try {
actionListenerBinding.invoke(getFacesContext(), new Object[]{facesEvent});
@@ -240,13 +214,6 @@
}
}
- public void setTabChangeListener(MethodBinding tabStateChangeListener) {
- this.tabChangeListener = tabStateChangeListener;
- }
-
- public MethodBinding getTabChangeListener() {
- return tabChangeListener;
- }
public void addTabChangeListener(TabChangeListener listener) {
@@ -257,6 +224,7 @@
}
private boolean isClientType() {
+ String switchType = getSwitchType();
return (switchType == null || switchType.equals(SWITCH_TYPE_CLIENT));
}
@@ -268,90 +236,20 @@
return (TabChangeListener[]) getFacesListeners(TabChangeListener.class);
}
- public Object saveState(FacesContext context) {
- Object[] state = new Object[8];
- state[0] = super.saveState(context);
- state[1] = renderedIndex;
- state[2] = selectedIndex;
- state[3] = saveAttachedState(context, tabChangeListener);
- state[4] = saveAttachedState(context, action);
- state[5] = saveAttachedState(context, actionListener);
- state[6] = switchType;
- state[7] = immediate;
- return state;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- renderedIndex = (Integer) values[1];
- selectedIndex = (Integer) values[2];
- tabChangeListener = (MethodBinding) restoreAttachedState(context, values[3]);
- action = (MethodBinding) restoreAttachedState(context, values[4]);
- actionListener = (MethodBinding) restoreAttachedState(context, values[5]);
- switchType = (String) values[6];
- immediate = (Boolean) values[7];
- }
-
public int encodeAjax(FacesContext facesContext) throws IOException {
setRenderedIndex(getSelectedIndex());
return AjaxUtils.encodeAjaxComponent(facesContext, this);
}
- public int getSelectedIndex() {
- if (selectedIndex != null) {
- return selectedIndex;
- }
- ValueBinding vb = getValueBinding(ATTR_SELECTED_INDEX);
- if (vb != null) {
- Integer value = (Integer) vb.getValue(getFacesContext());
- if (value != null) {
- return value;
- }
- }
- return 0;
- }
-
- public void setSelectedIndex(int selectedIndex) {
- this.selectedIndex = selectedIndex;
- }
+ public abstract Integer getRenderedIndex();
- private void setRenderedIndex(int index) {
- renderedIndex = index;
- }
+ public abstract void setRenderedIndex(Integer index);
- public int getRenderedIndex() {
- return renderedIndex;
- }
-
- public String getSwitchType() {
- String value = null;
- if (switchType != null) {
- value = switchType;
- } else {
- ValueBinding vb = getValueBinding(ATTR_SWITCH_TYPE);
- if (vb != null) {
- value = (String) vb.getValue(FacesContext.getCurrentInstance());
- }
- }
+ public abstract Integer getSelectedIndex();
- if (SWITCH_TYPE_CLIENT.equals(value)
- || SWITCH_TYPE_RELOAD_PAGE.equals(value)
- || SWITCH_TYPE_RELOAD_TAB.equals(value)) {
- return value;
- } else if (value == null) {
- // return default
- return SWITCH_TYPE_CLIENT;
- } else {
- LOG.warn("Illegal value for attribute switchtype : " + switchType
- + " Using default value " + SWITCH_TYPE_CLIENT);
- return SWITCH_TYPE_CLIENT;
- }
- }
+ public abstract void setSelectedIndex(Integer index);
- public void setSwitchType(String switchType) {
- this.switchType = switchType;
- }
+ public abstract String getSwitchType();
private UIPanelBase getTab(int index) {
int i = 0;
@@ -373,34 +271,6 @@
return getTab(getRenderedIndex());
}
- /**
- * @since 1.1.0
- * @param action
- */
- public void setAction(MethodBinding action) {
- this.action = action;
- }
-
- /**
- * @since 1.1.0
- */
- public MethodBinding getAction() {
- return action;
- }
-
- /**
- * @since 1.1.0
- */
- public void setActionListener(MethodBinding actionListener) {
- this.actionListener = actionListener;
- }
-
- /**
- * @since 1.1.0
- */
- public MethodBinding getActionListener() {
- return actionListener;
- }
/**
* @since 1.1.0
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITimeInput.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITimeInput.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITimeInput.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITimeInput.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITimeInput.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITimeInput.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITimeInput.java Wed Apr 2 12:36:26 2008
@@ -24,18 +24,13 @@
import javax.faces.convert.Converter;
import javax.faces.convert.DateTimeConverter;
import static javax.faces.convert.DateTimeConverter.CONVERTER_ID;
-import javax.faces.el.ValueBinding;
import java.util.TimeZone;
/*
* Date: 10.02.2006
* Time: 20:50:49
*/
-public class UITimeInput extends javax.faces.component.UIInput {
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TimeInput";
-
- private Integer tabIndex;
+public class AbstractUITimeInput extends javax.faces.component.UIInput {
public Converter getConverter() {
Converter converter = super.getConverter();
@@ -50,36 +45,5 @@
setConverter(dateTimeConverter);
}
return converter;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- tabIndex = (Integer) values[1];
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[2];
- values[0] = super.saveState(context);
- values[1] = tabIndex;
- return values;
- }
-
- public Integer getTabIndex() {
- if (tabIndex != null) {
- return tabIndex;
- }
- ValueBinding vb = getValueBinding(ATTR_TAB_INDEX);
- if (vb != null) {
- Number number = (Number) vb.getValue(getFacesContext());
- if (number != null) {
- return Integer.valueOf(number.intValue());
- }
- }
- return null;
- }
-
- public void setTabIndex(Integer tabIndex) {
- this.tabIndex = tabIndex;
}
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITimeInput.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITimeInput.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIToolBar.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIToolBar.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIToolBar.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIToolBar.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIToolBar.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIToolBar.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIToolBar.java Wed Apr 2 12:36:26 2008
@@ -17,18 +17,12 @@
* limitations under the License.
*/
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ORIENTATION;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ICON_SIZE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL_POSITION;
-
-import javax.faces.el.ValueBinding;
-import javax.faces.context.FacesContext;
/*
* Date: 11.02.2006
* Time: 14:48:46
*/
-public class UIToolBar extends javax.faces.component.UIPanel {
+public abstract class AbstractUIToolBar extends javax.faces.component.UIPanel {
public static final String LABEL_BOTTOM = "bottom";
public static final String LABEL_RIGHT = "right";
@@ -41,76 +35,4 @@
public static final String ORIENTATION_LEFT = "left";
public static final String ORIENTATION_RIGHT = "right";
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.ToolBar";
-
- private String labelPosition;
- private String iconSize;
- private String orientation;
-
- public String getLabelPosition() {
- if (labelPosition != null) {
- return labelPosition;
- }
- ValueBinding vb = getValueBinding(ATTR_LABEL_POSITION);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return LABEL_BOTTOM;
- }
- }
-
- public void setLabelPosition(String labelPosition) {
- this.labelPosition = labelPosition;
- }
-
- public String getIconSize() {
- if (iconSize != null) {
- return iconSize;
- }
- ValueBinding vb = getValueBinding(ATTR_ICON_SIZE);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return ICON_SMALL;
- }
- }
-
- public void setIconSize(String iconSize) {
- this.iconSize = iconSize;
- }
-
-
- public String getOrientation() {
- if (orientation != null) {
- return orientation;
- }
- ValueBinding vb = getValueBinding(ATTR_ORIENTATION);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return ORIENTATION_LEFT;
- }
-
- }
-
- public void setOrientation(String orientation) {
- this.orientation = orientation;
- }
-
- public Object saveState(FacesContext context) {
- Object[] saveState = new Object[4];
- saveState[0] = super.saveState(context);
- saveState[1] = labelPosition;
- saveState[2] = iconSize;
- saveState[3] = orientation;
- return saveState;
- }
-
- public void restoreState(FacesContext context, Object savedState) {
- Object[] values = (Object[]) savedState;
- super.restoreState(context, values[0]);
- labelPosition = (String) values[1];
- iconSize = (String) values[2];
- orientation = (String) values[3];
- }
}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIToolBar.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIToolBar.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Cell.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Cell.java?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Cell.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Cell.java Wed Apr 2 12:36:26 2008
@@ -0,0 +1,21 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public interface Cell {
+}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Cell.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Cell.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ColumnEvent.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ColumnEvent.java?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ColumnEvent.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ColumnEvent.java Wed Apr 2 12:36:26 2008
@@ -0,0 +1,21 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public interface ColumnEvent {
+}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ColumnEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ColumnEvent.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/CreateComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/CreateComponentUtils.java?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/CreateComponentUtils.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/CreateComponentUtils.java Wed Apr 2 12:36:26 2008
@@ -0,0 +1,87 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.internal.taglib.TagUtils;
+import org.apache.myfaces.tobago.TobagoConstants;
+
+import javax.faces.component.*;
+import javax.faces.component.UICommand;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+public class CreateComponentUtils {
+ public static UIComponent createComponent(String componentType, String rendererType) {
+ final FacesContext facesContext = FacesContext.getCurrentInstance();
+ return createComponent(facesContext, componentType, rendererType);
+ }
+
+ public static UIComponent createComponent(FacesContext facesContext, String componentType, String rendererType) {
+ UIComponent component = facesContext.getApplication().createComponent(componentType);
+ component.setRendererType(rendererType);
+ return component;
+ }
+
+ public static UIColumn createTextColumn(String label, String sortable, String align, String value) {
+ UIComponent text = createComponent(UIOutput.COMPONENT_TYPE, TobagoConstants.RENDERER_TYPE_OUT);
+ TagUtils.setStringProperty(text, TobagoConstants.ATTR_VALUE, value);
+ TagUtils.setBooleanProperty(text, TobagoConstants.ATTR_CREATE_SPAN, "false");
+ TagUtils.setBooleanProperty(text, TobagoConstants.ATTR_ESCAPE, "false");
+ return createColumn(label, sortable, align, text);
+ }
+
+ public static UIColumn createColumn(String label, String sortable, String align, UIComponent child) {
+ UIColumn column = createColumn(label, sortable, align);
+ column.getChildren().add(child);
+ return column;
+ }
+
+ public static UIColumn createColumn(String label, String sortable, String align) {
+ UIColumn column = (UIColumn) createComponent(UIColumn.COMPONENT_TYPE, null);
+ TagUtils.setStringProperty(column, TobagoConstants.ATTR_LABEL, label);
+ TagUtils.setBooleanProperty(column, TobagoConstants.ATTR_SORTABLE, sortable);
+ TagUtils.setBooleanProperty(column, TobagoConstants.ATTR_ALIGN, align);
+ return column;
+ }
+
+ public static UIMenuSelectOne createUIMenuSelectOneFacet(FacesContext facesContext,
+ javax.faces.component.UICommand command) {
+ UIMenuSelectOne radio = null;
+ final ValueBinding valueBinding = command.getValueBinding(TobagoConstants.ATTR_VALUE);
+ if (valueBinding != null) {
+ radio = (UIMenuSelectOne) createComponent(facesContext, UIMenuSelectOne.COMPONENT_TYPE,
+ TobagoConstants.RENDERER_TYPE_SELECT_ONE_RADIO);
+ command.getFacets().put(org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS, radio);
+ radio.setValueBinding(org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE, valueBinding);
+ }
+ return radio;
+ }
+
+ public static UIComponent createUISelectBooleanFacet(FacesContext facesContext, UICommand command) {
+ UIComponent checkbox = createComponent(facesContext, AbstractUISelectBoolean.COMPONENT_TYPE,
+ TobagoConstants.RENDERER_TYPE_SELECT_BOOLEAN_CHECKBOX);
+ command.getFacets().put(TobagoConstants.FACET_ITEMS, checkbox);
+ ValueBinding valueBinding = command.getValueBinding(TobagoConstants.ATTR_VALUE);
+ if (valueBinding != null) {
+ checkbox.setValueBinding(TobagoConstants.ATTR_VALUE, valueBinding);
+ } else {
+ checkbox.getAttributes().put(TobagoConstants.ATTR_VALUE, command.getAttributes().get(TobagoConstants.ATTR_VALUE));
+ }
+ return checkbox;
+ }
+}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/CreateComponentUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/CreateComponentUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Form.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Form.java?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Form.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Form.java Wed Apr 2 12:36:26 2008
@@ -0,0 +1,22 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public interface Form {
+}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Form.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Form.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java Wed Apr 2 12:36:26 2008
@@ -32,10 +32,10 @@
import javax.faces.component.UIInput;
import javax.faces.component.UIOutput;
import javax.faces.component.UISelectBoolean;
+import javax.faces.component.UICommand;
+import javax.faces.component.UISelectOne;
+import javax.faces.component.UISelectMany;
import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
import javax.faces.el.ValueBinding;
import javax.faces.model.DataModel;
@@ -51,133 +51,129 @@
* Date: Mar 7, 2005
* Time: 4:01:27 PM
*/
-public class Sorter extends MethodBinding {
+public class Sorter {
private static final Log LOG = LogFactory.getLog(Sorter.class);
private Comparator comparator;
- public Object invoke(FacesContext facesContext, Object[] aobj)
- throws EvaluationException {
- if (aobj[0] instanceof SortActionEvent) {
- SortActionEvent sortEvent = (SortActionEvent) aobj[0];
- if (LOG.isDebugEnabled()) {
- LOG.debug("sorterId = " + sortEvent.getComponent().getId());
- }
- UIColumn column = sortEvent.getColumn();
- UIData data = sortEvent.getSheet();
-
- Object value = data.getValue();
- if (value instanceof DataModel) {
- value = ((DataModel) value).getWrappedData();
- }
- SheetState sheetState = data.getSheetState(facesContext);
-
- Comparator actualComparator = null;
-
- if (value instanceof List || value instanceof Object[]) {
- String sortProperty;
-
- try {
-
- UIComponent child = getFirstSortableChild(column.getChildren());
- if (child != null) {
- ValueBinding valueBinding = child.getValueBinding("value");
- String var = data.getVar();
-
- if (FacesUtils.hasValueBindingOrValueExpression(child, "value")) {
- String expressionString = FacesUtils.getExpressionString(child, "value");
- if (isSimpleProperty(expressionString)) {
- if (expressionString.startsWith("#{")
- && expressionString.endsWith("}")) {
- expressionString =
- expressionString.substring(2,
- expressionString.length() - 1);
- }
- sortProperty = expressionString.substring(var.length() + 1);
-
- actualComparator = new BeanComparator(
- sortProperty, comparator, !sheetState.isAscending());
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Sort property is " + sortProperty);
- }
- } else {
- actualComparator = new ValueBindingComparator(facesContext, var,
- valueBinding, !sheetState.isAscending(), comparator);
+ public void perform(SortActionEvent sortEvent) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("sorterId = " + sortEvent.getComponent().getId());
+ }
+ UIColumn column = sortEvent.getColumn();
+ AbstractUIData data = (AbstractUIData) sortEvent.getComponent();
+
+ Object value = data.getValue();
+ if (value instanceof DataModel) {
+ value = ((DataModel) value).getWrappedData();
+ }
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SheetState sheetState = data.getSheetState(facesContext);
+
+ Comparator actualComparator = null;
+
+ if (value instanceof List || value instanceof Object[]) {
+ String sortProperty;
+
+ try {
+
+ UIComponent child = getFirstSortableChild(column.getChildren());
+ if (child != null) {
+ ValueBinding valueBinding = child.getValueBinding("value");
+ String var = data.getVar();
+
+ if (FacesUtils.hasValueBindingOrValueExpression(child, "value")) {
+ String expressionString = FacesUtils.getExpressionString(child, "value");
+ if (isSimpleProperty(expressionString)) {
+ if (expressionString.startsWith("#{")
+ && expressionString.endsWith("}")) {
+ expressionString =
+ expressionString.substring(2,
+ expressionString.length() - 1);
}
- }
+ sortProperty = expressionString.substring(var.length() + 1);
- } else {
- LOG.error("No sorting performed. Value is not instanceof List or Object[]!");
- unsetSortableAttribute(column);
- return null;
- }
- } catch (Exception e) {
- LOG.error("Error while extracting sortMethod :" + e.getMessage(), e);
- if (column != null) {
- unsetSortableAttribute(column);
+ actualComparator = new BeanComparator(
+ sortProperty, comparator, !sheetState.isAscending());
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Sort property is " + sortProperty);
+ }
+ } else {
+ actualComparator = new ValueBindingComparator(facesContext, var,
+ valueBinding, !sheetState.isAscending(), comparator);
+ }
}
- return null;
+
+ } else {
+ LOG.error("No sorting performed. Value is not instanceof List or Object[]!");
+ unsetSortableAttribute(column);
+ return;
}
+ } catch (Exception e) {
+ LOG.error("Error while extracting sortMethod :" + e.getMessage(), e);
+ if (column != null) {
+ unsetSortableAttribute(column);
+ }
+ return;
+ }
- // TODO: locale / comparator parameter?
- // don't compare numbers with Collator.getInstance() comparator
+ // TODO: locale / comparator parameter?
+ // don't compare numbers with Collator.getInstance() comparator
// Comparator comparator = Collator.getInstance();
// comparator = new RowComparator(ascending, method);
- // memorize selected rows
- List<Object> selectedDataRows = null;
- if (sheetState.getSelectedRows() != null && sheetState.getSelectedRows().size() > 0) {
- selectedDataRows = new ArrayList<Object>(sheetState.getSelectedRows().size());
- Object dataRow;
- for (Integer index : sheetState.getSelectedRows()) {
- if (value instanceof List) {
- dataRow = ((List) value).get(index);
- } else {
- dataRow = ((Object[]) value)[index];
- }
- selectedDataRows.add(dataRow);
+ // memorize selected rows
+ List<Object> selectedDataRows = null;
+ if (sheetState.getSelectedRows() != null && sheetState.getSelectedRows().size() > 0) {
+ selectedDataRows = new ArrayList<Object>(sheetState.getSelectedRows().size());
+ Object dataRow;
+ for (Integer index : sheetState.getSelectedRows()) {
+ if (value instanceof List) {
+ dataRow = ((List) value).get(index);
+ } else {
+ dataRow = ((Object[]) value)[index];
}
+ selectedDataRows.add(dataRow);
}
-
- // do sorting
- if (value instanceof List) {
- Collections.sort((List) value, actualComparator);
- } else { // value is instanceof Object[]
- Arrays.sort((Object[]) value, actualComparator);
- }
+ }
- // restore selected rows
- if (selectedDataRows != null) {
- sheetState.getSelectedRows().clear();
- for (Object dataRow : selectedDataRows) {
- int index = -1;
- if (value instanceof List) {
- for (int i = 0; i < ((List) value).size() && index < 0; i++) {
- if (dataRow == ((List) value).get(i)) {
- index = i;
- }
- }
- } else {
- for (int i = 0; i < ((Object[]) value).length && index < 0; i++) {
- if (dataRow == ((Object[]) value)[i]) {
- index = i;
- }
+ // do sorting
+ if (value instanceof List) {
+ Collections.sort((List) value, actualComparator);
+ } else { // value is instanceof Object[]
+ Arrays.sort((Object[]) value, actualComparator);
+ }
+
+ // restore selected rows
+ if (selectedDataRows != null) {
+ sheetState.getSelectedRows().clear();
+ for (Object dataRow : selectedDataRows) {
+ int index = -1;
+ if (value instanceof List) {
+ for (int i = 0; i < ((List) value).size() && index < 0; i++) {
+ if (dataRow == ((List) value).get(i)) {
+ index = i;
}
}
- if (index >= 0) {
- sheetState.getSelectedRows().add(index);
+ } else {
+ for (int i = 0; i < ((Object[]) value).length && index < 0; i++) {
+ if (dataRow == ((Object[]) value)[i]) {
+ index = i;
+ }
}
}
+ if (index >= 0) {
+ sheetState.getSelectedRows().add(index);
+ }
}
-
- } else { // DataModel?, ResultSet, Result or Object
- LOG.warn("Sorting not supported for type "
- + (value != null ? value.getClass().toString() : "null"));
}
+
+ } else { // DataModel?, ResultSet, Result or Object
+ LOG.warn("Sorting not supported for type "
+ + (value != null ? value.getClass().toString() : "null"));
}
- return null;
}
private boolean isSimpleProperty(String expressionString) {
@@ -210,11 +206,6 @@
}
}
return child;
- }
-
- public Class getType(FacesContext facescontext)
- throws MethodNotFoundException {
- return String.class;
}
public Comparator getComparator() {
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/SupportsRenderedPartially.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/SupportsRenderedPartially.java?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/SupportsRenderedPartially.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/SupportsRenderedPartially.java Wed Apr 2 12:36:26 2008
@@ -0,0 +1,26 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public interface SupportsRenderedPartially {
+
+ String[] getRenderedPartially();
+
+ void setRenderedPartially(String[] renderedPartially);
+}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/SupportsRenderedPartially.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/SupportsRenderedPartially.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL