Author: vbaranov
Date: 2008-03-25 09:42:38 -0400 (Tue, 25 Mar 2008)
New Revision: 7164
Modified:
trunk/ui/core/src/main/config/component/mediaOutput.xml
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
Log:
http://jira.jboss.com/jira/browse/RF-2489
Modified: trunk/ui/core/src/main/config/component/mediaOutput.xml
===================================================================
--- trunk/ui/core/src/main/config/component/mediaOutput.xml 2008-03-25 13:29:47 UTC (rev
7163)
+++ trunk/ui/core/src/main/config/component/mediaOutput.xml 2008-03-25 13:42:38 UTC (rev
7164)
@@ -130,7 +130,7 @@
</description>
</property>
<property elonly="true">
- <name>createContent</name>
+ <name>createContentExpression</name>
<classname>javax.el.MethodExpression</classname>
<description>
<![CDATA[
@@ -142,6 +142,19 @@
java.io.OutputStream,java.lang.Object
</methodargs>
</property>
+ <property elonly="true">
+ <name>createContent</name>
+ <classname>javax.faces.el.MethodBinding</classname>
+ <description>
+ <![CDATA[
+ Method call expression to send generated resource to OutputStream. It must have
two parameter with a type of java.io.OutputStream
+ and java.lang.Object ( deserialized value of data attribute )
+ ]]>
+ </description>
+ <methodargs>
+ java.io.OutputStream,java.lang.Object
+ </methodargs>
+ </property>
<property>
<name>converter</name>
<classname>javax.faces.convert.Converter</classname>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java 2008-03-25
13:29:47 UTC (rev 7163)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java 2008-03-25
13:42:38 UTC (rev 7164)
@@ -21,15 +21,21 @@
package org.ajax4jsf.component;
+import javax.el.MethodExpression;
+
import javax.faces.component.UIOutput;
+import javax.faces.el.MethodBinding;
-import org.ajax4jsf.resource.ResourceComponent;
+import org.ajax4jsf.resource.ResourceComponent2;
+import org.richfaces.webapp.taglib.MethodBindingMethodExpressionAdaptor;
+import org.richfaces.webapp.taglib.MethodExpressionMethodBindingAdaptor;
+
/**
* @author shura
*
*/
-public abstract class UIMediaOutput extends UIOutput implements ResourceComponent {
+public abstract class UIMediaOutput extends UIOutput implements ResourceComponent2 {
public static final String COMPONENT_TYPE = "org.ajax4jsf.MMedia";
@@ -57,5 +63,47 @@
*/
public abstract void setElement(String newvalue);
+ /**
+ * Get EL binding to method in user bean to send resource. Method will
+ * called with two parameters - restored data object and servlet output
+ * stream.
+ *
+ * @return MethodBinding to createContent
+ */
+ public MethodBinding getCreateContent() {
+ MethodBinding result = null;
+ MethodExpression me = getCreateContentExpression();
+ if (me != null) {
+ // if the MethodExpression is an instance of our private
+ // wrapper class.
+ if (me.getClass().equals(MethodExpressionMethodBindingAdaptor.class)) {
+ result = ((MethodExpressionMethodBindingAdaptor) me).getBinding();
+ } else {
+ // otherwise, this is a real MethodExpression. Wrap it
+ // in a MethodBinding.
+ result = new MethodBindingMethodExpressionAdaptor(me);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Set EL binding to method in user bean to send resource. Method will
+ * called with two parameters - restored data object and servlet output
+ * stream.
+ *
+ * @param newvalue - new value of createContent method binding
+ */
+ public void setCreateContent(MethodBinding newvalue) {
+ MethodExpressionMethodBindingAdaptor adapter;
+ if (newvalue != null) {
+ adapter = new MethodExpressionMethodBindingAdaptor(newvalue);
+ setCreateContentExpression(adapter);
+ } else {
+ setCreateContentExpression(null);
+ }
+ }
+
}
Modified:
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2008-03-25
13:29:47 UTC (rev 7163)
+++
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2008-03-25
13:42:38 UTC (rev 7164)
@@ -109,9 +109,8 @@
* @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
java.lang.Object)
*/
public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIMediaOutput) instance)
- .setCreateContent(this._send.getMethodExpression(ctx, null,
- MMEDIA_ACTION_SIG));
+ ((UIMediaOutput)
instance).setCreateContentExpression(this._send.getMethodExpression(ctx, null,
+ MMEDIA_ACTION_SIG));
}
}