You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/03/16 08:55:47 UTC
svn commit: r923613 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/event/
core/src/main/java/org/apache/myfaces/tobago/renderkit/
extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/
theme/scarborough/src/main/...
Author: lofwyr
Date: Tue Mar 16 07:55:46 2010
New Revision: 923613
URL: http://svn.apache.org/viewvc?rev=923613&view=rev
Log:
clean up
Added:
myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/
myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java (contents, props changed)
- copied, changed from r923272, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
Removed:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SheetUtils.java
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageAction.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetPageCommandRenderer.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageAction.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageAction.java?rev=923613&r1=923612&r2=923613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageAction.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageAction.java Tue Mar 16 07:55:46 2010
@@ -17,6 +17,9 @@ package org.apache.myfaces.tobago.event;
* limitations under the License.
*/
+import java.util.HashMap;
+import java.util.Map;
+
public enum PageAction {
/**
@@ -58,4 +61,29 @@ public enum PageAction {
public String getToken() {
return token;
}
+
+ private static final Map<String, PageAction> MAPPING;
+
+ static {
+ MAPPING = new HashMap<String, PageAction>();
+
+ for (PageAction action : PageAction.values()) {
+ MAPPING.put(action.getToken(), action);
+ }
+ }
+
+ /**
+ *
+ * @param name Name of the PageAction
+ * @return The matching page action (can't be null).
+ * @throws IllegalArgumentException When the name doesn't match any PageAction.
+ */
+ public static PageAction parse(String name) throws IllegalArgumentException {
+ PageAction value = MAPPING.get(name);
+ if (value != null) {
+ return value;
+ } else {
+ throw new IllegalArgumentException("Unknown name for PageAction: '" + name + "'");
+ }
+ }
}
Copied: myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java (from r923272, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java?p2=myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java&r1=923272&r2=923613&rev=923613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java (original)
+++ myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java Tue Mar 16 07:55:46 2010
@@ -17,13 +17,13 @@ package org.apache.myfaces.tobago.event;
* limitations under the License.
*/
-import java.util.Map;
import java.util.HashMap;
+import java.util.Map;
-/*
- * Date: 24.04.2006
- * Time: 21:13:06
+/**
+ * @deprecated use {@link PageAction.parse()}
*/
+@Deprecated
public class PageActionUtil {
private static final Map<String, PageAction> MAPPING;
Propchange: myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetPageCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetPageCommandRenderer.java?rev=923613&r1=923612&r2=923613&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetPageCommandRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetPageCommandRenderer.java Tue Mar 16 07:55:46 2010
@@ -19,20 +19,52 @@ package org.apache.myfaces.tobago.render
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import org.apache.myfaces.tobago.renderkit.SheetUtils;
+import org.apache.myfaces.tobago.event.PageAction;
+import org.apache.myfaces.tobago.event.PageActionEvent;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-
+import java.util.Map;
public class SheetPageCommandRenderer extends LinkRenderer {
private static final Log LOG = LogFactory.getLog(SheetPageCommandRenderer.class);
- public static final String PAGE_RENDERER_TYPE = "SheetPageCommand";
-
+ @Override
public void decode(FacesContext facesContext, UIComponent component) {
- SheetUtils.decode(facesContext, component);
+ String actionId = ComponentUtils.findPage(facesContext, component).getActionId();
+ String clientId = component.getClientId(facesContext);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("actionId = '" + actionId + "'");
+ LOG.debug("clientId = '" + clientId + "'");
+ }
+ if (actionId != null && actionId.equals(clientId)) {
+
+ PageAction action;
+ try {
+ action = PageAction.parse(component.getId());
+ } catch (Exception e) {
+ LOG.error("Illegal value for PageAction :" + component.getId());
+ return;
+ }
+ PageActionEvent event = new PageActionEvent(component.getParent(), action);
+
+ switch (action) {
+ case TO_PAGE:
+ case TO_ROW:
+ Map map = facesContext.getExternalContext().getRequestParameterMap();
+ Object value = map.get(clientId + ComponentUtils.SUB_SEPARATOR + "value");
+ try {
+ event.setValue(Integer.parseInt((String) value));
+ } catch (NumberFormatException e) {
+ LOG.error("Can't parse integer value for action " + action.name() + ": " + value);
+ }
+ break;
+ default:
+ // nothing more to do
+ }
+ component.queueEvent(event);
+ }
}
}