You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ha...@apache.org on 2009/01/29 20:30:04 UTC
svn commit: r738978 -
/myfaces/commons/trunk/myfaces-commons-components/src/main/java/org/apache/myfaces/commons/exporter/FaceletsExporterActionListenerTag.java
Author: hazems
Date: Thu Jan 29 19:30:04 2009
New Revision: 738978
URL: http://svn.apache.org/viewvc?rev=738978&view=rev
Log:
Solving the https://issues.apache.org/jira/browse/MFCOMMONS-3
Adding the Facelets TagHandler for the exportActionListener.
Added:
myfaces/commons/trunk/myfaces-commons-components/src/main/java/org/apache/myfaces/commons/exporter/FaceletsExporterActionListenerTag.java
Added: myfaces/commons/trunk/myfaces-commons-components/src/main/java/org/apache/myfaces/commons/exporter/FaceletsExporterActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-components/src/main/java/org/apache/myfaces/commons/exporter/FaceletsExporterActionListenerTag.java?rev=738978&view=auto
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-components/src/main/java/org/apache/myfaces/commons/exporter/FaceletsExporterActionListenerTag.java (added)
+++ myfaces/commons/trunk/myfaces-commons-components/src/main/java/org/apache/myfaces/commons/exporter/FaceletsExporterActionListenerTag.java Thu Jan 29 19:30:04 2009
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.commons.exporter;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+import com.sun.facelets.tag.jsf.ComponentSupport;
+
+/**
+ * The (FaceletsExporterActionListenerTag) is responsible for handling the
+ * ExporterActionListener Tag in Facelets.
+ */
+public class FaceletsExporterActionListenerTag extends TagHandler
+{
+
+ private final TagAttribute _for;
+
+ private final TagAttribute _fileType;
+
+ private final TagAttribute _fileName;
+
+ public FaceletsExporterActionListenerTag(TagConfig tagConfig)
+ {
+ super(tagConfig);
+ this._for = getRequiredAttribute(ExporterActionListener.FOR_KEY);
+ this._fileType = getRequiredAttribute(ExporterActionListener.FILE_TYPE_KEY);
+ this._fileName = getRequiredAttribute(ExporterActionListener.FILENAME_KEY);
+ }
+
+ public void apply(FaceletContext faceletContext, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException
+ {
+ if (ComponentSupport.isNew(parent))
+ {
+ ValueExpression forVE = _for.getValueExpression(faceletContext,
+ Object.class);
+ ValueExpression fileTypeVE = _fileType.getValueExpression(
+ faceletContext, Object.class);
+ ValueExpression fileNameVE = _fileName.getValueExpression(
+ faceletContext, Object.class);
+
+ ActionSource actionSource = (ActionSource) parent;
+ actionSource.addActionListener(new ExporterActionListener(
+ (String) forVE.getValue(faceletContext),
+ (String) fileTypeVE.getValue(faceletContext),
+ (String) fileNameVE.getValue(faceletContext)));
+ }
+ }
+}