JBoss Rich Faces SVN: r15195 - in branches/community/3.3.X/ui/simpleTogglePanel/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-08-18 07:02:59 -0400 (Tue, 18 Aug 2009)
New Revision: 15195
Modified:
branches/community/3.3.X/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
branches/community/3.3.X/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
Log:
simpleTogglePanel: doesn't became collapsed in ajax and server mode.
https://jira.jboss.org/jira/browse/RF-7704
Modified: branches/community/3.3.X/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
===================================================================
--- branches/community/3.3.X/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2009-08-18 10:06:11 UTC (rev 15194)
+++ branches/community/3.3.X/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2009-08-18 11:02:59 UTC (rev 15195)
@@ -39,6 +39,7 @@
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.UISimpleTogglePanel;
+import org.richfaces.component.util.HtmlUtil;
import org.richfaces.event.SimpleToggleEvent;
import org.richfaces.event.SimpleTogglePanelSwitchEvent;
@@ -182,8 +183,8 @@
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
UISimpleTogglePanel comp = (UISimpleTogglePanel) component;
- if (!(((comp.getSwitchType() == null) || (comp.getSwitchType().equals(UISimpleTogglePanel.CLIENT_SWITCH_TYPE) != true)) && (!comp.isOpened())))
- {
+ String switchType = comp.getSwitchType();
+ if (UISimpleTogglePanel.CLIENT_SWITCH_TYPE.equals(switchType) || comp.isOpened()) {
super.encodeChildren(context, component);
}
}
@@ -199,8 +200,9 @@
String width = convertToString(component.getAttributes().get("width"));
if (!isEmpty(width)) {
width = "width: " + convertToString(width);
- style = width + (isEmpty(style) ? ";" : "; " + style + ";");
}
+
+ style = HtmlUtil.concatStyles(style, width);
if (!isEmpty(style)) {
getUtils().writeAttribute(writer, "style", style);
}
@@ -230,17 +232,17 @@
getUtils().writeAttribute(writer, "class", "rich-stglpanel-body " + convertToString(component.getAttributes().get("bodyClass")) );
getUtils().writeAttribute(writer, "id", convertToString(clientId) + "_body" );
- String display = convertToString(component.getAttributes().get("display"));
- if (!isEmpty(display)) {
- display = "display: " + convertToString(display) + "; ";
+ String display = "";
+ if (!component.isOpened()) {
+ display = "display: none";
}
String height = convertToString(component.getAttributes().get("height"));
if (!isEmpty(height)) {
- height = "height: " + convertToString(component.getAttributes().get("height")) + ";";
+ height = "height: " + height;
}
- String style = display + height;
+ String style = HtmlUtil.concatStyles(display, height);
if (!isEmpty(style)) {
getUtils().writeAttribute(writer, "style", style);
}
Modified: branches/community/3.3.X/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
===================================================================
--- branches/community/3.3.X/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2009-08-18 10:06:11 UTC (rev 15194)
+++ branches/community/3.3.X/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2009-08-18 11:02:59 UTC (rev 15195)
@@ -88,7 +88,6 @@
{
result = eventFunction.call(element, eventObj);
}
- catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName + "]"); }
}
@@ -142,9 +141,13 @@
var thePanel = this.panels.get(panelId);
if (thePanel.status == "true") {
- return thePanel.invokeEvent("collapse",event,"true",element);
+ var res = thePanel.invokeEvent("collapse",event,"true",element);
+ Element.hide(panelId+"_body");
+ return res
} else {
- return thePanel.invokeEvent("expand",event,"false",element);
+ var res = thePanel.invokeEvent("expand",event,"false",element);
+ Element.show(panelId+"_body");
+ return res
}
}
15 years, 4 months
JBoss Rich Faces SVN: r15194 - root/framework/trunk/api/src/main/java/org/ajax4jsf/resource.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-18 06:06:11 -0400 (Tue, 18 Aug 2009)
New Revision: 15194
Modified:
root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java
Log:
Big A1 components check-in
Modified: root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java 2009-08-18 10:06:02 UTC (rev 15193)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java 2009-08-18 10:06:11 UTC (rev 15194)
@@ -49,12 +49,14 @@
* Get Last modified date for target .
* @return
*/
+ @Deprecated
public abstract Date getLastModified();
/**
* Set Last modified for target .
* @param newvalue
*/
+ @Deprecated
public abstract void setLastModified(Date newvalue);
@@ -62,12 +64,14 @@
* Get Expiration time for target .
* @return
*/
+ @Deprecated
public abstract Date getExpires();
/**
* Set Expiration time for target .
* @param newvalue
*/
+ @Deprecated
public abstract void setExpires(Date newvalue);
@@ -87,12 +91,14 @@
* Get session-avare flag for resource.
* @return true if resource depend of client session. If false, no JSESSIONID encoded in URI
*/
+ @Deprecated
public abstract boolean isSession();
/**
* Set session-avare flag for resource.
* @param newvalue
*/
+ @Deprecated
public abstract void setSession(boolean newvalue);
/**
15 years, 4 months
JBoss Rich Faces SVN: r15193 - in root/framework/trunk/impl/src/main: resources/META-INF/resources/richfaces.js and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-18 06:06:02 -0400 (Tue, 18 Aug 2009)
New Revision: 15193
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js
Log:
Big A1 components check-in
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-18 09:41:53 UTC (rev 15192)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-18 10:06:02 UTC (rev 15193)
@@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
@@ -69,7 +70,7 @@
/**
* Name Javasript function for submit AJAX request
*/
- public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
+ public static final String AJAX_FUNCTION_NAME = "RichFaces.ajax";
/**
* Attribute for keep clientId of status component
@@ -286,7 +287,7 @@
public static Map<String, Object> buildEventOptions(FacesContext facesContext,
UIComponent component) {
- Map<String,Object> options = new HashMap<String, Object>();
+ Map<String,Object> options = new LinkedHashMap<String, Object>();
appendParameters(facesContext, component, options);
String clientId = component.getClientId(facesContext);
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js 2009-08-18 09:41:53 UTC (rev 15192)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js 2009-08-18 10:06:02 UTC (rev 15193)
@@ -228,6 +228,7 @@
complete: function(xhr) {
var isPushActive = !!pushTracker[pushId];
+ //TODO may someone wish to stop push from dataavailable handler?
delete pushTracker[pushId];
if (xhr.status == 200 && xhr.getResponseHeader("Ajax-Push-Status") == "READY") {
15 years, 4 months
JBoss Rich Faces SVN: r15192 - in root/examples/trunk/components/core-demo: src/main/java/org/richfaces/demo and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-18 05:41:53 -0400 (Tue, 18 Aug 2009)
New Revision: 15192
Added:
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/DynamicExecuteBean.java
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/MediaOutputBean.java
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/RequestBean.java
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/TimeBean.java
root/examples/trunk/components/core-demo/src/main/resources/org/
root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/
root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/
root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/richfaces-twitter.jpg
root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/richfaces.jpg
root/examples/trunk/components/core-demo/src/main/webapp/dynamicExecute.xhtml
root/examples/trunk/components/core-demo/src/main/webapp/function.xhtml
root/examples/trunk/components/core-demo/src/main/webapp/mediaOutput.xhtml
root/examples/trunk/components/core-demo/src/main/webapp/outputPanel.xhtml
root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml
Modified:
root/examples/trunk/components/core-demo/pom.xml
root/examples/trunk/components/core-demo/src/main/webapp/index.xhtml
Log:
Big A1 components check-in - examples
Modified: root/examples/trunk/components/core-demo/pom.xml
===================================================================
--- root/examples/trunk/components/core-demo/pom.xml 2009-08-18 09:40:41 UTC (rev 15191)
+++ root/examples/trunk/components/core-demo/pom.xml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -17,10 +17,10 @@
<name>RichFaces core demo</name>
<dependencies>
- <!-- dependency>
+ <dependency>
<groupId>org.richfaces.ui.components</groupId>
<artifactId>${example.componentName}-ui</artifactId>
- </dependency -->
+ </dependency>
<dependency>
<groupId>org.jboss.cache</groupId>
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/DynamicExecuteBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/DynamicExecuteBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/DynamicExecuteBean.java 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,86 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.model.SelectItem;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean(name = "dynamicExecuteBean")
+@SessionScoped
+public class DynamicExecuteBean {
+
+ private static final SelectItem[] POSSIBLE_EXECUTE_OPTIONS = new SelectItem[] {
+ new SelectItem(null, "default"),
+ new SelectItem("@none"),
+ new SelectItem("@this"),
+ new SelectItem("@form"),
+ new SelectItem("formId"),
+ new SelectItem("anotherFormId"),
+ new SelectItem("@all")
+ };
+
+ private int actionsCounter = 0;
+
+ private Object execute = null;
+
+ private String inputValue;
+
+ private String value;
+
+ public SelectItem[] getExecuteOptions() {
+ return POSSIBLE_EXECUTE_OPTIONS;
+ }
+
+ public Object getExecute() {
+ return execute;
+ }
+
+ public void setExecute(Object execute) {
+ this.execute = execute;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getInputValue() {
+ return inputValue;
+ }
+
+ public void setInputValue(String inputValue) {
+ this.inputValue = inputValue;
+ }
+
+ public int getActionsCounter() {
+ return actionsCounter;
+ }
+
+ public void applyValue() {
+ this.actionsCounter++;
+ this.value = this.inputValue;
+ }
+}
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/MediaOutputBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/MediaOutputBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/MediaOutputBean.java 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+import org.richfaces.util.Util;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@RequestScoped
+@ManagedBean(name = "mediaOutputBean")
+public class MediaOutputBean {
+
+ public void createContent(OutputStream os, Object data) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream stream = classLoader.getResourceAsStream("org/richfaces/demo/" + data);
+ try {
+ Util.copyStreamContent(stream, os);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+}
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import java.util.EventListener;
+import java.util.EventObject;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.ajax4jsf.event.PushEventListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean(name = "pushBean")
+@SessionScoped
+public class PushBean {
+
+ private volatile PushEventListener listener;
+
+ public void setListener(EventListener listener) {
+ this.listener = (PushEventListener) listener;
+ }
+
+ public void generateEvent() {
+ listener.onEvent(new EventObject(this));
+ }
+}
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/RequestBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/RequestBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/RequestBean.java 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean(name = "requestBean")
+@RequestScoped
+public class RequestBean {
+
+ private String idsToRender;
+
+ public String getIdsToRender() {
+ return idsToRender;
+ }
+
+ public void setIdsToRender(String idsToRender) {
+ this.idsToRender = idsToRender;
+ }
+
+ public void setupIdsToRender() {
+ this.idsToRender = FacesContext.getCurrentInstance().getExternalContext().
+ getRequestParameterMap().get("idsToRender");
+ }
+
+ public Object getItems() {
+ SelectItem[] item = new SelectItem[1000];
+ for (int i = 0; i < item.length; i++) {
+ item[i] = new SelectItem(i);
+ }
+ return item;
+ }
+}
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/TimeBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/TimeBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/TimeBean.java 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,47 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean(name = "timeBean")
+@RequestScoped()
+public class TimeBean {
+
+ private String formattedDate = null;
+
+ public String getDateString() {
+ if (formattedDate == null) {
+ formattedDate = new SimpleDateFormat("HH:mm:ss SSSS").format(new Date());
+ }
+
+ return formattedDate;
+ }
+}
Added: root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/richfaces-twitter.jpg
===================================================================
(Binary files differ)
Property changes on: root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/richfaces-twitter.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/richfaces.jpg
===================================================================
(Binary files differ)
Property changes on: root/examples/trunk/components/core-demo/src/main/resources/org/richfaces/demo/richfaces.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/examples/trunk/components/core-demo/src/main/webapp/dynamicExecute.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/dynamicExecute.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/dynamicExecute.xhtml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:form>
+ <h:selectOneMenu value="#{dynamicExecuteBean.execute}" onchange="submit()">
+ <f:selectItems value="#{dynamicExecuteBean.executeOptions}" />
+ </h:selectOneMenu>
+ <br />
+ <h:commandLink value="Apply" />
+ </h:form>
+
+ <h:form id="formId">
+ <a4j:outputPanel ajaxRendered="true">
+ Actions counter: #{dynamicExecuteBean.actionsCounter}<br />
+ Input value: #{dynamicExecuteBean.inputValue}<br />
+ Applied value: #{dynamicExecuteBean.value}<br />
+ </a4j:outputPanel>
+
+ <h:inputText value="#{dynamicExecuteBean.inputValue}" />
+
+ <a4j:jsFunction action="#{dynamicExecuteBean.applyValue}" name="testFunction" execute="#{dynamicExecuteBean.execute}" />
+ <a href="javascript:testFunction()">Call test function</a>
+ </h:form>
+
+ <h:form id="anotherFormId">
+ <a4j:jsFunction action="#{dynamicExecuteBean.applyValue}" name="anotherTestFunction" execute="#{dynamicExecuteBean.execute}" />
+ <a href="javascript:anotherTestFunction()">Call test function from another form</a>
+ </h:form>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Added: root/examples/trunk/components/core-demo/src/main/webapp/function.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/function.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/function.xhtml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:panelGrid columns="2">
+ Time1: <h:panelGroup id="time1">#{timeBean.dateString}</h:panelGroup>
+ Time2: <h:panelGroup id="time2">#{timeBean.dateString}</h:panelGroup>
+ Ajax time: <a4j:outputPanel ajaxRendered="true">#{timeBean.dateString}</a4j:outputPanel>
+ </h:panelGrid>
+
+ <h:form id="form">
+ <a4j:jsFunction action="#{requestBean.setupIdsToRender}" name="testFunction1" execute="@all" render="#{requestBean.idsToRender}">
+ <f:param name="idsToRender" value="time1" />
+ </a4j:jsFunction>
+ <a4j:jsFunction action="#{requestBean.setupIdsToRender}" name="testFunction1Limited" execute="form" limitToList="true" render="#{requestBean.idsToRender}">
+ <f:param name="idsToRender" value="time1" />
+ </a4j:jsFunction>
+ <a4j:jsFunction action="#{requestBean.setupIdsToRender}" name="testFunction2" execute="form" render="#{requestBean.idsToRender}">
+ <f:param name="idsToRender" value="time2" />
+ </a4j:jsFunction>
+ <a4j:jsFunction action="#{requestBean.setupIdsToRender}" name="testFunction2Limited" execute="form" limitToList="true" render="#{requestBean.idsToRender}">
+ <f:param name="idsToRender" value="time2" />
+ </a4j:jsFunction>
+
+ <h:commandLink value="test">
+ <f:ajax />
+ <f:param name="a" value="b" />
+ </h:commandLink>
+ </h:form>
+
+ <a href="javascript:testFunction1()">Call test function1</a>
+ <a href="javascript:testFunction1Limited()">Call test function1 with limitToList=true</a>
+ <a href="javascript:testFunction2()">Call test function2</a>
+ <a href="javascript:testFunction2Limited()">Call test function2 with limitToList=true</a>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Modified: root/examples/trunk/components/core-demo/src/main/webapp/index.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/index.xhtml 2009-08-18 09:40:41 UTC (rev 15191)
+++ root/examples/trunk/components/core-demo/src/main/webapp/index.xhtml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -27,6 +27,8 @@
<img src="#{resource['org.richfaces.resource.TestResource2']}" />
+ <img src="#{resource['org.richfaces.resource.AnimatedTestResource']}" />
+
<img src="#{testResource.requestPath}" />
</h:form>
Added: root/examples/trunk/components/core-demo/src/main/webapp/mediaOutput.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/mediaOutput.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/mediaOutput.xhtml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <a4j:mediaOutput createContent="#{mediaOutputBean.createContent}" value="richfaces.jpg"
+ element="img" /><br />
+ <a4j:mediaOutput createContent="#{mediaOutputBean.createContent}" value="richfaces-twitter.jpg"
+ element="img" /><br />
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Added: root/examples/trunk/components/core-demo/src/main/webapp/outputPanel.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/outputPanel.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/outputPanel.xhtml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <a4j:outputPanel layout="block">
+ Output panel
+ </a4j:outputPanel>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Added: root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml 2009-08-18 09:41:53 UTC (rev 15192)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:panelGrid columns="2">
+ Time: <h:panelGroup id="time">#{timeBean.dateString}</h:panelGroup>
+ </h:panelGrid>
+
+ <h:form id="form">
+ <a4j:push eventProducer="#{pushBean.setListener}" interval="5000">
+ <f:ajax render="#{':time'}" />
+ </a4j:push>
+
+ <h:commandLink value="Generate push event" action="#{pushBean.generateEvent}">
+ <f:ajax render="#{'@this'}" />
+ </h:commandLink>
+ </h:form>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
15 years, 4 months
JBoss Rich Faces SVN: r15191 - in root/ui/trunk/components/core/src/main: java/org/ajax4jsf/renderkit and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-18 05:40:41 -0400 (Tue, 18 Aug 2009)
New Revision: 15191
Added:
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxFunction.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxLog.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxOutputPanel.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIMediaOutput.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlMediaOutput.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlOutputPanel.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlPush.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/CommandRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxFunctionRenderer1.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/MediaOutputHandler.java
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
Removed:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxFunction.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxOutputPanel.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPush.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFunctionRenderer.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxPushHandler.java
root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml
Log:
Big A1 components check-in
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxFunction.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxFunction.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxFunction.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.component;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:04 $
- *
- */
-public abstract class UIAjaxFunction extends AjaxActionComponent {
-
- public static final String COMPONENT_TYPE="org.ajax4jsf.Function";
-
- public abstract String getName();
-
- public abstract void setName(String name);
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxOutputPanel.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxOutputPanel.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxOutputPanel.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,42 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.component;
-
-import javax.faces.component.UIPanel;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
- *
- */
-public abstract class UIAjaxOutputPanel extends UIPanel implements AjaxOutput {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.OutputPanel";
- /**
- * @return
- */
- public abstract String getLayout();
-
- public abstract void setLayout(String layout);
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,109 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.component;
-
-import javax.el.MethodExpression;
-
-import javax.faces.component.UIOutput;
-import javax.faces.el.MethodBinding;
-
-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 ResourceComponent2 {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.MMedia";
-
- /**
- * Get URI attribute for resource ( src for images, href for links etc ).
- * @return
- */
- public abstract String getUriAttribute();
-
- /**
- * Set URI attribute for resource ( src for images, href for links etc ).
- * @param newvalue
- */
- public abstract void setUriAttribute(String newvalue);
-
- /**
- * Get Element name for rendering ( imj , a , object, applet ).
- * @return
- */
- public abstract String getElement();
-
- /**
- * Set Element name for rendering ( imj , a , object, applet ).
- * @param newvalue
- */
- 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);
- }
- }
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPush.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPush.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPush.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,113 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.component;
-
-import java.io.IOException;
-
-import javax.el.MethodExpression;
-import javax.faces.component.NamingContainer;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpSession;
-
-import org.ajax4jsf.webapp.PollEventsManager;
-import org.ajax4jsf.webapp.PushEventsCounter;
-
-/**
- * Component for periodically call AJAX events on server ( poll actions )
- * @author shura
- *
- */
-public abstract class UIPush extends AjaxActionComponent {
-
- public static final String COMPONENT_TYPE="org.ajax4jsf.Push";
-
-
- public static final String ON_DATA_AVAILABLE = "ondataavailable";
-
-
- private transient boolean _submitted = false;
-
- /**
- * @return the submitted
- */
- public boolean isSubmitted() {
- return _submitted;
- }
-
- public void encodeBegin(FacesContext context) throws IOException {
- MethodExpression producer = getEventProducer();
- // Subscribe events producer to push status listener.
- if(null != producer){
- producer.invoke(context.getELContext(), new Object[]{getListener(context)});
- }
- super.encodeBegin(context);
- }
-
- private PushEventsCounter getListener(FacesContext context){
- PollEventsManager eventsManeger = (PollEventsManager) context.getExternalContext().getApplicationMap().get(PollEventsManager.EVENTS_MANAGER_KEY);
- return eventsManeger.getListener(getListenerId(context));
- }
-
- public String getListenerId(FacesContext context){
- Object session = context.getExternalContext().getSession(false);
- StringBuffer id = new StringBuffer();
- if(null != session && session instanceof HttpSession){
- HttpSession httpSession = (HttpSession) session;
- id.append(httpSession.getId());
- }
- id.append(context.getViewRoot().getViewId());
- id.append(NamingContainer.SEPARATOR_CHAR);
- id.append(getClientId(context));
- return id.toString();
- }
- /**
- * @param submitted the submitted to set
- */
- public void setSubmitted(boolean submitted) {
- _submitted = submitted;
- }
-
- public abstract MethodExpression getEventProducer();
-
- public abstract void setEventProducer(MethodExpression producer);
- /**
- * @return time in mc for polling interval.
- */
- public abstract int getInterval();
-
- /**
- * @param interval time in mc for polling interval.
- */
- public abstract void setInterval(int interval);
-
- public abstract boolean isEnabled();
-
- public abstract void setEnabled(boolean enable);
-
- protected void setupReRender(FacesContext facesContext) {
- super.setupReRender(facesContext);
-// AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(this);
- //getListener(facesContext).processed();
- }
-
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,138 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import java.io.IOException;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
-import javax.faces.component.html.HtmlCommandButton;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.event.AjaxEvent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
- *
- */
-public abstract class AjaxCommandRendererBase extends AjaxComponentRendererBase {
-
- private static final Log _log = LogFactory
- .getLog(AjaxCommandRendererBase.class);
-
- protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
-
- // super.decode must not be called, because value is handled here
- if (isSubmitted(facesContext, uiComponent)) {
- ActionEvent event;
- event = new ActionEvent(uiComponent);
- uiComponent.queueEvent(event);
- uiComponent.queueEvent(new AjaxEvent(uiComponent));
- // Check areas for processing
- if (uiComponent instanceof AjaxComponent) {
- AjaxComponent ajaxComponent = (AjaxComponent) uiComponent;
- Set<String> toProcess = AjaxRendererUtils.asSet(ajaxComponent
- .getProcess());
- if (null != toProcess) {
- Set<String> componentIdsToProcess = new LinkedHashSet<String>();
- for (String componentId : toProcess) {
- UIComponent component = getUtils().findComponentFor(uiComponent, componentId);
- if(null != component){
- componentIdsToProcess.add(component.getClientId(facesContext));
- } else {
- componentIdsToProcess.add(componentId);
- }
- }
- AjaxContext.getCurrentInstance(facesContext).setAjaxAreasToProcess(componentIdsToProcess);
- }
- }
- }
- }
-
- public String getOnClick(FacesContext context, UIComponent component) {
- StringBuffer onClick;
- if (!getUtils().isBooleanAttribute(component, "disabled")) {
- onClick = AjaxRendererUtils.buildOnClick(component, context, true);
- if (!"reset".equals(component.getAttributes().get("type"))) {
- onClick.append(";return false;");
- }
- } else {
- onClick = new StringBuffer("return false;");
- }
- return onClick.toString();
- }
-
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException {
- renderChildren(context, component);
- }
-
- public Object getValue(UIComponent uiComponent) {
- if (uiComponent instanceof ValueHolder) {
- return ((ValueHolder) uiComponent).getValue();
- }
- return uiComponent.getAttributes().get("value");
- }
-
- public String getType(UIComponent uiComponent) {
- String type;
- if (uiComponent instanceof HtmlCommandButton) {
- type = ((HtmlCommandButton) uiComponent).getType();
- } else {
- type = (String) uiComponent.getAttributes().get("type");
- }
- if (type == null) {
- type = "button";
- }
- return type;
- }
-
- protected boolean isSubmitted(FacesContext facesContext,
- UIComponent uiComponent) {
- // Componet accept only ajax requests.
- if (!AjaxContext.getCurrentInstance(facesContext).isAjaxRequest()) {
- return false;
- }
- if (getUtils().isBooleanAttribute(uiComponent, "disabled")) {
- return false;
- }
- String clientId = uiComponent.getClientId(facesContext);
- Map<String, String> paramMap = facesContext.getExternalContext()
- .getRequestParameterMap();
- Object value = paramMap.get(clientId);
- boolean submitted = null != value;
- if (submitted && _log.isDebugEnabled()) {
- _log.debug("Decode submit of the Ajax component " + clientId);
- }
- return submitted;
- }
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,111 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-
-import org.ajax4jsf.component.UIAjaxFunction;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-
-/**
- * @author shura
- *
- */
-@ResourceDependencies(value = {
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
- })
-public class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- return UIAjaxFunction.class;
- }
-
- public String getFunction(FacesContext context, UIAjaxFunction component) {
- String functionName = component.getName();
- if (functionName == null) {
- throw new FacesException("Value of 'name' attribute of a4j:jsFunction component is null!");
- }
-
- StringBuffer script = new StringBuffer(functionName).append("=");
- JSFunctionDefinition func = new JSFunctionDefinition();
- //func.setName(component.getName());
- // Create AJAX Submit function.
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
- component, context, "RichFaces.ajax");
- Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, component);
- ajaxFunction.addParameter(options);
-
-// Map<String, Object> parameters = (Map<String, Object>) options.get("parameters");
-// if (null == parameters) {
-// parameters = new HashMap<String, Object>();
-// options.put("parameters", parameters);
-// }
-// ajaxFunction.addParameter(JSReference.NULL);
-// ajaxFunction.addParameter(options);
-// // Fill parameters.
-// for (Iterator<UIComponent> it = component.getChildren().iterator(); it.hasNext();) {
-// UIComponent child = it.next();
-// if (child instanceof UIParameter) {
-// UIParameter parameter = ((UIParameter) child);
-// String name = parameter.getName();
-// func.addParameter(name);
-// // Put parameter name to AJAX.Submit parameter, with default value.
-// JSReference reference = new JSReference(name);
-// if (null != parameter.getValue()) {
-// reference = new JSReference(name + "||"
-// + ScriptUtils.toScript(parameters.get(name)));
-//
-// }
-// // Replace parameter value to reference.
-// parameters.put(name, reference);
-// }
-// }
- func.addToBody(ajaxFunction.toScript());
- func.appendScript(script);
- return script.toString();
- }
-
- @Override
- protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
- Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
- String clientId = uiComponent.getClientId(facesContext);
-
- if (requestParameterMap.get(clientId) != null) {
- new ActionEvent(uiComponent).queue();
- }
- }
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,97 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.application.Resource;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIOutput;
-import javax.faces.context.FacesContext;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.component.UIResource;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.URIInternetResource;
-
-/**
- * @author shura
- *
- */
-public class LoadResourceRendererBase extends RendererBase {
-
- private static final String SCRIPT_COMPONENT_FAMILY="org.ajax4jsf.LoadScript";
- private static final String STYLE_COMPONENT_FAMILY="org.ajax4jsf.LoadStyle";
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- return UIResource.class;
- }
-
- public void encodeToHead(FacesContext context, UIComponent component) throws IOException {
-// UIResource resource = (UIResource) component;
-// Object src = resource.getSrc();
-// if(null == src) {
-// throw new FacesException("Source for resource is null for component "+resource.getClientId(context));
-// }
-//
-// String family = resource.getFamily();
-// Renderer renderer = null;
-// InternetResource internetResource = null;
-// Map<String, Object> attributes = Collections.emptyMap();
-//
-// if (SCRIPT_COMPONENT_FAMILY.equals(family)) {
-// renderer = context.getRenderKit().getRenderer(UIOutput.COMPONENT_FAMILY, "javax.faces.resource.Script");
-// } else if (STYLE_COMPONENT_FAMILY.equals(family)) {
-// renderer = context.getRenderKit().getRenderer(UIOutput.COMPONENT_FAMILY, "javax.faces.resource.Stylesheet");
-//
-// String media = (String) resource.getAttributes().get(HTML.media_ATTRIBUTE);
-// if (media != null && media.length() != 0) {
-// attributes = new HashMap<String, Object>();
-// attributes.put(HTML.media_ATTRIBUTE, media);
-// }
-// }
-//
-// if (src instanceof Resource) {
-// internetResource = (InternetResource) src;
-// } else {
-// if(resource.isRendered()){
-// String uri = context.getApplication().getViewHandler().
-// getResourceURL(context, src.toString());
-// uri = context.getExternalContext().encodeResourceURL(uri);
-// internetResource = new URIInternetResource(uri);
-// }
-// }
-//
-// if (internetResource != null) {
-// renderer.encode(internetResource, context, null, attributes);
-// }
- }
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFunctionRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFunctionRenderer.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFunctionRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.component.UIAjaxFunction;
-import org.ajax4jsf.renderkit.AjaxFunctionRendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class AjaxFunctionRenderer extends AjaxFunctionRendererBase {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- @Override
- public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
- super.encodeEnd(context, component);
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.id_ATTRIBUTE, component.getClientId(context), "id");
- writer.writeText(getFunction(context, (UIAjaxFunction) component), null);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,144 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.component.UIAjaxOutputPanel;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:27 $
- *
- */
-public class AjaxOutputPanelRenderer extends RendererBase {
-
- private final String[] STYLE_ATTRIBUTES = new String[]{"style","class"};
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- //
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if ("none".equals(panel.getLayout())) {
- if (component.getChildCount() > 0) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- boolean ajaxRequest = ajaxContext.isAjaxRequest();
- Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
- for (UIComponent child : component.getChildren()) {
- String childId = child.getClientId(context);
- if (child.isRendered()) {
- renderChild(context, child);
- } else {
- // Render "dummy" span.
- ResponseWriter out = context.getResponseWriter();
- out.startElement(HTML.SPAN_ELEM,child);
- out.writeAttribute(HTML.id_ATTRIBUTE,childId,HTML.id_ATTRIBUTE);
- out.writeAttribute(HTML.style_ATTRIBUTE,"display: none;","style");
- out.endElement(HTML.SPAN_ELEM);
- }
- // register child as rendered
- if(ajaxRequest && null != ajaxRenderedAreas) {
- ajaxRenderedAreas.add(childId);
- }
- }
- }
-
- } else {
- renderChildren(context,component);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
- public boolean getRendersChildren() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- return UIAjaxOutputPanel.class;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (!"none".equals(panel.getLayout())) {
- writer.startElement(getTag(panel), panel);
- getUtils().encodeId(context, component);
- getUtils().encodePassThru(context, component);
- getUtils().encodeAttributesFromArray(context,component,STYLE_ATTRIBUTES);
- }
- }
-
- /**
- * @param panel
- * @return
- */
- private String getTag(UIAjaxOutputPanel panel) {
- return "block".equals(panel.getLayout())?HTML.DIV_ELEM:HTML.SPAN_ELEM;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (!"none".equals(panel.getLayout())) {
- writer.endElement(getTag(panel));
- }
- if (panel.isKeepTransient()) {
- markNoTransient(component);
- }
- }
-
- /**
- * Set "transient" flag to false for component and all its children ( recursive ).
- * @param component
- */
- private void markNoTransient(UIComponent component) {
- for (Iterator<UIComponent> iter = component.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent element = iter.next();
- markNoTransient(element);
- element.setTransient(false);
- }
-
- }
-
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,128 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.component.UIPush;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-
-/**
- * @author shura
- *
- */
-@ResourceDependencies(value = {
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
-})
-public class AjaxPushRenderer extends RendererBase {
-
- public static final String PUSH_INTERVAL_PARAMETER = "A4J.AJAX.Push.INTERVAL";
-
- public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
-
- @Deprecated
- public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
-
- public static final int DEFAULT_PUSH_INTERVAL = 1000;
-
- public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
-
- private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- UIPush push = (UIPush) component;
- writer.startElement(HTML.SPAN_ELEM, component);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
- getUtils().encodeId(context, component);
-
- //TODO - ?
- getUtils().encodeBeginFormIfNessesary(context, component);
- // pushing script.
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- StringBuffer script = new StringBuffer("\n");
- if (push.isEnabled()) {
- JSFunction function = new JSFunction("RichFaces.startPush");
- // Set dummy form id, if nessesary.
- Map<String, Object> options = new HashMap<String, Object>();
-
- int interval = push.getInterval();
- if (!getUtils().shouldRenderAttribute(interval)) {
- String intervalInitParameter = context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
- if(null != intervalInitParameter){
- interval = Integer.parseInt(intervalInitParameter);
- } else {
- interval = DEFAULT_PUSH_INTERVAL;
- }
- }
-
- options.put("interval", new Integer(interval));
- options.put("pushId", push.getListenerId(context));
- ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext(context, push, push.getDefaultEventName(), push.getClientId(context), null);
- ClientBehavior clientBehavior = push.getClientBehaviors().get(push.getDefaultEventName()).get(0);
- options.put(UIPush.ON_DATA_AVAILABLE, new JSFunctionDefinition("event").addToBody(clientBehavior.getScript(behaviorContext)));
- function.addParameter(options);
- script.append(function.toScript());
- } else {
- script.append("RichFaces.stopPush('").append(push.getListenerId(context)).append("')");
- }
- script.append(";\n");
- writer.writeText(script.toString(),null);
- writer.endElement(HTML.SCRIPT_ELEM);
- getUtils().encodeEndFormIfNessesary(context, component);
- writer.endElement(HTML.SPAN_ELEM);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- // only push component is allowed.
- return UIPush.class;
- }
-
-// protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
-// boolean submitted = super.isSubmitted(facesContext, uiComponent);
-// UIPush push = (UIPush) uiComponent;
-// push.setSubmitted(submitted);
-// return submitted;
-// }
-
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -1,134 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.UIMediaOutput;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.resource.InternetResourceBuilder;
-
-/**
- * @author shura
- *
- */
-public class MediaOutputRenderer extends RendererBase {
-
- public static final String RENDERER_TYPE = "org.ajax4jsf.MMediaRenderer";
-
- /**
- * Associationd between element name and uri attributes
- */
- private static final Map uriAttributes;
-
- static {
- uriAttributes = new HashMap();
- uriAttributes.put("a","href");
- uriAttributes.put("img","src");
- uriAttributes.put("object","data");
- uriAttributes.put("link","href");
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- UIMediaOutput mmedia = (UIMediaOutput) component;
- String element = mmedia.getElement();
- if(null == element){
- throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
- }
- writer.endElement(element);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIMediaOutput.class;
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- UIMediaOutput mmedia = (UIMediaOutput) component;
- String element = mmedia.getElement();
- if(null == element){
- throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
- }
- String uriAttribute = mmedia.getUriAttribute();
- // Check for pre-defined attributes
- if(null == uriAttribute){
- uriAttribute = (String) uriAttributes.get(element);
- if(null == uriAttribute){
- throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"uriAttribute",component.getClientId(context)));
- }
- }
- writer.startElement(element,mmedia);
- getUtils().encodeId(context,component);
- InternetResourceBuilder internetResourceBuilder = InternetResourceBuilder.getInstance();
- InternetResource resource = internetResourceBuilder.createUserResource(mmedia.isCacheable(),mmedia.isSession(),mmedia.getMimeType());
- StringBuffer uri = new StringBuffer(resource.getUri(context,mmedia));
- // Append parameters to resource Uri
- boolean haveQestion = uri.indexOf("?")>=0;
- Iterator kids = component.getChildren().iterator();
- while (kids.hasNext()) {
- UIComponent kid = (UIComponent) kids.next();
-
- if (kid instanceof UIParameter) {
- UIParameter uiParam = (UIParameter) kid;
- String name = uiParam.getName();
- Object value = uiParam.getValue();
- if(null != value){
- if(haveQestion){
- uri.append('&');
- } else {
- uri.append('?');
- haveQestion = true;
- }
- uri.append(name).append('=').append(value.toString());
- }
- }
- }
- writer.writeURIAttribute(uriAttribute,uri,"uri");
- getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
- getUtils().encodePassThru(context,mmedia);
- }
-
-}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class UIAjaxCommandButton extends UIComponentBase {
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.AjaxCommandButton";
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class UIAjaxCommandLink extends UIComponentBase {
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.AjaxCommandLink";
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxFunction.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxFunction.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxFunction.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.ajax4jsf.component.AjaxActionComponent;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:04 $
+ *
+ */
+public abstract class UIAjaxFunction extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Function";
+
+ public abstract String getName();
+
+ public abstract void setName(String name);
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxLog.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxLog.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxLog.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class UIAjaxLog extends UIComponentBase {
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.AjaxLog";
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public boolean isPopup() {
+ //FIXME: common stuff goes here
+ return false;
+ }
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxOutputPanel.java (from rev 15164, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxOutputPanel.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxOutputPanel.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxOutputPanel.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,65 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIPanel;
+
+import org.ajax4jsf.component.AjaxOutput;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
+ *
+ */
+public class UIAjaxOutputPanel extends UIPanel implements AjaxOutput {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.AjaxOutputPanel";
+
+ private static enum PropertyKeys {
+ ajaxRendered,
+ keepTransient
+ };
+
+ public UIAjaxOutputPanel() {
+ super();
+ setRendererType("org.richfaces.OutputPanelRenderer");
+ }
+
+ public boolean isAjaxRendered() {
+ return Boolean.valueOf(getStateHelper().eval(PropertyKeys.ajaxRendered, Boolean.FALSE).
+ toString());
+ }
+
+ public boolean isKeepTransient() {
+ return Boolean.valueOf(getStateHelper().eval(PropertyKeys.keepTransient, Boolean.FALSE).
+ toString());
+ }
+
+ public void setAjaxRendered(boolean ajaxRendered) {
+ getStateHelper().put(PropertyKeys.ajaxRendered, ajaxRendered);
+ }
+
+ public void setKeepTransient(boolean keepTransient) {
+ getStateHelper().put(PropertyKeys.keepTransient, keepTransient);
+ }
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIMediaOutput.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIMediaOutput.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIMediaOutput.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIMediaOutput.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,120 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.el.MethodExpression;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.ajax4jsf.resource.ResourceComponent2;
+import org.richfaces.resource.MediaOutputResource;
+import org.richfaces.webapp.taglib.MethodBindingMethodExpressionAdaptor;
+import org.richfaces.webapp.taglib.MethodExpressionMethodBindingAdaptor;
+
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UIMediaOutput extends UIOutput implements ResourceComponent2 {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.MediaOutput";
+
+ /**
+ * Get URI attribute for resource ( src for images, href for links etc ).
+ * @return
+ */
+ public abstract String getUriAttribute();
+
+ /**
+ * Set URI attribute for resource ( src for images, href for links etc ).
+ * @param newvalue
+ */
+ public abstract void setUriAttribute(String newvalue);
+
+ /**
+ * Get Element name for rendering ( imj , a , object, applet ).
+ * @return
+ */
+ public abstract String getElement();
+
+ /**
+ * Set Element name for rendering ( imj , a , object, applet ).
+ * @param newvalue
+ */
+ 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 instanceof MethodExpressionMethodBindingAdaptor) {
+ 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);
+ }
+ }
+
+ public Resource getResource() {
+ FacesContext facesContext = getFacesContext();
+ ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+ MediaOutputResource resource = (MediaOutputResource) resourceHandler.createResource(MediaOutputResource.class.getName());
+ resource.initialize(this);
+
+ return resource;
+ }
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPush.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,127 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.el.MethodExpression;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Component for periodically call AJAX events on server ( poll actions )
+ * @author shura
+ *
+ */
+public class UIPush extends UIComponentBase implements ClientBehaviorHolder {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Push";
+
+ public final static String COMPONENT_FAMILY = "org.richfaces.Push";
+
+ public static final String ON_DATA_AVAILABLE = "ondataavailable";
+
+ private static final Collection<String> EVENT_NAMES = Collections.singleton(ON_DATA_AVAILABLE);
+
+ private static enum PropertyKeys {
+ eventProducer, enabled, interval
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException {
+ MethodExpression producer = getEventProducer();
+ // Subscribe events producer to push status listener.
+ if (null != producer) {
+ producer.invoke(context.getELContext(), new Object[]{getListener(context)});
+ }
+
+ super.encodeBegin(context);
+ }
+
+ private PushEventTracker getListener(FacesContext context) {
+ PushListenersManager pushListenersManager = PushListenersManager.getInstance(context);
+ return pushListenersManager.getListener(getListenerId(context));
+ }
+
+ public String getListenerId(FacesContext context){
+ Object session = context.getExternalContext().getSession(false);
+ StringBuffer id = new StringBuffer();
+ if(null != session && session instanceof HttpSession){
+ HttpSession httpSession = (HttpSession) session;
+ id.append(httpSession.getId());
+ }
+ id.append(context.getViewRoot().getViewId());
+ id.append(NamingContainer.SEPARATOR_CHAR);
+ id.append(getClientId(context));
+ return id.toString();
+ }
+
+ public MethodExpression getEventProducer() {
+ return (MethodExpression) getStateHelper().get(PropertyKeys.eventProducer);
+ }
+
+ public void setEventProducer(MethodExpression producer) {
+ getStateHelper().put(PropertyKeys.eventProducer, producer);
+ }
+
+ /**
+ * @return time in mc for polling interval.
+ */
+ public int getInterval() {
+ return (Integer) getStateHelper().eval(PropertyKeys.interval, 1000);
+ }
+
+ /**
+ * @param interval time in mc for polling interval.
+ */
+ public void setInterval(int interval) {
+ getStateHelper().put(PropertyKeys.interval, interval);
+ }
+
+ public boolean isEnabled() {
+ return Boolean.valueOf(getStateHelper().eval(PropertyKeys.enabled, Boolean.TRUE).toString());
+ }
+
+ public void setEnabled(boolean enable) {
+ getStateHelper().put(PropertyKeys.enabled, enable);
+ }
+
+ @Override
+ public String getDefaultEventName() {
+ return ON_DATA_AVAILABLE;
+ }
+
+ @Override
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,619 @@
+package org.richfaces.component.html;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIAjaxFunction;
+
+public class HtmlAjaxFunction extends UIAjaxFunction {
+
+ public final static String COMPONENT_FAMILY = "javax.faces.Command";
+
+ public final static String COMPONENT_TYPE = "org.richfaces.Function";
+
+ public HtmlAjaxFunction() {
+ setRendererType("org.richfaces.FunctionRenderer");
+ }
+
+ /*
+ * Limits JSF tree processing (decoding, conversion, validation and model updating) only to a component that sends the request. Boolean
+ */
+ private boolean _ajaxSingle = false;
+
+ private boolean _ajaxSingleSet = false;
+
+ /*
+ * If "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
+ */
+ private boolean _bypassUpdates = false;
+
+ private boolean _bypassUpdatesSet = false;
+
+ /*
+ * Serialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
+ */
+ private Object _data = null;
+
+ /*
+ * Name of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
+ */
+ private String _eventsQueue = null;
+
+ /*
+ * ID of an element to set focus after request is completed on client side
+ */
+ private String _focus = null;
+
+ /*
+ * Attribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is
+in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server,
+but just allows to avoid unnecessary updates on the client side if the response isn't actual now
+ */
+ private boolean _ignoreDupResponses = false;
+
+ private boolean _ignoreDupResponsesSet = false;
+
+ /*
+ * If "true", then of all AJAX-rendered on the page components only those will be updated,
+ which ID's are passed to the "reRender" attribute of the describable component.
+ "false"-the default value-means that all components with ajaxRendered="true" will be updated.
+ */
+ private boolean _limitToList = false;
+
+ private boolean _limitToListSet = false;
+
+ /*
+ * Name of generated JavaScript function definition
+ */
+ private String _name = null;
+
+ /*
+ * The client-side script method to be called before DOM is updated
+ */
+ private String _onbeforedomupdate = null;
+
+ /*
+ * The client-side script method to be called after the request is completed
+ */
+ private String _oncomplete = null;
+
+ /*
+ * Id['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
+ */
+ private Object _process = null;
+
+ /*
+ * Id['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
+ */
+ private Object _reRender = null;
+
+ /*
+ * Attribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send.
+When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
+ */
+ private int _requestDelay = Integer.MIN_VALUE;
+
+ private boolean _requestDelaySet = false;
+
+ /*
+ * If there are any component requests with identical IDs then these requests will be grouped.
+ */
+ private String _similarityGroupingId = null;
+
+ /*
+ * ID (in format of call UIComponent.findComponent()) of Request status component
+ */
+ private String _status = null;
+
+ /*
+ * Response waiting time on a particular request. If a response is not received during this time, the request is aborted
+ */
+ private int _timeout = Integer.MIN_VALUE;
+
+ private boolean _timeoutSet = false;
+
+ public boolean isAjaxSingle(){
+ if (this._ajaxSingleSet) {
+ return (this._ajaxSingle);
+ }
+ ValueExpression ve = getValueExpression("ajaxSingle");
+ if (ve != null) {
+ Boolean value = null;
+
+ try {
+ value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this._ajaxSingle);
+ }
+
+ return value;
+ } else {
+ return (this._ajaxSingle);
+ }
+
+ }
+
+ public void setAjaxSingle(boolean _ajaxSingle){
+ this._ajaxSingle = _ajaxSingle;
+ this._ajaxSingleSet = true;
+ }
+
+ public boolean isBypassUpdates(){
+ if (this._bypassUpdatesSet) {
+ return (this._bypassUpdates);
+ }
+ ValueExpression ve = getValueExpression("bypassUpdates");
+ if (ve != null) {
+ Boolean value = null;
+
+ try {
+ value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this._bypassUpdates);
+ }
+
+ return value;
+ } else {
+ return (this._bypassUpdates);
+ }
+
+ }
+
+ public void setBypassUpdates(boolean _bypassUpdates){
+ this._bypassUpdates = _bypassUpdates;
+ this._bypassUpdatesSet = true;
+ }
+
+ public Object getData(){
+ if (this._data != null) {
+ return this._data;
+ }
+ ValueExpression ve = getValueExpression("data");
+ if (ve != null) {
+ Object value = null;
+
+ try {
+ value = (Object) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setData(Object _data){
+ this._data = _data;
+ }
+
+ public String getEventsQueue(){
+ if (this._eventsQueue != null) {
+ return this._eventsQueue;
+ }
+ ValueExpression ve = getValueExpression("eventsQueue");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setEventsQueue(String _eventsQueue){
+ this._eventsQueue = _eventsQueue;
+ }
+
+ public String getFocus(){
+ if (this._focus != null) {
+ return this._focus;
+ }
+ ValueExpression ve = getValueExpression("focus");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setFocus(String _focus){
+ this._focus = _focus;
+ }
+
+ public boolean isIgnoreDupResponses(){
+ if (this._ignoreDupResponsesSet) {
+ return (this._ignoreDupResponses);
+ }
+ ValueExpression ve = getValueExpression("ignoreDupResponses");
+ if (ve != null) {
+ Boolean value = null;
+
+ try {
+ value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this._ignoreDupResponses);
+ }
+
+ return value;
+ } else {
+ return (this._ignoreDupResponses);
+ }
+
+ }
+
+ public void setIgnoreDupResponses(boolean _ignoreDupResponses){
+ this._ignoreDupResponses = _ignoreDupResponses;
+ this._ignoreDupResponsesSet = true;
+ }
+
+ public boolean isLimitToList(){
+ if (this._limitToListSet) {
+ return (this._limitToList);
+ }
+ ValueExpression ve = getValueExpression("limitToList");
+ if (ve != null) {
+ Boolean value = null;
+
+ try {
+ value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this._limitToList);
+ }
+
+ return value;
+ } else {
+ return (this._limitToList);
+ }
+
+ }
+
+ public void setLimitToList(boolean _limitToList){
+ this._limitToList = _limitToList;
+ this._limitToListSet = true;
+ }
+
+ public String getName(){
+ if (this._name != null) {
+ return this._name;
+ }
+ ValueExpression ve = getValueExpression("name");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setName(String _name){
+ this._name = _name;
+ }
+
+ public String getOnbeforedomupdate(){
+ if (this._onbeforedomupdate != null) {
+ return this._onbeforedomupdate;
+ }
+ ValueExpression ve = getValueExpression("onbeforedomupdate");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setOnbeforedomupdate(String _onbeforedomupdate){
+ this._onbeforedomupdate = _onbeforedomupdate;
+ }
+
+ public String getOncomplete(){
+ if (this._oncomplete != null) {
+ return this._oncomplete;
+ }
+ ValueExpression ve = getValueExpression("oncomplete");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setOncomplete(String _oncomplete){
+ this._oncomplete = _oncomplete;
+ }
+
+ public Object getProcess(){
+ if (this._process != null) {
+ return this._process;
+ }
+ ValueExpression ve = getValueExpression("process");
+ if (ve != null) {
+ Object value = null;
+
+ try {
+ value = (Object) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setProcess(Object _process){
+ this._process = _process;
+ }
+
+ public Object getReRender(){
+ if (this._reRender != null) {
+ return this._reRender;
+ }
+ ValueExpression ve = getValueExpression("reRender");
+ if (ve != null) {
+ Object value = null;
+
+ try {
+ value = (Object) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setReRender(Object _reRender){
+ this._reRender = _reRender;
+ }
+
+ public int getRequestDelay(){
+ if (this._requestDelaySet) {
+ return (this._requestDelay);
+ }
+ ValueExpression ve = getValueExpression("requestDelay");
+ if (ve != null) {
+ Integer value = null;
+
+ try {
+ value = (Integer) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this._requestDelay);
+ }
+
+ return value;
+ } else {
+ return (this._requestDelay);
+ }
+
+ }
+
+ public void setRequestDelay(int _requestDelay){
+ this._requestDelay = _requestDelay;
+ this._requestDelaySet = true;
+ }
+
+ public String getSimilarityGroupingId(){
+ if (this._similarityGroupingId != null) {
+ return this._similarityGroupingId;
+ }
+ ValueExpression ve = getValueExpression("similarityGroupingId");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setSimilarityGroupingId(String _similarityGroupingId){
+ this._similarityGroupingId = _similarityGroupingId;
+ }
+
+ public String getStatus(){
+ if (this._status != null) {
+ return this._status;
+ }
+ ValueExpression ve = getValueExpression("status");
+ if (ve != null) {
+ String value = null;
+
+ try {
+ value = (String) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return null;
+
+
+ }
+
+ public void setStatus(String _status){
+ this._status = _status;
+ }
+
+ public int getTimeout(){
+ if (this._timeoutSet) {
+ return (this._timeout);
+ }
+ ValueExpression ve = getValueExpression("timeout");
+ if (ve != null) {
+ Integer value = null;
+
+ try {
+ value = (Integer) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this._timeout);
+ }
+
+ return value;
+ } else {
+ return (this._timeout);
+ }
+
+ }
+
+ public void setTimeout(int _timeout){
+ this._timeout = _timeout;
+ this._timeoutSet = true;
+ }
+
+ public String getFamily(){
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public Object saveState(FacesContext context){
+ Object [] state = new Object[23];
+ state[0] = super.saveState(context);
+ state[1] = Boolean.valueOf(_ajaxSingle);
+ state[2] = Boolean.valueOf(_ajaxSingleSet);
+ state[3] = Boolean.valueOf(_bypassUpdates);
+ state[4] = Boolean.valueOf(_bypassUpdatesSet);
+ state[5] = saveAttachedState(context, _data);
+ state[6] = _eventsQueue;
+ state[7] = _focus;
+ state[8] = Boolean.valueOf(_ignoreDupResponses);
+ state[9] = Boolean.valueOf(_ignoreDupResponsesSet);
+ state[10] = Boolean.valueOf(_limitToList);
+ state[11] = Boolean.valueOf(_limitToListSet);
+ state[12] = _name;
+ state[13] = _onbeforedomupdate;
+ state[14] = _oncomplete;
+ state[15] = saveAttachedState(context, _process);
+ state[16] = saveAttachedState(context, _reRender);
+ state[17] = Integer.valueOf(_requestDelay);
+ state[18] = Boolean.valueOf(_requestDelaySet);
+ state[19] = _similarityGroupingId;
+ state[20] = _status;
+ state[21] = Integer.valueOf(_timeout);
+ state[22] = Boolean.valueOf(_timeoutSet);
+ return state;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state){
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+ _ajaxSingle = ((Boolean)states[1]).booleanValue();
+ _ajaxSingleSet = ((Boolean)states[2]).booleanValue();
+ _bypassUpdates = ((Boolean)states[3]).booleanValue();
+ _bypassUpdatesSet = ((Boolean)states[4]).booleanValue();
+ _data = (Object)restoreAttachedState(context, states[5]);
+ _eventsQueue = (String)states[6];;
+ _focus = (String)states[7];;
+ _ignoreDupResponses = ((Boolean)states[8]).booleanValue();
+ _ignoreDupResponsesSet = ((Boolean)states[9]).booleanValue();
+ _limitToList = ((Boolean)states[10]).booleanValue();
+ _limitToListSet = ((Boolean)states[11]).booleanValue();
+ _name = (String)states[12];;
+ _onbeforedomupdate = (String)states[13];;
+ _oncomplete = (String)states[14];;
+ _process = (Object)restoreAttachedState(context, states[15]);
+ _reRender = (Object)restoreAttachedState(context, states[16]);
+ _requestDelay = ((Integer)states[17]).intValue();
+ _requestDelaySet = ((Boolean)states[18]).booleanValue();
+ _similarityGroupingId = (String)states[19];;
+ _status = (String)states[20];;
+ _timeout = ((Integer)states[21]).intValue();
+ _timeoutSet = ((Boolean)states[22]).booleanValue();
+
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlMediaOutput.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlMediaOutput.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlMediaOutput.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,415 @@
+package org.richfaces.component.html;
+
+import java.util.Date;
+
+import javax.el.MethodExpression;
+
+import org.richfaces.component.UIMediaOutput;
+
+public class HtmlMediaOutput extends UIMediaOutput {
+
+ static public final String COMPONENT_FAMILY = "org.richfaces.MediaOutput";
+
+ static public final String COMPONENT_TYPE = "org.richfaces.MediaOutput";
+
+ private static enum PropertyKeys {
+ onblur, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown,
+ onmousemove, onmouseout, onmouseover, onmouseup, rel, rev, type, title, target,
+ tabindex, styleClass, vspace, usemap, shape, standby, style, uriAttribute, accesskey,
+ align, archive, border, element, declare, coords, hreflang, hspace, dir, codetype, codebase,
+ charset, classid, lang, mimeType, lastModified, cacheable, createContentExpression, ismap,
+ session, expires
+ }
+
+ public HtmlMediaOutput() {
+ setRendererType("org.richfaces.MediaOutputRenderer");
+ }
+
+ public String getAccesskey() {
+ return (String) getStateHelper().eval(PropertyKeys.accesskey);
+ }
+
+ public void setAccesskey(String accesskey) {
+ getStateHelper().put(PropertyKeys.accesskey, accesskey);
+ }
+
+ public String getAlign() {
+ return (String) getStateHelper().eval(PropertyKeys.align);
+ }
+
+ public void setAlign(String align) {
+ getStateHelper().put(PropertyKeys.align, align);
+ }
+
+ public String getArchive() {
+ return (String) getStateHelper().eval(PropertyKeys.archive);
+ }
+
+ public void setArchive(String archive) {
+ getStateHelper().put(PropertyKeys.archive, archive);
+ }
+
+ public String getBorder() {
+ return (String) getStateHelper().eval(PropertyKeys.border);
+ }
+
+ public void setBorder(String border) {
+ getStateHelper().put(PropertyKeys.border, border);
+ }
+
+ public boolean isCacheable() {
+ return Boolean.parseBoolean(getStateHelper().eval(PropertyKeys.cacheable,
+ Boolean.FALSE).toString());
+ }
+
+ public void setCacheable(boolean cacheable) {
+ getStateHelper().put(PropertyKeys.cacheable, cacheable);
+ }
+
+ public String getCharset() {
+ return (String) getStateHelper().eval(PropertyKeys.charset);
+ }
+
+ public void setCharset(String charset) {
+ getStateHelper().put(PropertyKeys.charset, charset);
+ }
+
+ public String getClassid() {
+ return (String) getStateHelper().eval(PropertyKeys.classid);
+ }
+
+ public void setClassid(String classid) {
+ getStateHelper().put(PropertyKeys.classid, classid);
+ }
+
+ public String getCodebase() {
+ return (String) getStateHelper().eval(PropertyKeys.codebase);
+ }
+
+ public void setCodebase(String codebase) {
+ getStateHelper().put(PropertyKeys.codebase, codebase);
+ }
+
+ public String getCodetype() {
+ return (String) getStateHelper().eval(PropertyKeys.codetype);
+ }
+
+ public void setCodetype(String codetype) {
+ getStateHelper().put(PropertyKeys.codetype, codetype);
+ }
+
+ public String getCoords() {
+ return (String) getStateHelper().eval(PropertyKeys.coords);
+ }
+
+ public void setCoords(String coords) {
+ getStateHelper().put(PropertyKeys.coords, coords);
+ }
+
+ public MethodExpression getCreateContentExpression() {
+ return (MethodExpression) getStateHelper().get(PropertyKeys.createContentExpression);
+ }
+
+ public void setCreateContentExpression(
+ MethodExpression createContentExpression) {
+ getStateHelper().put(PropertyKeys.createContentExpression,
+ createContentExpression);
+ }
+
+ public String getDeclare() {
+ return (String) getStateHelper().eval(PropertyKeys.declare);
+ }
+
+ public void setDeclare(String declare) {
+ getStateHelper().put(PropertyKeys.declare, declare);
+ }
+
+ public String getDir() {
+ return (String) getStateHelper().eval(PropertyKeys.dir);
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+ public String getElement() {
+ return (String) getStateHelper().eval(PropertyKeys.element);
+ }
+
+ public void setElement(String element) {
+ getStateHelper().put(PropertyKeys.element, element);
+ }
+
+ public Date getExpires() {
+ return (Date) getStateHelper().eval(PropertyKeys.expires);
+ }
+
+ public void setExpires(Date expires) {
+ getStateHelper().put(PropertyKeys.expires, expires);
+ }
+
+ public String getHreflang() {
+ return (String) getStateHelper().eval(PropertyKeys.hreflang);
+ }
+
+ public void setHreflang(String hreflang) {
+ getStateHelper().put(PropertyKeys.hreflang, hreflang);
+ }
+
+ public String getHspace() {
+ return (String) getStateHelper().eval(PropertyKeys.hspace);
+ }
+
+ public void setHspace(String hspace) {
+ getStateHelper().put(PropertyKeys.hspace, hspace);
+ }
+
+ public boolean isIsmap() {
+ return Boolean.parseBoolean(getStateHelper().eval(PropertyKeys.ismap, Boolean.FALSE).toString());
+ }
+
+ public void setIsmap(boolean ismap) {
+ getStateHelper().put(PropertyKeys.ismap, ismap);
+ }
+
+ public String getLang() {
+ return (String) getStateHelper().eval(PropertyKeys.lang);
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public Date getLastModified() {
+ return (Date) getStateHelper().eval(PropertyKeys.lastModified);
+ }
+
+ public void setLastModified(Date lastModified) {
+ getStateHelper().put(PropertyKeys.lastModified, lastModified);
+ }
+
+ public String getMimeType() {
+ return (String) getStateHelper().eval(PropertyKeys.mimeType);
+ }
+
+ public void setMimeType(String mimeType) {
+ getStateHelper().put(PropertyKeys.mimeType, mimeType);
+ }
+
+ public String getOnblur() {
+ return (String) getStateHelper().eval(PropertyKeys.onblur);
+ }
+
+ public void setOnblur(String onblur) {
+ getStateHelper().put(PropertyKeys.onblur, onblur);
+ }
+
+ public String getOnclick() {
+ return (String) getStateHelper().eval(PropertyKeys.onclick);
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return (String) getStateHelper().eval(PropertyKeys.ondblclick);
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnfocus() {
+ return (String) getStateHelper().eval(PropertyKeys.onfocus);
+ }
+
+ public void setOnfocus(String onfocus) {
+ getStateHelper().put(PropertyKeys.onfocus, onfocus);
+ }
+
+ public String getOnkeydown() {
+ return (String) getStateHelper().eval(PropertyKeys.onkeydown);
+ }
+
+ public void setOnkeydown(String onkeydown) {
+ getStateHelper().put(PropertyKeys.onkeydown, onkeydown);
+ }
+
+ public String getOnkeypress() {
+ return (String) getStateHelper().eval(PropertyKeys.onkeypress);
+ }
+
+ public void setOnkeypress(String onkeypress) {
+ getStateHelper().put(PropertyKeys.onkeypress, onkeypress);
+ }
+
+ public String getOnkeyup() {
+ return (String) getStateHelper().eval(PropertyKeys.onkeyup);
+ }
+
+ public void setOnkeyup(String onkeyup) {
+ getStateHelper().put(PropertyKeys.onkeyup, onkeyup);
+ }
+
+ public String getOnmousedown() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousedown);
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousemove);
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseout);
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseover);
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseup);
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getRel() {
+ return (String) getStateHelper().eval(PropertyKeys.rel);
+ }
+
+ public void setRel(String rel) {
+ getStateHelper().put(PropertyKeys.rel, rel);
+ }
+
+ public String getRev() {
+ return (String) getStateHelper().eval(PropertyKeys.rev);
+ }
+
+ public void setRev(String rev) {
+ getStateHelper().put(PropertyKeys.rev, rev);
+ }
+
+ @Deprecated
+ public boolean isSession() {
+ return true;
+ }
+
+ @Deprecated
+ public void setSession(boolean session) {
+ if (!session) {
+ //TODO: log
+ }
+ }
+
+ public String getShape() {
+ return (String) getStateHelper().eval(PropertyKeys.shape);
+ }
+
+ public void setShape(String shape) {
+ getStateHelper().put(PropertyKeys.shape, shape);
+ }
+
+ public String getStandby() {
+ return (String) getStateHelper().eval(PropertyKeys.standby);
+ }
+
+ public void setStandby(String standby) {
+ getStateHelper().put(PropertyKeys.standby, standby);
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style);
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass);
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getTabindex() {
+ return (String) getStateHelper().eval(PropertyKeys.tabindex);
+ }
+
+ public void setTabindex(String tabindex) {
+ getStateHelper().put(PropertyKeys.tabindex, tabindex);
+ }
+
+ public String getTarget() {
+ return (String) getStateHelper().eval(PropertyKeys.target);
+ }
+
+ public void setTarget(String target) {
+ getStateHelper().put(PropertyKeys.target, target);
+ }
+
+ public String getTitle() {
+ return (String) getStateHelper().eval(PropertyKeys.title);
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getType() {
+ return (String) getStateHelper().eval(PropertyKeys.type);
+ }
+
+ public void setType(String type) {
+ getStateHelper().put(PropertyKeys.type, type);
+ }
+
+ public String getUriAttribute() {
+ return (String) getStateHelper().eval(PropertyKeys.uriAttribute);
+ }
+
+ public void setUriAttribute(String uriAttribute) {
+ getStateHelper().put(PropertyKeys.uriAttribute, uriAttribute);
+ }
+
+ public String getUsemap() {
+ return (String) getStateHelper().eval(PropertyKeys.usemap);
+ }
+
+ public void setUsemap(String usemap) {
+ getStateHelper().put(PropertyKeys.usemap, usemap);
+ }
+
+ public String getVspace() {
+ return (String) getStateHelper().eval(PropertyKeys.vspace);
+ }
+
+ public void setVspace(String vspace) {
+ getStateHelper().put(PropertyKeys.vspace, vspace);
+ }
+
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlOutputPanel.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlOutputPanel.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlOutputPanel.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,153 @@
+package org.richfaces.component.html;
+
+import org.richfaces.component.UIAjaxOutputPanel;
+
+public class HtmlOutputPanel extends UIAjaxOutputPanel {
+
+ static final public String COMPONENT_FAMILY = "javax.faces.Panel";
+
+ static final public String COMPONENT_TYPE = "org.richfaces.OutputPanel";
+
+ private static enum PropertyKeys {
+ dir, lang, layout, onclick, onmousemove, ondblclick, onkeydown, onkeypress,
+ onkeyup, onmousedown, title, style, onmouseout, onmouseover, onmouseup, styleClass
+ }
+
+ public HtmlOutputPanel() {
+ super();
+ setRendererType("org.richfaces.OutputPanelRenderer");
+ }
+
+ public String getDir() {
+ return (String) getStateHelper().eval(PropertyKeys.dir);
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+ public String getLang() {
+ return (String) getStateHelper().eval(PropertyKeys.lang);
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public String getLayout() {
+ return (String) getStateHelper().eval(PropertyKeys.layout, "inline");
+ }
+
+ public void setLayout(String layout) {
+ getStateHelper().put(PropertyKeys.layout, layout);
+ }
+
+ public String getOnclick() {
+ return (String) getStateHelper().eval(PropertyKeys.onclick);
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return (String) getStateHelper().eval(PropertyKeys.ondblclick);
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnkeydown() {
+ return (String) getStateHelper().eval(PropertyKeys.onkeydown);
+ }
+
+ public void setOnkeydown(String onkeydown) {
+ getStateHelper().put(PropertyKeys.onkeydown, onkeydown);
+ }
+
+ public String getOnkeypress() {
+ return (String) getStateHelper().eval(PropertyKeys.onkeypress);
+ }
+
+ public void setOnkeypress(String onkeypress) {
+ getStateHelper().put(PropertyKeys.onkeypress, onkeypress);
+ }
+
+ public String getOnkeyup() {
+ return (String) getStateHelper().eval(PropertyKeys.onkeyup);
+ }
+
+ public void setOnkeyup(String onkeyup) {
+ getStateHelper().put(PropertyKeys.onkeyup, onkeyup);
+ }
+
+ public String getOnmousedown() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousedown);
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousemove);
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseout);
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseover);
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseup);
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style);
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass);
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getTitle() {
+ return (String) getStateHelper().eval(PropertyKeys.title);
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlPush.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlPush.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlPush.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.html;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+
+import org.richfaces.component.UIPush;
+
+public class HtmlPush extends UIPush {
+
+ public final static String COMPONENT_FAMILY = "org.richfaces.Push";
+
+ public final static String COMPONENT_TYPE = "org.richfaces.Push";
+
+ public HtmlPush(){
+ setRendererType("org.richfaces.PushRenderer");
+ }
+
+ public String getFamily(){
+ return COMPONENT_FAMILY;
+ }
+
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,140 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
+import javax.faces.component.html.HtmlCommandButton;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.component.AjaxComponent;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
+ *
+ */
+public abstract class AjaxCommandRendererBase extends AjaxComponentRendererBase {
+
+ private static final Log _log = LogFactory
+ .getLog(AjaxCommandRendererBase.class);
+
+ protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
+
+ // super.decode must not be called, because value is handled here
+ if (isSubmitted(facesContext, uiComponent)) {
+ ActionEvent event;
+ event = new ActionEvent(uiComponent);
+ uiComponent.queueEvent(event);
+ uiComponent.queueEvent(new AjaxEvent(uiComponent));
+ // Check areas for processing
+ if (uiComponent instanceof AjaxComponent) {
+ AjaxComponent ajaxComponent = (AjaxComponent) uiComponent;
+ Set<String> toProcess = AjaxRendererUtils.asSet(ajaxComponent
+ .getProcess());
+ if (null != toProcess) {
+ Set<String> componentIdsToProcess = new LinkedHashSet<String>();
+ for (String componentId : toProcess) {
+ UIComponent component = getUtils().findComponentFor(uiComponent, componentId);
+ if(null != component){
+ componentIdsToProcess.add(component.getClientId(facesContext));
+ } else {
+ componentIdsToProcess.add(componentId);
+ }
+ }
+ AjaxContext.getCurrentInstance(facesContext).setAjaxAreasToProcess(componentIdsToProcess);
+ }
+ }
+ }
+ }
+
+ public String getOnClick(FacesContext context, UIComponent component) {
+ StringBuffer onClick;
+ if (!getUtils().isBooleanAttribute(component, "disabled")) {
+ onClick = AjaxRendererUtils.buildOnClick(component, context, true);
+ if (!"reset".equals(component.getAttributes().get("type"))) {
+ onClick.append(";return false;");
+ }
+ } else {
+ onClick = new StringBuffer("return false;");
+ }
+ return onClick.toString();
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ renderChildren(context, component);
+ }
+
+ public Object getValue(UIComponent uiComponent) {
+ if (uiComponent instanceof ValueHolder) {
+ return ((ValueHolder) uiComponent).getValue();
+ }
+ return uiComponent.getAttributes().get("value");
+ }
+
+ public String getType(UIComponent uiComponent) {
+ String type;
+ if (uiComponent instanceof HtmlCommandButton) {
+ type = ((HtmlCommandButton) uiComponent).getType();
+ } else {
+ type = (String) uiComponent.getAttributes().get("type");
+ }
+ if (type == null) {
+ type = "button";
+ }
+ return type;
+ }
+
+ protected boolean isSubmitted(FacesContext facesContext,
+ UIComponent uiComponent) {
+ // Componet accept only ajax requests.
+ if (!AjaxContext.getCurrentInstance(facesContext).isAjaxRequest()) {
+ return false;
+ }
+ if (getUtils().isBooleanAttribute(uiComponent, "disabled")) {
+ return false;
+ }
+ String clientId = uiComponent.getClientId(facesContext);
+ Map<String, String> paramMap = facesContext.getExternalContext()
+ .getRequestParameterMap();
+ Object value = paramMap.get(clientId);
+ boolean submitted = null != value;
+ if (submitted && _log.isDebugEnabled()) {
+ _log.debug("Decode submit of the Ajax component " + clientId);
+ }
+ return submitted;
+ }
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,32 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import javax.faces.render.Renderer;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class AjaxComponentRendererBase extends Renderer {
+
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,118 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.component.UIAjaxFunction;
+
+/**
+ * @author shura
+ *
+ */
+@ResourceDependencies(value = {
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js")
+ })
+public class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIAjaxFunction.class;
+ }
+
+ public String getFunction(FacesContext context, UIAjaxFunction component) {
+ String functionName = component.getName();
+ if (functionName == null) {
+ throw new FacesException("Value of 'name' attribute of a4j:jsFunction component is null!");
+ }
+
+ StringBuffer script = new StringBuffer(functionName).append("=");
+ JSFunctionDefinition func = new JSFunctionDefinition();
+ //func.setName(component.getName());
+ // Create AJAX Submit function.
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
+ component, context, AjaxRendererUtils.AJAX_FUNCTION_NAME);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, component);
+ ajaxFunction.addParameter(options);
+
+ Map<String, Object> parameters = options;
+// if (null == parameters) {
+// parameters = new HashMap<String, Object>();
+// options.put("parameters", parameters);
+// }
+ // Fill parameters.
+ for (Iterator<UIComponent> it = component.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = it.next();
+ if (child instanceof UIParameter) {
+ UIParameter parameter = ((UIParameter) child);
+ String name = parameter.getName();
+ func.addParameter(name);
+ // Put parameter name to AJAX.Submit parameter, with default value.
+ JSReference reference = new JSReference(name);
+ if (null != parameter.getValue()) {
+ reference = new JSReference(name + "||"
+ + ScriptUtils.toScript(parameters.get(name)));
+
+ }
+ // Replace parameter value to reference.
+ parameters.put(name, reference);
+ }
+ }
+
+ //TODO - added in 4.0 - ?
+ func.addParameter(new JSReference("event"));
+
+ func.addToBody(ajaxFunction.toScript());
+ func.appendScript(script);
+ return script.toString();
+ }
+
+ @Override
+ protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
+ Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
+ String clientId = uiComponent.getClientId(facesContext);
+
+ if (requestParameterMap.get(clientId) != null) {
+ new ActionEvent(uiComponent).queue();
+ }
+ }
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/CommandRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/CommandRendererBase.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/CommandRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,42 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class CommandRendererBase extends Renderer {
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ public void decode(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ super.decode(context, component);
+ }
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.renderkit.AjaxCommandRendererBase;
+import org.richfaces.renderkit.CommandRendererBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AjaxCommandButtonRendererBase extends AjaxCommandRendererBase {
+
+ protected void encodeTypeAndImage(FacesContext context, UIComponent uiComponent) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ String type = (String)uiComponent.getAttributes().get("type");
+ String image = (String)uiComponent.getAttributes().get("image");
+ if(image != null){
+ image = context.getApplication().getViewHandler().getResourceURL(context,image);
+ image = context.getExternalContext().encodeResourceURL(image);
+ writer.writeAttribute("type","image","image");
+ writer.writeURIAttribute("src",image,"image");
+ Object value;
+ if (null == uiComponent.getAttributes().get("alt") && null != (value = uiComponent.getAttributes().get("value")) ) {
+ writer.writeAttribute("alt",value,"value");
+ }
+ } else {
+ if(null != type ){
+ writer.writeAttribute("type",type.toLowerCase(),"type");
+ } else {
+ writer.writeAttribute("type","button","type");
+ }
+ }
+ }
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxFunctionRenderer1.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFunctionRenderer.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxFunctionRenderer1.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxFunctionRenderer1.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,53 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIAjaxFunction;
+import org.richfaces.renderkit.AjaxFunctionRendererBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class AjaxFunctionRenderer1 extends AjaxFunctionRendererBase {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, component.getClientId(context), "id");
+ writer.writeText(getFunction(context, (UIAjaxFunction) component), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,149 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIAjaxOutputPanel;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:27 $
+ *
+ */
+public class AjaxOutputPanelRenderer extends RendererBase {
+
+ private final String[] STYLE_ATTRIBUTES = new String[]{"style","class"};
+
+ private boolean hasNoneLayout(UIComponent component) {
+ //TODO - A1 won't support 'none' layout
+ return false;//"none".equals(component.getAttributes().get("layout"));
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ //
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (hasNoneLayout(panel)) {
+ if (component.getChildCount() > 0) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ boolean ajaxRequest = ajaxContext.isAjaxRequest();
+ Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
+ for (UIComponent child : component.getChildren()) {
+ String childId = child.getClientId(context);
+ if (child.isRendered()) {
+ renderChild(context, child);
+ } else {
+ // Render "dummy" span.
+ ResponseWriter out = context.getResponseWriter();
+ out.startElement(HTML.SPAN_ELEM,child);
+ out.writeAttribute(HTML.id_ATTRIBUTE,childId,HTML.id_ATTRIBUTE);
+ out.writeAttribute(HTML.style_ATTRIBUTE,"display: none;","style");
+ out.endElement(HTML.SPAN_ELEM);
+ }
+ // register child as rendered
+ if(ajaxRequest && null != ajaxRenderedAreas) {
+ ajaxRenderedAreas.add(childId);
+ }
+ }
+ }
+ } else {
+ renderChildren(context,component);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIAjaxOutputPanel.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (!hasNoneLayout(component)) {
+ writer.startElement(getTag(panel), panel);
+ getUtils().encodeId(context, component);
+ getUtils().encodePassThru(context, component);
+ getUtils().encodeAttributesFromArray(context,component,STYLE_ATTRIBUTES);
+ }
+ }
+
+ /**
+ * @param panel
+ * @return
+ */
+ private String getTag(UIAjaxOutputPanel panel) {
+ Object layout = panel.getAttributes().get("layout");
+ return "block".equals(layout) ? HTML.DIV_ELEM : HTML.SPAN_ELEM;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (!hasNoneLayout(component)) {
+ writer.endElement(getTag(panel));
+ }
+ if (panel.isKeepTransient()) {
+ markNoTransient(component);
+ }
+ }
+
+ /**
+ * Set "transient" flag to false for component and all its children ( recursive ).
+ * @param component
+ */
+ private void markNoTransient(UIComponent component) {
+ for (Iterator<UIComponent> iter = component.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent element = iter.next();
+ markNoTransient(element);
+ element.setTransient(false);
+ }
+
+ }
+
+
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,128 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIPush;
+
+/**
+ * @author shura
+ *
+ */
+@ResourceDependencies(value = {
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js")
+})
+public class AjaxPushRenderer extends RendererBase {
+
+ public static final String PUSH_INTERVAL_PARAMETER = "A4J.AJAX.Push.INTERVAL";
+
+ public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
+
+ @Deprecated
+ public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
+
+ public static final int DEFAULT_PUSH_INTERVAL = 1000;
+
+ public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
+
+ private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ UIPush push = (UIPush) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
+ getUtils().encodeId(context, component);
+
+ //TODO - ?
+ getUtils().encodeBeginFormIfNessesary(context, component);
+ // pushing script.
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if (push.isEnabled()) {
+ JSFunction function = new JSFunction("RichFaces.startPush");
+ // Set dummy form id, if nessesary.
+ Map<String, Object> options = new HashMap<String, Object>();
+
+ int interval = push.getInterval();
+ if (!getUtils().shouldRenderAttribute(interval)) {
+ String intervalInitParameter = context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
+ if(null != intervalInitParameter){
+ interval = Integer.parseInt(intervalInitParameter);
+ } else {
+ interval = DEFAULT_PUSH_INTERVAL;
+ }
+ }
+
+ options.put("interval", new Integer(interval));
+ options.put("pushId", push.getListenerId(context));
+ ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext(context, push, push.getDefaultEventName(), push.getClientId(context), null);
+ ClientBehavior clientBehavior = push.getClientBehaviors().get(push.getDefaultEventName()).get(0);
+ options.put(UIPush.ON_DATA_AVAILABLE, new JSFunctionDefinition("event").addToBody(clientBehavior.getScript(behaviorContext)));
+ function.addParameter(options);
+ script.append(function.toScript());
+ } else {
+ script.append("RichFaces.stopPush('").append(push.getListenerId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(),null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ getUtils().encodeEndFormIfNessesary(context, component);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class<? extends UIComponent> getComponentClass() {
+ // only push component is allowed.
+ return UIPush.class;
+ }
+
+// protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
+// boolean submitted = super.isSubmitted(facesContext, uiComponent);
+// UIPush push = (UIPush) uiComponent;
+// push.setSubmitted(submitted);
+// return submitted;
+// }
+
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,128 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIMediaOutput;
+
+/**
+ * @author shura
+ *
+ */
+public class MediaOutputRenderer extends RendererBase {
+
+ public static final String RENDERER_TYPE = "org.richfaces.MediaOutputRenderer";
+
+ /**
+ * Associationd between element name and uri attributes
+ */
+ private static final Map<String, String> uriAttributes;
+
+ static {
+ uriAttributes = new HashMap<String, String>();
+ uriAttributes.put("a","href");
+ uriAttributes.put("img","src");
+ uriAttributes.put("object","data");
+ uriAttributes.put("link","href");
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ UIMediaOutput mmedia = (UIMediaOutput) component;
+ String element = mmedia.getElement();
+ if(null == element){
+ throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
+ }
+ writer.endElement(element);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class<? extends UIComponent> getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIMediaOutput.class;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ UIMediaOutput mmedia = (UIMediaOutput) component;
+ String element = mmedia.getElement();
+ if(null == element){
+ throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
+ }
+ String uriAttribute = mmedia.getUriAttribute();
+ // Check for pre-defined attributes
+ if(null == uriAttribute){
+ uriAttribute = (String) uriAttributes.get(element);
+
+ if (null == uriAttribute) {
+ throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"uriAttribute",component.getClientId(context)));
+ }
+ }
+ writer.startElement(element,mmedia);
+ getUtils().encodeId(context, component);
+
+ StringBuilder uri = new StringBuilder(mmedia.getResource().getRequestPath());
+ // Append parameters to resource Uri
+ boolean haveQestion = uri.indexOf("?") >= 0;
+ for (UIComponent child : component.getChildren()) {
+ if (child instanceof UIParameter) {
+ UIParameter uiParam = (UIParameter) child;
+ String name = uiParam.getName();
+ Object value = uiParam.getValue();
+ if(null != value){
+ if(haveQestion){
+ uri.append('&');
+ } else {
+ uri.append('?');
+ haveQestion = true;
+ }
+ uri.append(name).append('=').append(value.toString());
+ }
+ }
+ }
+ writer.writeURIAttribute(uriAttribute,uri,"uri");
+ getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
+ getUtils().encodePassThru(context, mmedia);
+ }
+
+}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -21,22 +21,88 @@
package org.richfaces.resource;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIMediaOutput;
+
/**
* @author Nick Belaevski
* @since 4.0
*/
-public class MediaOutputResource extends AbstractBaseResource {
+public class MediaOutputResource extends AbstractBaseResource implements StateHolder {
+ private Object userData;
+
+ private MethodExpression contentProducer;
+
+ /*
+ * TODO: add handling for expressions:
+ *
+ * 1. State saving
+ * 2. Evaluation
+ */
+ private ValueExpression lastModifiedExpression;
+
+ private ValueExpression expiresExpression;
+
+ private ValueExpression timeToLiveExpression;
+
@Override
public InputStream getInputStream() {
- // TODO Auto-generated method stub
- return null;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ contentProducer.invoke(facesContext.getELContext(), new Object[]{baos, userData});
+ return new ByteArrayInputStream(baos.toByteArray());
}
- @Override
- public void setCacheable(boolean cacheable) {
- super.setCacheable(cacheable);
+ public boolean isTransient() {
+ return false;
}
+
+ public void setTransient(boolean newTransientValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[4];
+
+ //parent fields state saving
+ state[0] = isCacheable(context) ? Boolean.TRUE : Boolean.FALSE;
+ state[1] = getContentType();
+ state[2] = UIComponentBase.saveAttachedState(context, userData);
+ state[3] = UIComponentBase.saveAttachedState(context, contentProducer);
+
+ return state;
+ }
+
+ public void restoreState(FacesContext context, Object stateObject) {
+ Object[] state = (Object[]) stateObject;
+
+ setCacheable((Boolean) state[0]);
+ setContentType((String) state[1]);
+ userData = UIComponentBase.restoreAttachedState(context, state[2]);
+ contentProducer = (MethodExpression) UIComponentBase.restoreAttachedState(context, state[3]);
+ }
+
+ /**
+ * @param uiMediaOutput
+ */
+ //TODO use ResourceComponent or exchange object as argument?
+ public void initialize(UIMediaOutput uiMediaOutput) {
+ this.setCacheable(uiMediaOutput.isCacheable());
+ this.setContentType(uiMediaOutput.getMimeType());
+ this.userData = uiMediaOutput.getValue();
+ this.contentProducer = uiMediaOutput.getCreateContentExpression();
+ this.lastModifiedExpression = uiMediaOutput.getValueExpression("lastModfied");
+ this.expiresExpression = uiMediaOutput.getValueExpression("expires");
+ this.timeToLiveExpression = uiMediaOutput.getValueExpression("timeToLive");
+ }
}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets (from rev 15175, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets)
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxPushHandler.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxPushHandler.java 2009-08-14 08:20:51 UTC (rev 15175)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxPushHandler.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.taglib.html.facelets;
+package org.richfaces.taglib.html.facelets;
import java.util.EventListener;
@@ -32,27 +32,31 @@
import javax.faces.view.facelets.MetadataTarget;
import javax.faces.view.facelets.TagAttribute;
-import org.ajax4jsf.component.UIPush;
+import org.richfaces.component.UIPush;
/**
* @author shura (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
+ * @version $Revision$ $Date: 2009-07-31 14:34:48 +0300 (Пт, 31 июл
+ * 2009) $
+ *
*/
public class AjaxPushHandler extends ComponentHandler {
private static final MetaRule ajaxPushMetaRule = new AjaxPushMetaRule();
-
+
/**
* @param config
*/
public AjaxPushHandler(ComponentConfig config) {
super(config);
-
+
}
- /* (non-Javadoc)
- * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
*/
protected MetaRuleset createMetaRuleset(Class type) {
MetaRuleset metaRules = super.createMetaRuleset(type);
@@ -62,10 +66,11 @@
/**
* @author shura (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
+ * @version $Revision$ $Date: 2009-07-31 14:34:48 +0300 (Пт, 31
+ * июл 2009) $
+ *
*/
- static class AjaxPushMetaRule extends MetaRule{
+ static class AjaxPushMetaRule extends MetaRule {
/**
*
@@ -74,31 +79,38 @@
super();
}
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String, com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
+ * com.sun.facelets.tag.TagAttribute,
+ * com.sun.facelets.tag.MetadataTarget)
*/
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UIPush.class)) {
+ public Metadata applyRule(String name, TagAttribute attribute,
+ MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIPush.class)) {
-
- if ("eventProducer".equals(name)) {
- return new AjaxPushActionMapper(attribute);
- }
- }
+ if ("eventProducer".equals(name)) {
+ return new AjaxPushActionMapper(attribute);
+ }
+ }
return null;
}
}
+
/**
* @author shura (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
+ * @version $Revision$ $Date: 2009-07-31 14:34:48 +0300 (Пт, 31
+ * июл 2009) $
+ *
*/
static class AjaxPushActionMapper extends Metadata {
- private static final Class<?>[] AJAX_PUSH_ACTION_SIG = new Class[] {EventListener.class};
+ private static final Class<?>[] AJAX_PUSH_ACTION_SIG = new Class[] { EventListener.class };
private final TagAttribute _send;
+
/**
* @param attribute
*/
@@ -106,12 +118,15 @@
_send = attribute;
}
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext, java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @seecom.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.
+ * FaceletContext, java.lang.Object)
*/
public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIPush) instance).setEventProducer(this._send.getMethodExpression(ctx, null,
- AJAX_PUSH_ACTION_SIG));
+ ((UIPush) instance).setEventProducer(this._send
+ .getMethodExpression(ctx, null, AJAX_PUSH_ACTION_SIG));
}
}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/MediaOutputHandler.java (from rev 15053, root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/MediaOutputHandler.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/MediaOutputHandler.java 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,124 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.taglib.html.facelets;
+
+import java.io.OutputStream;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.UIMediaOutput;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+public class MediaOutputHandler extends ComponentHandler {
+
+ private static final MetaRule mmediaMetaRule = new MMediaMetaRule();
+
+ /**
+ * @param config
+ */
+ public MediaOutputHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRules = super.createMetaRuleset(type);
+ metaRules.addRule(mmediaMetaRule);
+ return metaRules;
+ }
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+ static class MMediaMetaRule extends MetaRule {
+
+ /**
+ *
+ */
+ public MMediaMetaRule() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
+ * com.sun.facelets.tag.TagAttribute,
+ * com.sun.facelets.tag.MetadataTarget)
+ */
+ public Metadata applyRule(String name, TagAttribute attribute,
+ MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIMediaOutput.class)) {
+ if ("createContent".equals(name)) {
+ return new MMediaActionMapper(attribute);
+ }
+ }
+ return null;
+ }
+
+ }
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+ static class MMediaActionMapper extends Metadata {
+
+ private static final Class<?>[] MMEDIA_ACTION_SIG = new Class[] {
+ OutputStream.class, Object.class };
+
+ private final TagAttribute _send;
+
+ /**
+ * @param attribute
+ */
+ public MMediaActionMapper(TagAttribute attribute) {
+ _send = attribute;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seecom.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.
+ * FaceletContext, java.lang.Object)
+ */
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIMediaOutput) instance).setCreateContentExpression(this._send
+ .getMethodExpression(ctx, null, MMEDIA_ACTION_SIG));
+ }
+
+ }
+
+}
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2009-08-18 09:40:41 UTC (rev 15191)
@@ -6,17 +6,32 @@
<tag>
<tag-name>push</tag-name>
<component>
- <component-type>org.ajax4jsf.Push</component-type>
- <renderer-type>org.ajax4jsf.PushRenderer</renderer-type>
- <handler-class>org.ajax4jsf.taglib.html.facelets.AjaxPushHandler</handler-class>
+ <component-type>org.richfaces.Push</component-type>
+ <renderer-type>org.richfaces.PushRenderer</renderer-type>
+ <handler-class>org.richfaces.taglib.html.facelets.AjaxPushHandler</handler-class>
</component>
</tag>
<tag>
<tag-name>jsFunction</tag-name>
<component>
- <component-type>org.ajax4jsf.Function</component-type>
- <renderer-type>org.ajax4jsf.FunctionRenderer</renderer-type>
+ <component-type>org.richfaces.Function</component-type>
+ <renderer-type>org.richfaces.FunctionRenderer</renderer-type>
</component>
</tag>
+ <tag>
+ <tag-name>outputPanel</tag-name>
+ <component>
+ <component-type>org.richfaces.OutputPanel</component-type>
+ <renderer-type>org.richfaces.OutputPanelRenderer</renderer-type>
+ </component>
+ </tag>
+ <tag>
+ <tag-name>mediaOutput</tag-name>
+ <component>
+ <component-type>org.richfaces.MediaOutput</component-type>
+ <renderer-type>org.richfaces.MediaOutputRenderer</renderer-type>
+ <handler-class>org.richfaces.taglib.html.facelets.MediaOutputHandler</handler-class>
+ </component>
+ </tag>
</facelet-taglib>
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml 2009-08-18 09:24:53 UTC (rev 15190)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml 2009-08-18 09:40:41 UTC (rev 15191)
@@ -10,26 +10,46 @@
</managed-bean>
<component>
- <component-type>org.ajax4jsf.Push</component-type>
- <component-class>org.ajax4jsf.component.html.HtmlPush</component-class>
+ <component-type>org.richfaces.Push</component-type>
+ <component-class>org.richfaces.component.html.HtmlPush</component-class>
</component>
<component>
- <component-type>org.ajax4jsf.Function</component-type>
- <component-class>org.ajax4jsf.component.html.HtmlAjaxFunction</component-class>
+ <component-type>org.richfaces.Function</component-type>
+ <component-class>org.richfaces.component.html.HtmlAjaxFunction</component-class>
</component>
+ <component>
+ <component-type>org.richfaces.MediaOutput</component-type>
+ <component-class>org.richfaces.component.html.HtmlMediaOutput</component-class>
+ </component>
+
+ <component>
+ <component-type>org.richfaces.OutputPanel</component-type>
+ <component-class>org.richfaces.component.html.HtmlOutputPanel</component-class>
+ </component>
+
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
- <component-family>org.ajax4jsf.Push</component-family>
- <renderer-type>org.ajax4jsf.PushRenderer</renderer-type>
- <renderer-class>org.ajax4jsf.renderkit.html.AjaxPushRenderer</renderer-class>
+ <component-family>org.richfaces.Push</component-family>
+ <renderer-type>org.richfaces.PushRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.AjaxPushRenderer</renderer-class>
</renderer>
<renderer>
- <component-family>org.ajax4jsf.Function</component-family>
- <renderer-type>org.ajax4jsf.FunctionRenderer</renderer-type>
- <renderer-class>org.ajax4jsf.renderkit.html.AjaxFunctionRenderer</renderer-class>
+ <component-family>javax.faces.Command</component-family>
+ <renderer-type>org.richfaces.FunctionRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.AjaxFunctionRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>org.richfaces.MediaOutput</component-family>
+ <renderer-type>org.richfaces.MediaOutputRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.MediaOutputRenderer</renderer-class>
+ </renderer>
+ <renderer>
+ <component-family>javax.faces.Panel</component-family>
+ <renderer-type>org.richfaces.OutputPanelRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.AjaxOutputPanelRenderer</renderer-class>
+ </renderer>
</render-kit>
</faces-config>
\ No newline at end of file
Added: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml (rev 0)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://richfaces.org/xhtml-el" xmlns:cdk="http://richfaces.org/cdk"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ class="org.richfaces.renderkit.html.CommandButtonRenderer"
+ superclass="org.richfaces.renderkit.html.AjaxCommandButtonRendererBase"
+ componentclass="org.richfaces.component.UIAjaxCommandButton">
+
+ <!-- f:clientid var="clientId"/ -->
+
+ <input
+ id="#{clientId}"
+ name="#{clientId}"
+ value="#{this.getValue(component)}"
+ cdk:passThroughWithExclusions="value name onclick type id class"
+ onclick="#{this.getOnClick(context,component)}"
+ class="#{component.attributes['styleClass']}"
+ >
+ <cdk:call expression="encodeTypeAndImage(context,component);" />
+ </input>
+
+</cdk:root>
Added: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml (rev 0)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cdk:root xmlns="http://richfaces.org/xhtml-el" xmlns:cdk="http://richfaces.org/cdk"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ class="org.richfaces.renderkit.html.AjaxFunctionRenderer"
+ superclass="org.richfaces.renderkit.AjaxFunctionRendererBase"
+ componentclass="org.richfaces.component.UIAjaxFunction">
+
+ <!-- f:clientid var="clientId"/ -->
+ <span id="#{clientId}" style="display: none;">
+ <script type="text/javascript">
+ #{this.getFunction(context,component)};
+ </script>
+ </span>
+</cdk:root>
Added: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml (rev 0)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://richfaces.org/xhtml-el" xmlns:cdk="http://richfaces.org/cdk"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ class="org.richfaces.renderkit.html.CommandLinkRenderer"
+ superclass="org.richfaces.renderkit.AjaxCommandRendererBase"
+ componentclass="org.richfaces.component.UIAjaxCommandLink">
+
+ <!-- f:clientid var="clientId"/ -->
+ <a
+ id="#{clientId}"
+ name="#{clientId}"
+ type="#{component.attributes['type']}"
+ cdk:passThroughWithExclusions="value name onclick type href id"
+ onclick="#{this.getOnClick(context,component)}"
+ href="#"
+ class="#{component.attributes['styleClass']}"
+ >
+ #{this.getValue(component)}
+ <cdk:body>
+ <cdk:call expression="renderChildren(context,component);" />
+ </cdk:body>
+ </a>
+</cdk:root>
\ No newline at end of file
Added: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml (rev 0)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2009-08-18 09:40:41 UTC (rev 15191)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://richfaces.org/xhtml-el" xmlns:cdk="http://richfaces.org/cdk"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ class="org.richfaces.renderkit.html.LogRenderer"
+ superclass="org.richfaces.renderkit.AjaxComponentRendererBase"
+ componentclass="org.richfaces.component.UIAjaxLog">
+
+ <!-- f:clientid var="clientId"/ -->
+ <cdk:choose>
+ <cdk:when test="#{component.isPopup()}">
+ <script id="#{clientId}" type="text/javascript">
+ LOG.registerPopup(
+ '#{component.attributes["hotkey"]}',
+ '#{component.attributes["name"]}',
+ #{component.attributes["width"]},
+ #{component.attributes["height"]},
+ LOG.#{component.attributes["level"]});
+ </script>
+ </cdk:when>
+ <cdk:otherwise>
+ <div id="richfaces.log"
+ style='width:#{component.attributes["width"]};height:#{component.attributes["height"]};overflow:auto;#{component.attributes["style"]}'
+ cdk:passThroughWithExclusions="value name id style">
+ <button>Clear</button><br />
+ <script type="text/javascript">
+ LOG.LEVEL = LOG.#{component.attributes["level"]};
+ </script>
+ </div>
+ </cdk:otherwise>
+ </cdk:choose>
+</cdk:root>
15 years, 4 months
JBoss Rich Faces SVN: r15190 - root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-18 05:24:53 -0400 (Tue, 18 Aug 2009)
New Revision: 15190
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java
Log:
BuildLibraryMojo: generated resources directories added as compilation roots
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java 2009-08-18 00:57:37 UTC (rev 15189)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java 2009-08-18 09:24:53 UTC (rev 15190)
@@ -119,6 +119,10 @@
outputResourcesDirectory.mkdirs();
outputTestsDirectory.mkdirs();
+ project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
+ project.addCompileSourceRoot(outputResourcesDirectory.getAbsolutePath());
+ project.addTestCompileSourceRoot(outputTestsDirectory.getAbsolutePath());
+
compileTemplates();
}
15 years, 4 months
JBoss Rich Faces SVN: r15189 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/generate/java and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-08-17 20:57:37 -0400 (Mon, 17 Aug 2009)
New Revision: 15189
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
Log:
generate component classes
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-18 00:57:04 UTC (rev 15188)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-18 00:57:37 UTC (rev 15189)
@@ -15,7 +15,7 @@
* @author asmirnov(a)exadel.com
*
*/
-final class RichFacesConventions implements NamingConventions {
+public final class RichFacesConventions implements NamingConventions {
private static final String ABSTRACT = "Abstract";
private static final String UI = "UI";
@@ -31,7 +31,7 @@
* <p class="changed_added_4_0"></p>
* @param componentLibrary
*/
- RichFacesConventions(String baseName) {
+ public RichFacesConventions(String baseName) {
this.baseName = baseName;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-18 00:57:04 UTC (rev 15188)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-18 00:57:37 UTC (rev 15189)
@@ -23,34 +23,52 @@
package org.richfaces.cdk.generate.java;
+import java.io.File;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
+import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.JsfComponent;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class ComponentClassGenerator implements CdkWriter {
+public class ComponentClassGenerator extends FreeMarkerRenderer<Component, String> implements CdkWriter {
/* (non-Javadoc)
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
*/
@Override
- public void init(CdkContext context) {
- // TODO Auto-generated method stub
+ public void init(CdkContext context) throws CdkException {
+ super.init(context);
}
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
- */
+
@Override
- public void render(ComponentLibrary library) throws CdkException {
- // TODO Auto-generated method stub
+ protected boolean isMyComponent(JsfComponent c) {
+ if (c instanceof Component) {
+ Component component = (Component) c;
+ return !component.isExists();
+ }
+ return false;
+ }
+
+ @Override
+ protected String getOutputFile(Component c) {
+ File sourceOutput = getContext().getJavaSourceOutput();
+ return (new File(sourceOutput,c.getComponentClass().getName().replace('.', File.separatorChar)+".java")).getAbsolutePath();
}
+
+ @Override
+ protected String getTemplateName() {
+ return "component.ftl";
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-18 00:57:04 UTC (rev 15188)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-18 00:57:37 UTC (rev 15189)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import javax.annotation.Generated;
+
import com.google.common.collect.ImmutableMap;
/**
@@ -132,6 +134,32 @@
}
/**
+ * <p class="changed_added_4_0"></p>
+ * @return package name.
+ */
+ public String getPackage() {
+ int indexOfPeriod = name.lastIndexOf('.');
+ if(indexOfPeriod>0){
+ return name.substring(0,indexOfPeriod);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return package name.
+ */
+ public String getSimpleName() {
+ int indexOfPeriod = name.lastIndexOf('.');
+ if(indexOfPeriod>0){
+ return name.substring(indexOfPeriod+1);
+ } else {
+ return name;
+ }
+ }
+
+ /**
* <p class="changed_added_4_0">
* </p>
*
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2009-08-18 00:57:37 UTC (rev 15189)
@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package ${componentClass.package};
+
+// Import declarations
+import javax.annotation.Generated;
+
+/**
+ * ${description}
+ **/
+@Generated({"RicFaces CDK","4.0.0-SNAPSHOT"})
+public class ${componentClass.simpleName} extends ${baseClass} {
+
+
+ public static final String COMPONENT_TYPE="${type}";
+
+ public static final String COMPONENT_FAMILY="${family}";
+
+ protected enum Properties {
+ [#list component.attributes as attribute]
+ [#if attribute.exists == false ]
+ ${attribute.hame},
+ [/#if]
+ [/#list]
+ ;
+ String toString;
+ PropertyKeys(String toString) { this.toString = toString; }
+ PropertyKeys() { }
+ public String toString() {
+ return ((toString != null) ? toString : super.toString());
+ }
+ }
+
+ [#list component.attributes as attribute]
+ [#if attribute.exists == false ]
+ /**
+ * ${attribute.description}
+ **/
+ public ${attribute.type} get${attribute.name}(){
+ return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
+ }
+
+ /**
+ * Setter for ${attribute.name}
+ **/
+ public void set${attribute.name}(${attribute.type} ${attribute.name}){
+ getStateHelper().put(Properties.${attribute.name},${attribute.name});
+ }
+ [/#if]
+ [/#list]
+
+}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-08-18 00:57:04 UTC (rev 15188)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-08-18 00:57:37 UTC (rev 15189)
@@ -45,13 +45,17 @@
private final String expectedCanonicalName;
private final String expectedBoxedName;
private final String expectedTypeParameter;
+ private final String packageName;
+ private final String simpleName;
- public ClassDescriptionTest(String className,String expectedCanonicalName,String expectedBoxedName,String expectedTypeParameter) {
+ public ClassDescriptionTest(String className,String expectedCanonicalName,String expectedBoxedName,String expectedTypeParameter, String packageName, String simpleName) {
this.className = className;
this.expectedCanonicalName = expectedCanonicalName;
this.expectedBoxedName = expectedBoxedName;
this.expectedTypeParameter = expectedTypeParameter;
-
+ this.packageName = packageName;
+ this.simpleName = simpleName;
+
}
/**
* Test method for {@link org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
@@ -63,13 +67,16 @@
assertEquals(expectedCanonicalName, description.getName());
assertEquals(expectedBoxedName, description.getBoxingName());
assertEquals(expectedTypeParameter, description.getTypeParameters());
+ assertEquals(packageName, description.getPackage());
+ assertEquals(simpleName, description.getSimpleName());
+
}
@Parameters
public static Collection<String[]> values(){
- return Arrays.asList(new String[]{int.class.getName(),"int","java.lang.Integer",null},
- new String[]{"java.util.List<String>","java.util.List","java.util.List<String>","<String>"},
- new String[]{double.class.getName(),"double","java.lang.Double",null});
+ return Arrays.asList(new String[]{int.class.getName(),"int","java.lang.Integer",null,null,"int"},
+ new String[]{"java.util.List<String>","java.util.List","java.util.List<String>","<String>","java.util","List"},
+ new String[]{double.class.getName(),"double","java.lang.Double",null,null,"double"});
}
}
15 years, 4 months
JBoss Rich Faces SVN: r15188 - root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-08-17 20:57:04 -0400 (Mon, 17 Aug 2009)
New Revision: 15188
Added:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java
Log:
New build mojo created
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-08-17 23:31:33 UTC (rev 15187)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-08-18 00:57:04 UTC (rev 15188)
@@ -36,6 +36,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@@ -43,6 +44,7 @@
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
@@ -141,7 +143,7 @@
* @required
* @readonly
*/
- protected List compileSourceRoots;
+ protected List<File> compileSourceRoots;
/**
* Project classpath.
*
@@ -358,4 +360,23 @@
getLog().debug("Taglib version is " + taglib.getTlibVersion());
}
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
+ throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException(
+ "Error scanning source root: \'" + rootFolder + "\'", e );
+ }
+ }
+
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java 2009-08-17 23:31:33 UTC (rev 15187)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java 2009-08-18 00:57:04 UTC (rev 15188)
@@ -29,7 +29,6 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.DirectoryScanner;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.render.JavaClassRenderer;
import org.richfaces.builder.templates.TemplateReader;
@@ -79,25 +78,6 @@
this.templatesFileExcludes = templatesFileExcludes;
}
- private String[] doScan(String[] includes, String[] excludes, File rootFolder)
- throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
-
- directoryScanner.scan();
-
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException(
- "Error scanning source root: \'" + rootFolder + "\'", e );
- }
- }
-
private Iterable<File> findTemplateFiles() throws MojoExecutionException {
Set<File> sourceFiles = new HashSet<File>();
if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
Added: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java (rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-18 00:57:04 UTC (rev 15188)
@@ -0,0 +1,77 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.builder.mojo;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.RichFacesConventions;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ * @goal generate
+ */
+public class GenerateMojo extends AbstractCDKMojo {
+
+ /* (non-Javadoc)
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ // TODO set logging.
+ checkLibraryConfig();
+ AbstractCdkContext context = new AbstractCdkContext(this.createProjectClassLoader(project));
+ context.setJavaSource((File) compileSourceRoots.get(0));
+ context.setJavaSourceOutput(outputJavaDirectory);
+ context.setResourceOutput(outputResourcesDirectory);
+ context.setNamingConventions(new RichFacesConventions(library.getPrefix()));
+ Set<File> javaSources = new HashSet<File>();
+ for (File compileRoot : compileSourceRoots) {
+ String[] sources = doScan(new String[]{"**/*.java"}, null, compileRoot);
+ for (String src : sources) {
+ javaSources.add(new File(compileRoot,src));
+ }
+ }
+ context.addSources(StandardSources.JAVA_SOURCES, javaSources);
+ LibraryBuilder builder = LibraryBuilder.createInstance(context);
+ try {
+ ComponentLibrary model = builder.buildModel();
+ builder.generate(model, StandardOutputs.COMPONENT_CLASSES);
+ } catch (CdkException e) {
+ throw new MojoExecutionException("CDK build error", e);
+ }
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months
JBoss Rich Faces SVN: r15187 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/apt and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-08-17 19:31:33 -0400 (Mon, 17 Aug 2009)
New Revision: 15187
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Verifier.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/VerifierImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Id.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Root.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/package-info.java
root/cdk/trunk/plugins/generator/src/test/resources/META-INF/
root/cdk/trunk/plugins/generator/src/test/resources/META-INF/templates/
root/cdk/trunk/plugins/generator/src/test/resources/META-INF/templates/testComponent.ftl
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/VM_global_library.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componentTag.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componenttest.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converterTag.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/facelets.taglib.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/faces-config.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_tag.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_taghandler.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/renderer.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-config.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-dependencies.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tag.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tagtest.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/templatecompiler/
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validatorTag.vm
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates12/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.dia
root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.png
Log:
start component class renderer implementation
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -28,7 +28,7 @@
import org.richfaces.builder.templates.RendererTemplateParser;
import org.richfaces.cdk.CdkContext.SourceType;
import org.richfaces.cdk.CdkWriter.OutputType;
-import org.richfaces.cdk.apt.CdkCompiler;
+import org.richfaces.cdk.apt.AptBuilder;
import org.richfaces.cdk.apt.CdkProcessor;
import org.richfaces.cdk.apt.ComponentProcessor;
import org.richfaces.cdk.generate.java.ComponentClassGenerator;
@@ -87,7 +87,9 @@
*/
public ComponentLibrary buildModel(SourceType type) throws CdkException {
ModelBuilder modelBuilder = getBuilderFor(type);
- return modelBuilder.build();
+ ComponentLibrary library = modelBuilder.build();
+ getVerifier().verify(library);
+ return library;
}
/**
@@ -108,6 +110,7 @@
library = model;
}
}
+ getVerifier().verify(library);
return library;
}
@@ -159,7 +162,7 @@
protected ModelBuilder getBuilderFor(SourceType type) throws CdkException {
ModelBuilder builder;
if (StandardSources.JAVA_SOURCES.equals(type)) {
- builder = new CdkCompiler();
+ builder = new AptBuilder();
} else if (StandardSources.FACES_CONFIGS.equals(type)) {
builder = new FacesConfigParser();
} else if (StandardSources.RENDERER_TEMPLATES.equals(type)) {
@@ -171,4 +174,9 @@
builder.init(getContext());
return builder;
}
+
+ protected Verifier getVerifier(){
+ // TODO - put verifier implementation into context ?
+ return new VerifierImpl(getContext());
+ }
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Verifier.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Verifier.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Verifier.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,42 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0">Interface for CDK library model verifier.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface Verifier {
+
+ /**
+ * <p class="changed_added_4_0">Perform verify procedure on the library model.</p>
+ * @param library
+ * @throws CdkException
+ */
+ public void verify(ComponentLibrary library) throws CdkException;
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Verifier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/VerifierImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/VerifierImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/VerifierImpl.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class VerifierImpl implements Verifier {
+
+ private final CdkContext context;
+
+ public VerifierImpl(CdkContext context) {
+ this.context = context;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.Verifier#verify(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void verify(ComponentLibrary library) throws CdkException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/VerifierImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java (from rev 15186, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,261 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.apt;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+
+import javax.annotation.processing.Processor;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.LoggerFactory;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0">
+ * That class compiles files from sources and process annotations
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class AptBuilder implements ModelBuilder {
+
+ private static final Logger log = LoggerFactory.getLogger();
+
+ private VirtualFileManager fileManager;
+
+ private Iterable<String> options;
+
+ private JavaCompiler javaCompiler;
+
+ private Locale locale;
+
+ private CdkContext context;
+
+ private boolean initialized = false;
+
+ /**
+ * <p class="changed_added_4_0">Builder method that creates and initializes compiler instance.
+ * That instance can be reused for consecuence processing.</p>
+ * @param context
+ * @return
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
+ JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
+ setJavaCompiler(javaCompiler);
+ ArrayList<String> options = new ArrayList<String>();
+ options.add("-proc:only");
+ options.add("-implicit:class");
+ options.add("-verbose");
+ ClassLoader classPathLoader = context.getLoader();
+ StringBuilder classPathOption = new StringBuilder();
+ boolean hasClassPathElement=false;
+ while (null != classPathLoader && classPathLoader instanceof URLClassLoader) {
+ URLClassLoader urlLoader = (URLClassLoader) classPathLoader;
+ for (URL cpElement : urlLoader.getURLs()) {
+ if(hasClassPathElement){
+ classPathOption.append(File.pathSeparatorChar);
+ } else {
+ options.add("-classpath");
+ hasClassPathElement = true;
+ }
+ classPathOption.append(cpElement.toExternalForm());
+ }
+ classPathLoader = classPathLoader.getParent();
+ }
+ if (hasClassPathElement) {
+ options.add(classPathOption.toString());
+ log.info("Compiler classpath:" + classPathOption);
+
+ }
+ if(null != context.getJavaSource()){
+ options.add("-sourcepath");
+ options.add(context.getJavaSource().getAbsolutePath());
+ }
+ if(null != context.getJavaSourceOutput() || null != context.getResourceOutput()){
+ options.add("-s");
+ StringBuilder generatedSourceFolders = new StringBuilder();
+ if(null != context.getJavaSourceOutput()){
+ generatedSourceFolders.append(context.getJavaSourceOutput().getAbsolutePath());
+ }
+ if(null != context.getResourceOutput()){
+ if(generatedSourceFolders.length()>0){
+ generatedSourceFolders.append(File.pathSeparatorChar);
+ }
+ generatedSourceFolders.append(context.getResourceOutput().getAbsolutePath());
+ }
+ options.add(generatedSourceFolders.toString());
+ }
+ setOptions(options);
+ // TODO - provide source files locale.
+ setLocale(Locale.getDefault());
+ // TODO -set locale and charset for platform-independent processing. Provide own diagnostics listener.
+ StandardJavaFileManager stdFileManager = javaCompiler
+ .getStandardFileManager(null, null, null);
+ // TODO - use standard file manager for all tasks.
+ VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
+ context.getLoader());
+ fileManager.setJavaSourceDirectory(context.getJavaSource());
+ setFileManager(fileManager);
+ initialized = true;
+ }
+
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ if(!initialized){
+ throw new CdkException("Annotation processor is not initialized");
+ }
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(context,library);
+ process(context.getSources(StandardSources.JAVA_SOURCES),processor);
+ return library;
+ }
+ /**
+ * <p class="changed_added_4_0">That method process source files and call appropriate annotation processors</p>
+ * @param sources
+ * @param processors
+ * @throws AptException
+ */
+ protected void process(Iterable<File> sources, Processor...processors) throws AptException {
+ final List<String> messages = Lists.newArrayList();
+ DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {
+
+ @Override
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ log.debug("LOG: " + diagnostic.getMessage(null));
+ if(Kind.ERROR.equals(diagnostic.getKind())){
+ messages.add(diagnostic.getMessage(null));
+ }
+ }
+
+ };
+ ArrayList<VirtualJavaFileObject> sourceObjects = new ArrayList<VirtualJavaFileObject>();
+ for (File file : sources) {
+ VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
+ sourceObjects.add(sourceObject);
+ }
+ CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener, getOptions(), null, sourceObjects);
+ task.setProcessors(Arrays.asList(processors));
+ task.setLocale(locale);
+ if(!task.call()){
+ throw new AptException("Compilation error: "+messages);
+ }
+ }
+
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the options
+ */
+ protected Iterable<String> getOptions() {
+ return options;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param options
+ * the options to set
+ */
+ protected void setOptions(Iterable<String> options) {
+ this.options = options;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the fileManager
+ */
+ protected VirtualFileManager getFileManager() {
+ return fileManager;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param fileManager the fileManager to set
+ */
+ protected void setFileManager(VirtualFileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param javaCompiler the javaCompiler to set
+ */
+ protected void setJavaCompiler(JavaCompiler javaCompiler) {
+ this.javaCompiler = javaCompiler;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the javaCompiler
+ */
+ protected JavaCompiler getJavaCompiler() {
+ return javaCompiler;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the locale
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param locale the locale to set
+ */
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,261 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.apt;
-
-import java.io.File;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-
-import javax.annotation.processing.Processor;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.JavaCompiler.CompilationTask;
-
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.model.ComponentLibrary;
-
-import com.google.common.collect.Lists;
-
-/**
- * <p class="changed_added_4_0">
- * That class compiles files from sources and process annotations
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class CdkCompiler implements ModelBuilder {
-
- private static final Logger log = LoggerFactory.getLogger();
-
- private VirtualFileManager fileManager;
-
- private Iterable<String> options;
-
- private JavaCompiler javaCompiler;
-
- private Locale locale;
-
- private CdkContext context;
-
- private boolean initialized = false;
-
- /**
- * <p class="changed_added_4_0">Builder method that creates and initializes compiler instance.
- * That instance can be reused for consecuence processing.</p>
- * @param context
- * @return
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- setJavaCompiler(javaCompiler);
- ArrayList<String> options = new ArrayList<String>();
- options.add("-proc:only");
- options.add("-implicit:class");
- options.add("-verbose");
- ClassLoader classPathLoader = context.getLoader();
- StringBuilder classPathOption = new StringBuilder();
- boolean hasClassPathElement=false;
- while (null != classPathLoader && classPathLoader instanceof URLClassLoader) {
- URLClassLoader urlLoader = (URLClassLoader) classPathLoader;
- for (URL cpElement : urlLoader.getURLs()) {
- if(hasClassPathElement){
- classPathOption.append(File.pathSeparatorChar);
- } else {
- options.add("-classpath");
- hasClassPathElement = true;
- }
- classPathOption.append(cpElement.toExternalForm());
- }
- classPathLoader = classPathLoader.getParent();
- }
- if (hasClassPathElement) {
- options.add(classPathOption.toString());
- log.info("Compiler classpath:" + classPathOption);
-
- }
- if(null != context.getJavaSource()){
- options.add("-sourcepath");
- options.add(context.getJavaSource().getAbsolutePath());
- }
- if(null != context.getJavaSourceOutput() || null != context.getResourceOutput()){
- options.add("-s");
- StringBuilder generatedSourceFolders = new StringBuilder();
- if(null != context.getJavaSourceOutput()){
- generatedSourceFolders.append(context.getJavaSourceOutput().getAbsolutePath());
- }
- if(null != context.getResourceOutput()){
- if(generatedSourceFolders.length()>0){
- generatedSourceFolders.append(File.pathSeparatorChar);
- }
- generatedSourceFolders.append(context.getResourceOutput().getAbsolutePath());
- }
- options.add(generatedSourceFolders.toString());
- }
- setOptions(options);
- // TODO - provide source files locale.
- setLocale(Locale.getDefault());
- // TODO -set locale and charset for platform-independent processing. Provide own diagnostics listener.
- StandardJavaFileManager stdFileManager = javaCompiler
- .getStandardFileManager(null, null, null);
- // TODO - use standard file manager for all tasks.
- VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
- context.getLoader());
- fileManager.setJavaSourceDirectory(context.getJavaSource());
- setFileManager(fileManager);
- initialized = true;
- }
-
- @Override
- public ComponentLibrary build() throws CdkException {
- if(!initialized){
- throw new CdkException("Annotation processor is not initialized");
- }
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(context,library);
- process(context.getSources(StandardSources.JAVA_SOURCES),processor);
- return library;
- }
- /**
- * <p class="changed_added_4_0">That method process source files and call appropriate annotation processors</p>
- * @param sources
- * @param processors
- * @throws AptException
- */
- protected void process(Iterable<File> sources, Processor...processors) throws AptException {
- final List<String> messages = Lists.newArrayList();
- DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {
-
- @Override
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- log.debug("LOG: " + diagnostic.getMessage(null));
- if(Kind.ERROR.equals(diagnostic.getKind())){
- messages.add(diagnostic.getMessage(null));
- }
- }
-
- };
- ArrayList<VirtualJavaFileObject> sourceObjects = new ArrayList<VirtualJavaFileObject>();
- for (File file : sources) {
- VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
- sourceObjects.add(sourceObject);
- }
- CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener, getOptions(), null, sourceObjects);
- task.setProcessors(Arrays.asList(processors));
- task.setLocale(locale);
- if(!task.call()){
- throw new AptException("Compilation error: "+messages);
- }
- }
-
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the options
- */
- protected Iterable<String> getOptions() {
- return options;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param options
- * the options to set
- */
- protected void setOptions(Iterable<String> options) {
- this.options = options;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the fileManager
- */
- protected VirtualFileManager getFileManager() {
- return fileManager;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param fileManager the fileManager to set
- */
- protected void setFileManager(VirtualFileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaCompiler the javaCompiler to set
- */
- protected void setJavaCompiler(JavaCompiler javaCompiler) {
- this.javaCompiler = javaCompiler;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaCompiler
- */
- protected JavaCompiler getJavaCompiler() {
- return javaCompiler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the locale
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param locale the locale to set
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
-}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -195,16 +195,16 @@
* <p class="changed_added_4_0">
* Get all classes annotated with particular annotation.
* </p>
- *
+ * @param round
+ * current round environment.
* @param annotation
* annotation class.
- * @param round
- * current round environment.
+ *
* @return {@link Set} of all classes annotated with {@code annotation}
* type.
*/
protected Set<? extends TypeElement> getClassesAnnotatedWith(
- Class<? extends Annotation> annotation, RoundEnvironment round) {
+ RoundEnvironment round, Class<? extends Annotation> annotation) {
Set<TypeElement> classes = Sets.newHashSet();
Set<? extends Element> annotatedWith = round
.getElementsAnnotatedWith(annotation);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -25,25 +25,19 @@
import java.util.Set;
-import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.MirroredTypeException;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeMirror;
import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Attributes;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.annotations.Family;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.Component.Type;
import org.richfaces.cdk.util.Strings;
@@ -82,88 +76,57 @@
RoundEnvironment roundEnv) {
if (null != annotations && !annotations.isEmpty()) {
ComponentLibrary library = getLibrary();
- NamingConventions namingUtils = getContext().getNamingConventions();
- // Process all component classes.
+ // Process all component classes annotated with CDK @Component.
Set<? extends TypeElement> componentClasses = getClassesAnnotatedWith(
- Component.class, roundEnv);
- for (TypeElement component : componentClasses) {
+ roundEnv, Component.class);
+ for (TypeElement componentElement : componentClasses) {
try {
// Process class-level annotations.
// Calculate type for base UI component class.
- // TODO - encpsulate that into simple utility classes call.
- Component componentAnnotation = component
+ // TODO - encapsulate that into simple utility classes call.
+ Component componentAnnotation = componentElement
.getAnnotation(Component.class);
- String baseClassName = component.getQualifiedName()
- .toString();
- String componentType = namingUtils.inferComponentType(
- componentAnnotation.type(), baseClassName);
- // Create/get component instance.
- org.richfaces.cdk.model.Component componentModel = library
- .createComponent(componentType)
- .setClassName(
- namingUtils.inferUIComponentClass(
- componentType, componentAnnotation
- .className(),
- baseClassName, component
+ org.richfaces.cdk.model.Component component = new org.richfaces.cdk.model.Component();
+ // Should that component be generated ?
+ component.setExists(!componentElement
.getModifiers().contains(
- Modifier.ABSTRACT)))
- .setBaseClassName(
- namingUtils.inferUIComponentBaseClass(
- componentType, baseClassName,
- component.getModifiers().contains(
- Modifier.ABSTRACT)));
- // Component Family. TODO - get it from 'COMPONENT_FAMILY'
- // field or infer by NamingConventios.
- Family family = component.getAnnotation(Family.class);
- componentModel
- .setFamily(namingUtils.inferUIComponentFamily(componentType,family.value()));
+ Modifier.ABSTRACT));
+ component.setBaseClass(new ClassDescription(componentElement.getQualifiedName()
+ .toString()));
+ if(!Strings.isEmpty(componentAnnotation.type())){
+ component.setType(new Type(componentAnnotation.type()));
+ }
+ // Generated class name.
+ if(!Strings.isEmpty(componentAnnotation
+ .className())){
+ component.setComponentClass(new ClassDescription(componentAnnotation.className()));
+ component.setExists(false);
+ }
+ // Component family
+ if(!Strings.isEmpty(componentAnnotation
+ .family())){
+ // @Component annotation fiels
+ component.setFamily(componentAnnotation.family());
+ } else if(null != componentElement.getAnnotation(Family.class)){
+ // @Family annotation.
+ component
+ .setFamily(componentElement.getAnnotation(Family.class).value());
+ } else {
+ // TODO - find static final COMPONENT_FAMILY string ?
+ }
// JavaDoc comments
- componentModel.setDescription(this.processingEnv
- .getElementUtils().getDocComment(component));
+ component.setDescription(this.processingEnv
+ .getElementUtils().getDocComment(componentElement));
// TODO - process Events attribute.
// TODO - renderers, ....
// Process attributes.
- Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
- Attribute.class, component);
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- Property atribute = componentModel
- .addAttribute(beanProperty.getName());
- // Documentation
- atribute.setDescription(beanProperty.getDocComment());
- // Type.
- atribute.setPropertyClass(beanProperty
- .getType().toString());
- // Flags.
- atribute.setExists(beanProperty.isExists());
- }
- Attributes attributes = component
- .getAnnotation(Attributes.class);
- if (null != attributes) {
- Attribute[] attributes2 = attributes.value();
- for (Attribute attributeAnnotation : attributes2) {
- Property attribute = componentModel
- .addAttribute(attributeAnnotation.name());
- attribute.setExists(false);
- try {
- Class<?> type = attributeAnnotation.type();
- attribute
- .setPropertyClass(type
- .getName());
- } catch (MirroredTypeException ex) {
- attribute.setPropertyClass(ex
- .getTypeMirror().toString());
- }
- // TODO - process additional properties.
- }
- }
- // TODO - Process standard information for parent classes
- // and intrfaces.
- } catch (InvalidNameException e) {
+ processAttributes(componentElement, component);
+ library.getComponents().add(component);
+ } catch (Exception e) {
// rise error and continue.
processingEnv.getMessager().printMessage(
javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
- component);
+ componentElement);
continue;
}
}
@@ -172,12 +135,49 @@
return false;
}
+ protected void processAttributes(TypeElement componentElement,
+ org.richfaces.cdk.model.Component component) {
+ Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
+ Attribute.class, componentElement);
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ Property atribute = component
+ .addAttribute(beanProperty.getName());
+ // Documentation
+ atribute.setDescription(beanProperty.getDocComment());
+ // Type.
+ atribute.setType(new ClassDescription(beanProperty
+ .getType().toString()));
+ // Flags.
+ atribute.setExists(beanProperty.isExists());
+ }
+ Attributes attributes = componentElement
+ .getAnnotation(Attributes.class);
+ if (null != attributes) {
+ Attribute[] attributes2 = attributes.value();
+ for (Attribute attributeAnnotation : attributes2) {
+ Property attribute = component
+ .addAttribute(attributeAnnotation.name());
+ attribute.setExists(false);
+ try {
+ Class<?> type = attributeAnnotation.type();
+ attribute
+ .setType(new ClassDescription(type
+ .getName()));
+ } catch (MirroredTypeException ex) {
+ attribute.setType(new ClassDescription(ex
+ .getTypeMirror().toString()));
+ }
+ // TODO - process additional properties.
+ }
+ }
+ // TODO - Process standard information for parent classes
+ // and intrfaces.
+ }
+
public ComponentLibrary getLibrary() {
return library;
}
- protected ClassDescription createClassDescription(TypeMirror mirror) {
- return getLibrary().createClassDescription(mirror.toString());
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -37,6 +37,7 @@
*/
public class CdkConfiguration extends Configuration {
+ private static final String TEMPLATES = "/META-INF/templates";
private final CdkContext context;
/**
@@ -51,7 +52,7 @@
super();
this.context = context;
// TODO set proper template loader.
- setClassForTemplateLoading(context.getClass(), "/META-INF/templates");
+ setClassForTemplateLoading(context.getClass(), TEMPLATES);
// TODO create an object wrapper for library model.
setObjectWrapper(new LibraryModelWrapper());
// Add context variables
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -25,6 +25,7 @@
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
@@ -78,7 +79,7 @@
protected boolean processComponent(C c, P param) {
try {
- FileWriter out = new FileWriter(getOutputFile(c));
+ Writer out = getOutput(c);
template.process(c, out);
out.close();
} catch (IOException e) {
@@ -92,6 +93,10 @@
return false;
}
+ protected Writer getOutput(C c) throws IOException {
+ return new FileWriter(getOutputFile(c));
+ }
+
protected abstract String getOutputFile(C c);
protected abstract boolean isMyComponent(JsfComponent c);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -31,14 +31,14 @@
/**
* <p class="changed_added_4_0">Reference to component library for which that component is belong to.</p>
*/
- private final ComponentLibrary library;
+ private ComponentLibrary library;
/**
* <p class="changed_added_4_0">
* Component type
* </p>
*/
- private final Type type;
+ private Type type;
/**
* <p class="changed_added_4_0">
@@ -118,18 +118,6 @@
private ComponentExtension extension;
- /**
- * <p class="changed_added_4_0">Constructor. That class can be instantiated by model-package members only.
- * </p>
- *
- * @param type
- * the type to set
- */
- Component(ComponentLibrary library, Type type) {
- this.library = library;
- this.type = type;
- }
-
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
return visitor.visit(this, param);
@@ -140,13 +128,23 @@
*
* @see org.richfaces.cdk.model.JsfComponent#getType()
*/
+ @Override
@XmlElement(name="component-type",required=true)
- public JsfType getType() {
+ public Type getType() {
return type;
}
+
/**
* <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the extension
*/
@XmlElement(name="component-extensions")
@@ -199,7 +197,7 @@
* the componentClass to set
*/
@XmlElement(name="component-class")
- void setComponentClass(ClassDescription componentClass) {
+ public void setComponentClass(ClassDescription componentClass) {
this.componentClass = componentClass;
}
@@ -209,8 +207,6 @@
*
* @return the baseClass
*/
- @XmlElementWrapper(name="component-extensions")
- @XmlElement(namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public ClassDescription getBaseClass() {
return baseClass;
}
@@ -222,38 +218,10 @@
* @param baseClass
* the baseClass to set
*/
- void setBaseClass(ClassDescription baseClass) {
+ public void setBaseClass(ClassDescription baseClass) {
this.baseClass = baseClass;
}
- /**
- * <p class="changed_added_4_0">Create and set {@link ClassDescription} for component class.</p>
- * @param className canonical name for component class.
- * @return component instance itself for chain calls.
- */
- public Component setClassName(String className) {
- ClassDescription classDescription = library
- .createClassDescription(className);
- setComponentClass(classDescription);
- return this;
- }
-
- /**
- * <p class="changed_added_4_0">Create and set {@link ClassDescription} for base generated component class .</p>
- * @param className canonical name for component super class.
- * @return component instance itself for chain calls.
- */
- public Component setBaseClassName(String className) {
- if (!Strings.isEmpty(className)) {
- ClassDescription classDescription = library
- .createClassDescription(className);
- setBaseClass(classDescription);
- } else {
- setBaseClass(null);
- }
- return this;
- }
-
/* (non-Javadoc)
* @see org.richfaces.cdk.model.DescriptionGroup#getDescription()
*/
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -43,6 +43,7 @@
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -72,23 +73,22 @@
*/
private static final long serialVersionUID = -6055670836731899832L;
- private final Set<Component> components = Sets.newHashSet();
+ private final List<Component> components = Lists.newArrayList();
- private final Set<ClassDescription> classes = Sets.newHashSet();
/**
* <p class="changed_added_4_0">
* JSF renderer associated with that library
* </p>
*/
- private final List<Renderer> renderers = new ArrayList<Renderer>();
+ private final List<Renderer> renderers = Lists.newArrayList();
- private final List<Converter> converters = new ArrayList<Converter>();
+ private final List<Converter> converters = Lists.newArrayList();
- private final List<Validator> validators = new ArrayList<Validator>();
+ private final List<Validator> validators = Lists.newArrayList();
- private final List<Behavior> behaviors = new ArrayList<Behavior>();
+ private final List<Behavior> behaviors = Lists.newArrayList();
- private final List<Listener> listeners = new ArrayList<Listener>();
+ private final List<Listener> listeners = Lists.newArrayList();
/**
* <p class="changed_added_4_0">
@@ -166,7 +166,8 @@
component = find(components, componentType);
} catch (NoSuchElementException e) {
if (create) {
- component = new Component(this,componentType);
+ component = new Component();
+ component.setType(componentType);
components.add(component);
}
}
@@ -194,27 +195,8 @@
/**
* <p class="changed_added_4_0">
- * Gets or creates {@link ClassDescription} object.
* </p>
*
- * @param className
- * @return
- */
- public ClassDescription createClassDescription(String className) {
- ClassDescription result;
- try {
- result = find(classes, new ClassDescription.Type(className));
- } catch (NoSuchElementException e) {
- result = new ClassDescription(className);
- classes.add(result);
- }
- return result;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
* @return the renderers
*/
public List<Renderer> getRenderers() {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -39,7 +39,7 @@
/**
* <p class="changed_added_4_0">Bean property name of component attribute</p>
*/
- private final String name;
+ private String name;
private ClassDescription type;
@@ -86,10 +86,13 @@
* <p class="changed_added_4_0"></p>
* @param name
*/
- Property(String name) {
+ public Property(String name) {
this.name = name;
}
+ public Property() {
+ }
+
/**
* <p class="changed_added_4_0"></p>
* @return the name
@@ -101,6 +104,13 @@
/**
* <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the description
*/
public String getDescription() {
@@ -159,19 +169,11 @@
* <p class="changed_added_4_0"></p>
* @param type the type to set
*/
- void setType(ClassDescription type) {
+ public void setType(ClassDescription type) {
this.type = type;
}
- @XmlElement(name = "property-class")
- public void setPropertyClass(String propertyClass) {
- if (!Strings.isEmpty(propertyClass)) {
- ClassDescription type = new ClassDescription(propertyClass);
- setType(type);
- }
- }
-
/**
* <p class="changed_added_4_0"></p>
* @return the dafaultValue
Modified: root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.dia
===================================================================
(Binary files differ)
Modified: root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.png
===================================================================
(Binary files differ)
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/VM_global_library.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/VM_global_library.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/VM_global_library.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,12 +0,0 @@
-#macro( quietnull $a)
-
-#if($a)$a#end
-
-#end
-
-
-
-
-
-
-
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,202 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-#if(${generator.key})
-
-import java.io.IOException;
-import javax.faces.FacesException;
-import org.richfaces.framework.util.base64.Codec;
-#end
-
-/**
- * Component-Type ${component.name}
- * Component-Family ${component.family}
- #if(${component.renderer})
- * Renderer-Type ${component.renderer.name}
- #end
- * ${component.xmlEncodedDescription}
- */
- public class $component.simpleClassName extends $component.superclass {
-
- public static final String COMPONENT_TYPE = "${component.name}";
-
- /**
- * Constructor to init default renderers
- */
- public $component.simpleClassName (){
- #if(${component.renderer})
- setRendererType("${component.renderer.name}");
- #end
- }
-
-// Component properties fields
-#set( $fiedCounter = 1 )
-#foreach( $prop in $component.properties )
- #if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- #if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated what $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
- #set( $fiedCounter = $fiedCounter+2)
- #else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
- #set( $fiedCounter = $fiedCounter+1)
- #end
-#end
-#end
-
-// Getters-setters
-#foreach( $prop in $component.properties )
- #if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name ){
- this._${prop.name} = __$prop.name;
- #if($prop.simpleType)
- this._${prop.name}Set = true;
- #end
- }
-
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value bindings
- */
- public $prop.simpleClassName ${prop.getterName}( ){
- #if($prop.simpleType)
- if(this._${prop.name}Set){
- return this._${prop.name};
- }
- ValueBinding vb = getValueBinding("${prop.name}");
- if (vb != null) {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value) {
- return this._${prop.name};
- }
- return (value.${prop.classname}Value());
- } else {
- return (this._${prop.name});
- }
- #else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- #if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- }
- ValueBinding vb = getValueBinding("${prop.name}");
- if (null != vb){
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- #end
- } else {
- return ${prop.defaultvalue};
- }
- #end
- }
- #if($prop.raw)
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name ){
- this._${prop.name} = __$prop.name;
- }
- /**
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw( ){
- return this._${prop.name};
- }
- #end
- #end
-#end
-
-#if( ${component.family} )
-// Component family.
- public static final String COMPONENT_FAMILY = "${component.family}";
-
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-#end
-
-// Save state
-// ----------------------------------------------------- StateHolder Methods
-
-
- public Object saveState(FacesContext context) {
- Object values[] = new Object[${fiedCounter}];
- values[0] = super.saveState(context);
-#set($currentField = 1)
-#foreach( $prop in $component.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
- #set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
- #set( $currentField = $currentField+1)
- #else
- #if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
- #else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
- #end
- #set( $currentField = $currentField+1)
- #end
-
- #end
-#end
- return values;
- }
-
-
- public void restoreState(FacesContext context, Object state) {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
-#set($currentField = 1)
-#foreach( $prop in $component.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
- #set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
- #set( $currentField = $currentField+1)
- #else
- #if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
- #else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
- #end
- #set( $currentField = $currentField+1)
- #end
-
- #end
-#end
-
-
- }
-// Utilites
-
-}
\ No newline at end of file
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componentTag.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componentTag.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componentTag.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,149 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import ${component.classname};
-
-public class $tag.simpleClassName extends $tag.superclass {
-
-// Fields
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- private String _$prop.name = null;
-
- #end
-#end
-// Setters
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- /*
- * $prop.description
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( String __${prop.name} ){
- this._${prop.name} = __${prop.name};
- }
-
- #end
- #if( $prop.alias)
- /*
- * ${prop.xmlEncodedDescription}
- * Setter for alias of $prop.name as $prop.alias
- * @param $prop.name - new value
- */
- public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} ){
- this.${prop.setterName}(__${prop.alias});
- }
- #end
-#end
-// Release
-
- /* (non-Javadoc)
- * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#release()
- */
- public void release()
- {
- // TODO Auto-generated method stub
- super.release();
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- this._${prop.name} = null;
- #end
-#end
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component)
- {
- // TODO Auto-generated method stub
- super.setProperties(component);
-
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- #if(!$prop.el)
- if(null != this._${prop.name} && isValueReference(this._${prop.name})){
- throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext()) +" not allowed EL expression for property ${prop.name}");
- }
- #end
- #if($prop.name == "action")
- setActionProperty(component, this._${prop.name});
- #elseif($prop.name == "actionListener")
- setActionListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "converter")
- setConverterProperty(component, this._${prop.name});
- #elseif($prop.name == "validator")
- setValidatorProperty(component, this._${prop.name});
- #elseif($prop.name == "valueChangeListener")
- setValueChangedListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "value")
- setValueProperty(component, this._${prop.name});
- #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
- if(null != this._${prop.name}){
- if (isValueReference(this._${prop.name}))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(this._${prop.name},
- new Class[]{${prop.methodArgsClasses}});
- ((${component.simpleClassName})component).${prop.setterName}(mb);
- }
- else
- {
- getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
- }
- }
- #elseif($prop.elonly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
- setValueBinding(component, "${prop.name}",this._${prop.name});
- #elseif(${prop.simpleType})
- // Simple type - ${prop.simpleClassName}
- set${prop.boxingClass}Property(component, "${prop.name}",this._${prop.name});
- #elseif($prop.classname == "java.lang.Boolean" || $prop.classname == "java.lang.Integer" || $prop.classname == "java.lang.Long")
- set${prop.simpleClassName}Property(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.String")
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.Object")
- // TODO - handle object
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #else
- // TODO - setup properties for other cases.
- // name ${prop.name} with type $prop.classname
- #end
- #end
-#end
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType() {
- // TODO Auto-generated method stub
- return "${component.name}";
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType() {
- #if($renderer)
- return "${renderer.name}";
- #else
- return null;
- #end
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componenttest.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componenttest.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/componenttest.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,147 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import com.gargoylesoftware.htmlunit.Page;
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlForm;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.component.UIViewRoot;
-
-import org.richfaces.tests.MockValueBinding;
-
-//import ${component.classname};
-#if(${generator.key})
-
-import java.io.IOException;
-import javax.faces.FacesException;
-import org.richfaces.framework.util.base64.Codec;
-#end
-
-public class $component.test.simpleClassName extends $component.test.superclassname {
-
-// public static final String COMPONENT_TYPE = "${component.name}";
-
-
-#set( $fiedCounter = 1 )
-#foreach( $prop in $component.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- private boolean _${prop.name}Set = false;
- #set( $fiedCounter = $fiedCounter+2)
- #else
- #set( $fiedCounter = $fiedCounter+1)
- #end
-#end
-#end
-
- private $component.simpleClassName component;
- private UIForm form;
-// private FacesContext context;
-
- /**
- * Constructor to init default renderers
- */
- public $component.test.simpleClassName (String name){
- super(name);
- }
-
- /*
- * setup the tets
- */
- public void setUp() throws Exception {
- super.setUp();
- component = new ${component.simpleClassName}();
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- component.setId("component");
-#foreach( $prop in $component.properties )
- #if(!$prop.exist && !$prop.elonly && !$prop.classname.startsWith("javax.faces."))
- component.${prop.setterName}($testDataGenerator.getTestData(${prop}) );
- #end
-#end
-
- form.getChildren().add(component);
-
- }
-
- /*
- * setup the tets
- */
- public void tearDown() throws Exception{
- super.tearDown();
- component = null;
- form = null;
- }
-
- public void testComponent() throws Exception {
- #if(${component.renderer})
- assertEquals("${component.renderer.name}", component.getRendererType());
- #end
-
-// values[0] = component.saveState(facesContext);
-
- }
-/*
- public void testDefaultValues(){
-
- }
-*/
- public void testContext(){
-
- Object state = component.saveState(facesContext);
-/*
- UIViewRoot root = facesContext.getViewRoot();
- root.processDecodes(facesContext);
- root.processValidators(facesContext);
- root.processUpdates(facesContext);
- root.processApplication(facesContext);
-*/
- testRestoreState(state);
- }
-
- public void testGetters() {
- ${component.simpleClassName} component = new ${component.simpleClassName}();
-
-#foreach( $prop in $component.properties )
- #if(!$prop.exist && !$prop.elonly && !$prop.classname.startsWith("javax.faces."))
- component.setValueBinding("${prop.name}", new MockValueBinding($testDataGenerator.getTestVeData(${prop}), ${testDataGenerator.getTestVeClass(${prop})}.class));
- assertEquals($testDataGenerator.getTestData(${prop}), component.${prop.getterName}());
- component.${prop.setterName}($testDataGenerator.getTestData1(${prop}) );
- assertEquals($testDataGenerator.getTestData1(${prop}), component.${prop.getterName}());
- #end
-#end
-
-
- }
-
- private void testRestoreState(Object state){
- ${component.simpleClassName} restoredComponent = new ${component.simpleClassName}();
- restoredComponent.restoreState(facesContext, state);
-
-#foreach( $prop in $component.properties )
- #if(!$prop.exist)
- assertEquals(component.${prop.getterName}(), restoredComponent.${prop.getterName}());
- #end
-#end
-
- }
-
- private void assertEquals(double d1, double d2) {
- assertEquals(d1, d2, 0);
- }
-
- private void assertEquals(float d1, float d2) {
- assertEquals(d1, d2, 0);
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,221 +0,0 @@
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
- import javax.faces.context.FacesContext;
- import javax.faces.el.ValueBinding;
-import javax.faces.component.StateHolder;
-
- /**
- * Converter-Id ${converter.id}
- * ${converter.xmlEncodedDescription}
- */
-
-public class $converter.simpleClassName extends $converter.superclass #if(${converter.stateHolderRequired} && !${converter.superclassImplementsStateHolder})implements StateHolder#end
- {
-
- public static final String CONVERTER_ID = "${converter.id}";
-
-
-
- // Conveter properties fields
-
-#set( $fieldCounter = 0 )
- #foreach( $prop in $converter.properties )
-
-#if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
-
-#if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
-#set( $fieldCounter = $fieldCounter+2)
-#else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
-#set( $fieldCounter = $fieldCounter+1)
- #end
-#end
-#end
-
- // Getters and setters
- #foreach( $prop in $converter.properties )
-
-#if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
-
-#if($prop.simpleType)
- this._${prop.name}Set = true;
-
-#end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding("${prop.name}");
-
-#if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
-
- return (this._${prop.name});
- }
- }
-
-#else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
-
-#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
-
-#end
- else
- {
- return ${prop.defaultvalue};
- }
-
-#end
- }
- #if($prop.raw)
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
-
- {
- return this._${prop.name};
- }
- #end
-#end
-#end
-
-#if($converter.stateHolderRequired)
-
- // Save state
- // ----------------------------------------------------- StateHolder Methods
-
- private boolean _transient;
-
-#if(${converter.superclassImplementsStateHolder})
-#set($currentField=1)
-#set($fieldCounter = $fieldCounter+1)
-#else
-#set($currentField=0)
-#end
- public Object saveState(FacesContext context) {
-
-#if(${converter.superSaveStateMethodExists})
- Object values[] = new Object[${fieldCounter}];
- values[0] = super.saveState(context);
-#else
- Object values[] = new Object[${fieldCounter}];
-#end
-#foreach( $prop in $converter.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
-#set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
-#set( $currentField = $currentField+1)
-#else
-#if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
-#else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
- #end
-
-#set( $currentField = $currentField+1)
-#end
-#end
-#end
- return values;
- }
-
-
-#if(${converter.superclassImplementsStateHolder})
-#set($currentField=1)
-#else
-#set($currentField=0)
-#end
- public void restoreState(FacesContext context, Object state) {
-#if(${converter.superRestoreStateMethodExists})
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
-#else
- Object values[] = (Object[]) state;
-#end
-#foreach( $prop in $converter.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
-#set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
-#set( $currentField = $currentField+1)
-#else
-#if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
-#else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
- #end
-#set( $currentField = $currentField+1)
-#end
-
-#end
-#end
- }
-
-#if(!$converter.superIsTransientMethodExists)
- public boolean isTransient()
- {
- return _transient;
- }
-#end
-
-#if(!$converter.superSetTransientMethodExists)
- public void setTransient(boolean newTransientValue)
- {
- this._transient = newTransientValue;
- }
-#end
-
-#end
-
- // Utilites
-
- private FacesContext getFacesContext()
- {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name)
- {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
- }
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converterTag.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converterTag.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converterTag.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,95 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import javax.faces.convert.Converter;
-import javax.faces.webapp.UIComponentTag;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import org.apache.commons.beanutils.ConvertUtils;
-import javax.servlet.jsp.JspException;
-import ${converter.classname};
-
-public class $tag.simpleClassName extends $tag.superclass
-{
-
-// Fields
-#foreach( $prop in $converter.properties )
-#if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- private String _$prop.name = null;
-
-#end
-#end
-// Setters
-#foreach( $prop in $converter.properties )
-#if( !$prop.existintag )
- /*
- * $prop.description
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}(String __${prop.name})
- {
- this._${prop.name} = __${prop.name};
- }
-
-#end
-#if( $prop.alias)
- /*
- * ${prop.xmlEncodedDescription}
- * Setter for alias of $prop.name as $prop.alias
- * @param $prop.name - new value
- */
- public void set${prop.upperFirstChar($prop.alias)}(String __${prop.alias})
- {
- this.${prop.setterName}(__${prop.alias});
- }
-#end
-#end
-
- protected Converter createConverter() throws JspException
- {
- ${converter.simpleClassName} converter = (${converter.simpleClassName}) FacesContext.getCurrentInstance().getApplication().createConverter("${converter.id}");
- _setProperties(converter);
- return converter;
- }
-
- // Support method to wire in attributes
- private void _setProperties(${converter.simpleClassName} converter) throws JspException
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-#foreach( $prop in $converter.properties )
-#if( !$prop.existintag )
- if (_${prop.name} != null)
- {
-#if( ${prop.el} )
- if (UIComponentTag.isValueReference(_${prop.name}))
- {
- ValueBinding vb = facesContext.getApplication().createValueBinding(_${prop.name});
- converter.${prop.setterName}((${prop.simpleClassName}) vb.getValue(facesContext));
- }
-#if (!${prop.elonly})
- else
- {
- converter.${prop.setterName}((${prop.simpleClassName}) ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
- }
-#end
- }
-#else
- converter.${prop.setterName}((${prop.simpleClassName}) ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
-#end
-#end
-#end
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/facelets.taglib.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/facelets.taglib.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/facelets.taglib.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE facelet-taglib PUBLIC
- "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
- "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
-<facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
- <namespace>${taglib.uri}</namespace>
-
-${taglib.includeContent}
-
-#foreach( $component in ${components})
-#if($component.tag)
- <tag>
- <tag-name>${component.tag.name}</tag-name>
- <component>
- <component-type>${component.name}</component-type>
-#if(${component.renderer})
- <renderer-type>
- ${component.renderer.name}
- </renderer-type>
-#end
-#if(${component.taghandler})
- <handler-class>
- ${component.taghandler.classname}
- </handler-class>
-#end
- </component>
-
- </tag>
-#end
-#end
-
-
-#foreach( $listener in ${listeners})
- <tag>
- <tag-name>${listener.name}</tag-name>
-#if(${listener.taghandler})
- <handler-class>
- ${listener.taghandler.classname}
- </handler-class>
-#end
-
- </tag>
-#end
-
-</facelet-taglib>
\ No newline at end of file
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/faces-config.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/faces-config.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/faces-config.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,127 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
-<faces-config>
-
-${facesConfig.includeContent}
-
-#foreach( $validator in ${validators})
- <validator>
- #if(${validator.description})
- <description>${validator.description}</description>
- #end
- #if(${validator.displayname})
- <display-name>${validator.displayname}</display-name>
- #end
- #if(${validator.icon})
- <icon>${validator.icon}</icon>
- #end
- <validator-id>${validator.id}</validator-id>
- <validator-class>${validator.classname}</validator-class>
- </validator>
-#end
-
-#foreach( $converter in ${converters})
- <converter>
- #if(${converter.description})
- <description>${converter.description}</description>
- #end
- #if(${converter.displayname})
- <display-name>${converter.displayname}</display-name>
- #end
- #if(${converter.icon})
- <icon>${converter.icon}</icon>
- #end
- #if(${converter.id})
- <converter-id>${converter.id}</converter-id>
- #end
- #if(${converter.forclass})
- <converter-for-class>${converter.forclass}</converter-for-class>
- #end
-
- <converter-class>${converter.classname}</converter-class>
-
- </converter>
-#end
-
-
-
-#foreach( $component in ${components})
-#if( $component.generate )
- <component>
- #if(${component.description})
- <description>${component.xmlEncodedDescription}</description>
- #end
- #if(${component.displayname})
- <display-name>${component.xmlEncodedDisplayname}</display-name>
- #end
- <component-type>${component.name}</component-type>
- <component-class>${component.classname}</component-class>
-
-#foreach( $facet in $component.facets)
- <facet>
- #if(${facet.description})
- <description>${facet.xmlEncodedDescription}</description>
- #end
- #if(${facet.displayname})
- <display-name>${facet.xmlEncodedDisplayname}</display-name>
- #end
- <facet-name>${facet.name}</facet-name>
- </facet>
-#end
- #if(${component.renderer})
- <component-extension>
- <component-family>${component.family}</component-family>
- <renderer-type>${component.renderer.name}</renderer-type>
- </component-extension>
- #end
- </component>
-#end
-#end
-
-#foreach( $renderkit in $facesConfig.renderKits)
- <render-kit>
- #if(${renderkit.renderkitid})
- <render-kit-id>${renderkit.renderkitid}</render-kit-id>
- #if(${renderkit.renderkitclass})
- <render-kit-class>${renderkit.renderkitclass}</render-kit-class>
- #end
- #end
-#foreach( $component in $components)
- #if($component.renderer)
- #set($rendererClass = $renderkit.rendererClass($component.renderer.classname) )
- #if( $component.renderer.generate || $facesConfig.rendererExists("${rendererClass}"))
- <renderer>
- <component-family>${component.family}</component-family>
- <renderer-type>
- ${component.renderer.name}
- </renderer-type>
- <renderer-class>
- ${rendererClass}
- </renderer-class>
- </renderer>
- #end
- #end
-#end
-
-#foreach($renderer in $renderers)
- #set($rendererClass = $renderkit.rendererClass($renderer.classname) )
- #if( $renderer.generate || $facesConfig.rendererExists("${rendererClass}"))
- <renderer>
- <component-family>${renderer.family}</component-family>
- <renderer-type>
- ${renderer.name}
- </renderer-type>
- <renderer-class>
- ${rendererClass}
- </renderer-class>
- </renderer>
- #end
-#end
-
-
- </render-kit>
-#end
-
-
-</faces-config>
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_tag.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_tag.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_tag.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,221 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- * License Agreement.
- *
- * JBoss RichFaces 3.1 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import ${listener.componentclass};
-
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.ValueBinding;
-import javax.faces.webapp.UIComponentTag;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.TagSupport;
-
-import org.apache.commons.beanutils.ConvertUtils;
-
-import org.richfaces.Messages;
-
-
-public class $tag.simpleClassName extends TagSupport {
-
- private static final long serialVersionUID = -274448680242671987L;
-
- private String type;
- private String binding;
-
- public int doStartTag() throws JspException {
-
- UIComponentTag parentTag = UIComponentTag
- .getParentUIComponentTag(pageContext);
-
- if (parentTag == null) {
- throw new JspException(Messages.getMessage(
- Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR, this
- .getClass().getName()));
- }
-
- if (type == null && binding == null) {
- throw new JspException("Either of the following attributes is "
- + "required: type binding");
- }
-
- // Process only newly created components
- if (parentTag.getCreated()) {
-
- FacesContext context = FacesContext.getCurrentInstance();
- Application application = context.getApplication();
-
- ${listener.listenerclass} listener = null;
-
- UIComponent component = parentTag.getComponentInstance();
-
- // First try to access listener binding
- if (binding != null) {
- ValueBinding valueBinding = application
- .createValueBinding(binding);
-
- try {
- listener = (${listener.listenerclass}) valueBinding
- .getValue(context);
- } catch (EvaluationException e) {
- throw new JspException(e);
- }
- }
-
- // Then try to instantiate it by type attribute
- if (listener == null) {
-
- String className = null;
-
- if (UIComponentTag.isValueReference(type)) {
-
- try {
- className = (String) application.createValueBinding(
- type).getValue(context);
- } catch (EvaluationException e) {
- throw new JspException(e);
- }
-
- } else {
- className = type;
- }
-
- if (className == null) {
- throw new JspException("Type attribute resolved to null.");
- }
-
- try {
- listener = (${listener.listenerclass}) Class.forName(className)
- .newInstance();
- } catch (Exception e) {
- throw new JspException(Messages.getMessage(
- Messages.INSTANTIATE_LISTENER_ERROR, className,
- component.getId()), e);
- }
-
- }
-
- #foreach( $prop in $listener.properties )
- #if( !$prop.existintag )
- if (_${prop.name} != null)
- {
- #if( ${prop.el} )
- if (UIComponentTag.isValueReference(_${prop.name}))
- {
- ValueBinding vb = application.createValueBinding(_${prop.name});
- listener.${prop.setterName}((${prop.simpleClassName}) vb.getValue(facesContext));
- }
- #if (!${prop.elonly})
- else
- {
- listener.${prop.setterName}((${prop.simpleClassName}) ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
- }
- #end
- }
- #else
- listener.${prop.setterName}((${prop.simpleClassName}) ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
- #end
- #end
- #end
-
- // If listener was found/created, append it to component
- if (listener != null) {
- (($listener.componentclass) component)
- .${listener.methodname}(listener);
- }
-
-
- }
-
- return SKIP_BODY;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getBinding() {
- return binding;
- }
-
- public void setBinding(String binding) {
- this.binding = binding;
- }
-
- public void release() {
- type = null;
- binding = null;
- }
-
-// Fields
-#foreach( $prop in $listener.properties )
-#if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- private String _$prop.name = null;
-
-#end
-#end
-// Setters
-#foreach( $prop in $listener.properties )
-#if( !$prop.existintag )
- /*
- * $prop.description
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}(String __${prop.name})
- {
- this._${prop.name} = __${prop.name};
- }
-
-#end
-#if( $prop.alias)
- /*
- * ${prop.xmlEncodedDescription}
- * Setter for alias of $prop.name as $prop.alias
- * @param $prop.name - new value
- */
- public void set${prop.upperFirstChar($prop.alias)}(String __${prop.alias})
- {
- this.${prop.setterName}(__${prop.alias});
- }
-#end
-#end
-
-
-
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_taghandler.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_taghandler.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listener_taghandler.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,101 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import ${listener.componentclass};
-
-import java.io.IOException;
-
-import javax.faces.*;
-import javax.faces.el.*;
-
-import javax.el.*;
-
-import com.sun.facelets.*;
-import com.sun.facelets.el.*;
-import com.sun.facelets.tag.*;
-import com.sun.facelets.tag.jsf.*;
-
-public class $tag.simpleClassName extends TagHandler {
-
- private Class listenerType;
-
- private final TagAttribute type;
-
- private final TagAttribute binding;
-
- public ${tag.simpleClassName}(TagConfig config) {
- super(config);
- this.binding = this.getAttribute("binding");
- this.type = this.getAttribute("type");
- if (type != null) {
- if (!type.isLiteral()) {
- throw new TagAttributeException(this.tag, this.type, "Must be literal");
- }
- try {
- this.listenerType = Class.forName(type.getValue());
- } catch (Exception e) {
- throw new TagAttributeException(this.tag, this.type, e);
- }
- }
- }
-
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, FaceletException, ELException {
- if (parent instanceof $listener.componentclass) {
- // only process if parent was just created
- if (parent.getParent() == null) {
- ${listener.componentclass} src = (${listener.componentclass}) parent;
- ${listener.listenerclass} listener = null;
- ValueExpression ve = null;
- if (this.binding != null) {
- ve = this.binding.getValueExpression(ctx,
- ${listener.listenerclass}.class);
- listener = (${listener.listenerclass}) ve.getValue(ctx);
- }
- if (listener == null) {
- try {
- listener = (${listener.listenerclass}) listenerType.newInstance();
- } catch (Exception e) {
- throw new TagAttributeException(this.tag, this.type, e.getCause());
- }
- if (ve != null) {
- ve.setValue(ctx, ve);
- }
- }
- #foreach($prop in $listener.properties)
- #if( !$prop.existintag )
- TagAttribute attribute;
- #if( $prop.required )
- attribute = getRequiredAttribute("${prop.name}");
- #else
- attribute = getAttribute("${prop.name}");
- #end
- if (attribute != null) {
- ValueBinding binding;
-
- binding = new LegacyValueBinding(
- attribute.getValueExpression(ctx,
- ${prop.classname}.class));
-
- listener.${prop.setterName}(binding);
- }
- #end
- #end
-
- src.${listener.methodname}(listener);
- }
- } else {
- throw new TagException(this.tag,
- "Parent is not of type ${listener.componentclass}, type is: " + parent);
- }
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/renderer.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/renderer.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/renderer.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,25 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${package};
-
-import ${component.classname};
-import ${renderer.superclass};
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/03 21:05:15 $
- *
- */
-public class ${renderer.simpleClassName} extends ${renderer.superclass} {
-
- /**
- * @see org.richfaces.renderkit.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // Expected component class for rendering
- return ${component.simpleClassName}.class;
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-config.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-config.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-config.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resource-config>
-<!-- Include manual created resource -->
-${resourcesConfig.includeContent}
-
-#foreach( $key in ${classResources.keySet()})
- <resource class="${classResources.get($key)}">
- <name>${key}</name>
- </resource>
-#end
-
-#foreach( $key in ${pathResources.keySet()})
- <resource>
- <name>${key}</name>
- <path>${pathResources.get($key)}</path>
- </resource>
-#end
-</resource-config>
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-dependencies.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-dependencies.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/resources-dependencies.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<components>
- <namespace>$uri</namespace>
-
-#foreach( $key in ${components.keySet()})
- <component>
- <name>$key</name>
-
- #set($componentEntry = ${components.get($key)})
- #set($scripts = ${componentEntry.get("scripts")})
- #set($styles = ${componentEntry.get("styles")})
-
- #if(!${scripts.isEmpty()})
- <scripts>
- #foreach($script in $scripts)
- <script>$script</script>
- #end
- </scripts>
- #end
-
- #if(!${styles.isEmpty()})
- <styles>
- #foreach($style in $styles)
- <style>$style</style>
- #end
- </styles>
- #end
- </component>
-#end
-
-</components>
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tag.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tag.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tag.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,154 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import ${component.classname};
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/03 21:05:14 $
- *
- */
-public class $tag.simpleClassName extends $tag.superclass {
-
-// Fields
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- private String _$prop.name = null;
-
- #end
-#end
-// Setters
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- /*
- * $prop.description
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( String __${prop.name} ){
- this._${prop.name} = __${prop.name};
- }
-
- #end
- #if( $prop.alias)
- /*
- * ${prop.xmlEncodedDescription}
- * Setter for alias of $prop.name as $prop.alias
- * @param $prop.name - new value
- */
- public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} ){
- this.${prop.setterName}(__${prop.alias});
- }
- #end
-#end
-// Release
-
- /* (non-Javadoc)
- * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#release()
- */
- public void release()
- {
- // TODO Auto-generated method stub
- super.release();
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- this._${prop.name} = null;
- #end
-#end
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component)
- {
- // TODO Auto-generated method stub
- super.setProperties(component);
-
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- #if(!$prop.el)
- if(null != this._${prop.name} && isValueReference(this._${prop.name})){
- throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext()) +" not allowed EL expression for property ${prop.name}");
- }
- #end
- #if($prop.name == "action")
- setActionProperty(component, this._${prop.name});
- #elseif($prop.name == "actionListener")
- setActionListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "converter")
- setConverterProperty(component, this._${prop.name});
- #elseif($prop.name == "validator")
- setValidatorProperty(component, this._${prop.name});
- #elseif($prop.name == "valueChangeListener")
- setValueChangedListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "value")
- setValueProperty(component, this._${prop.name});
- #elseif($prop.elonly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
- setValueBinding(component, "${prop.name}",this._${prop.name});
- #elseif(${prop.simpleType})
- // Simple type - ${prop.simpleClassName}
- set${prop.boxingClass}Property(component, "${prop.name}",this._${prop.name});
- #elseif($prop.classname == "java.lang.Boolean" || $prop.classname == "java.lang.Integer" || $prop.classname == "java.lang.Long")
- set${prop.simpleClassName}Property(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.String")
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.Object")
- // TODO - handle object
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
- if(null != this._${prop.name}){
- if (isValueReference(this._${prop.name}))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(this._${prop.name},
- new Class[]{${prop.methodArgsClasses}});
- ((${component.simpleClassName})component).${prop.setterName}(mb);
- }
- else
- {
- getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
- }
- }
- #else
- // TODO - setup properties for other cases.
- // name ${prop.name} with type $prop.classname
- #end
- #end
-#end
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType() {
- // TODO Auto-generated method stub
- return "${component.name}";
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType() {
- #if($renderer)
- return "${renderer.name}";
- #else
- return null;
- #end
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,102 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import ${component.classname};
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-
-import com.sun.facelets.*;
-import com.sun.facelets.el.*;
-import com.sun.facelets.tag.*;
-/**
- * @author shura (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:03 $
- *
- */
-public class $tag.simpleClassName extends $tag.superclass {
-
-
- private static final ${tag.simpleClassName}MetaRule metaRule = new ${tag.simpleClassName}MetaRule();
-
-
-
- public ${tag.simpleClassName}(ComponentConfig config)
- {
- super(config);
- }
-// Metarule
- protected MetaRuleset createMetaRuleset(Class type)
- {
- MetaRuleset m = super.createMetaRuleset(type);
- m.addRule(metaRule);
- return m;
- }
-
- /**
- * @author shura (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:03 $
- *
- */
- static class ${tag.simpleClassName}MetaRule extends MetaRule{
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String, com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
- */
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(${component.simpleClassName}.class)) {
- #foreach($prop in $component.properties)
- #if( !$prop.existintag )
- #if( $prop.isInstanceof("javax.faces.el.MethodBinding") )
- if ("${prop.name}".equals(name)) {
- return new ${prop.name}Mapper(attribute);
- }
-
- #end
- #end
- #end
- }
- return null;
- }
-
- }
-
-#foreach($prop in $component.properties)
-#if( !$prop.existintag )
-
- #if( $prop.isInstanceof("javax.faces.el.MethodBinding") )
-
- static class ${prop.name}Mapper extends Metadata {
-
- private static final Class[] SIGNATURE = new Class[] {${prop.methodArgsClasses}};
-
- private final TagAttribute _action;
- /**
- * @param attribute
- */
- public ${prop.name}Mapper(TagAttribute attribute) {
- _action = attribute;
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext, java.lang.Object)
- */
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((${component.simpleClassName}) instance)
- .${prop.setterName}(new LegacyMethodBinding(this._action
- .getMethodExpression(ctx, null,
- SIGNATURE)));
- }
-
- }
- #end
- #end
- #end
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,195 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
- "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
-<taglib>
- <tlib-version>${taglib.tlibversion}</tlib-version>
- <jsp-version>${taglib.jspversion}</jsp-version>
-#if(${taglib.shortname})
- <short-name>${taglib.shortname}</short-name>
-#end
- <uri>${taglib.uri}</uri>
-#if(${taglib.description})
- <description>${taglib.description}</description>
-#end
-${taglib.includeContent}
-
-#foreach( $component in ${components})
- #if($component.tag)
- <tag>
- <name>${component.tag.name}</name>
- <tag-class>${component.tag.classname}</tag-class>
- <body-content>${component.tag.bodyContent}</body-content>
- #if(${component.tag.displayname})
- <display-name>${component.tag.xmlEncodedDisplayname}</display-name>
- #elseif(${component.displayname})
- <display-name>${component.xmlEncodedDisplayname}</display-name>
- #end
- #if(${component.tag.description})
- <description>${component.tag.xmlEncodedDescription}</description>
- #else
- <description>${component.xmlEncodedDescription}</description>
- #end
- #foreach( $prop in ${component.properties} )
- #if( !${prop.hidden} && !${prop.disabled} )
- <attribute>
- <name>${prop.name}</name>
- #if(${prop.required})
- <required>true</required>
- #end
- <rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
- </attribute>
- #if( $prop.alias )
- <attribute>
- <name>${prop.alias}</name>
- <rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
- </attribute>
- #end
- #end
- #end
-</tag>
-#end
-#end
-
-#foreach( $validator in ${validators})
- #if($validator.tag)
- <tag>
- <name>${validator.tag.name}</name>
- <tag-class>${validator.tag.classname}</tag-class>
- <body-content>${validator.tag.bodyContent}</body-content>
- #if(${validator.tag.displayname})
- <display-name>${validator.tag.xmlEncodedDisplayname}</display-name>
- #elseif(${validator.displayname})
- <display-name>${validator.xmlEncodedDisplayname}</display-name>
- #end
- #if(${validator.tag.description})
- <description>${validator.tag.xmlEncodedDescription}</description>
- #elseif(${validator.xmlEncodedDescription})
- <description>${validator.xmlEncodedDescription}</description>
- #end
- #foreach( $prop in ${validator.properties} )
- #if( !${prop.hidden} && !${prop.disabled} )
- <attribute>
- <name>${prop.name}</name>
- #if(${prop.required})
- <required>true</required>
- #end
- <rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
- </attribute>
- #if( $prop.alias )
- <attribute>
- <name>${prop.alias}</name>
- <rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
- </attribute>
- #end
- #end
- #end
-</tag>
-#end
-#end
-
-#foreach( $converter in ${converters})
- #if($converter.tag)
- <tag>
- <name>${converter.tag.name}</name>
- <tag-class>${converter.tag.classname}</tag-class>
- <body-content>${converter.tag.bodyContent}</body-content>
- #if(${converter.tag.displayname})
- <display-name>${converter.tag.xmlEncodedDisplayname}</display-name>
- #elseif(${converter.displayname})
- <display-name>${converter.xmlEncodedDisplayname}</display-name>
- #end
- #if(${converter.tag.description})
- <description>${converter.tag.xmlEncodedDescription}</description>
- #elseif(${converter.xmlEncodedDescription})
- <description>${converter.xmlEncodedDescription}</description>
- #end
- #foreach( $prop in ${converter.properties} )
- #if( !${prop.hidden} && !${prop.disabled} )
- <attribute>
- <name>${prop.name}</name>
- #if(${prop.required})
- <required>true</required>
- #end
- <rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
- </attribute>
- #if( $prop.alias )
- <attribute>
- <name>${prop.alias}</name>
- <rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
- </attribute>
- #end
- #end
- #end
-</tag>
-#end
-#end
-
-#foreach( $listener in ${listeners})
- #if($listener.tag)
- <tag>
- #if($listener.tag.name)
- <name>${listener.tag.name}</name>
- #else
- <name>${listener.name}</name>
- #end
- <tag-class>${listener.tag.classname}</tag-class>
- <body-content>${listener.tag.bodyContent}</body-content>
- #if(${listener.tag.displayname})
- <display-name>${listener.tag.xmlEncodedDisplayname}</display-name>
- #elseif(${listener.displayname})
- <display-name>${listener.xmlEncodedDisplayname}</display-name>
- #end
- #if(${listener.tag.description})
- <description>${listener.tag.xmlEncodedDescription}</description>
- #elseif(${listener.xmlEncodedDescription})
- <description>${listener.xmlEncodedDescription}</description>
- #end
-
- <attribute>
- <name>type</name>
- <rtexprvalue>false</rtexprvalue>
- <description>
- Attribute defines the fully qualified Java class name for listener
- </description>
- </attribute>
-
- <attribute>
- <name>binding</name>
- <rtexprvalue>false</rtexprvalue>
- <description>
- The attribute takes a value-binding expression for a component property of a backing bean
- </description>
- </attribute>
-
-
- #foreach( $prop in ${listener.properties} )
- #if( !${prop.hidden} && !${prop.disabled} )
- <attribute>
- <name>${prop.name}</name>
- #if(${prop.required})
- <required>true</required>
- #end
- <rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
- </attribute>
- #if( $prop.alias )
- <attribute>
- <name>${prop.alias}</name>
- <rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
- </attribute>
- #end
- #end
- #end
-</tag>
-#end
-#end
-
-
-</taglib>
\ No newline at end of file
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tagtest.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tagtest.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/tagtest.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,173 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import javax.faces.webapp.UIComponentTag;
-import ${component.classname};
-import javax.faces.application.Application;
-import javax.faces.el.ValueBinding;
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpSession;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
-import javax.servlet.jsp.el.ExpressionEvaluator;
-import javax.servlet.jsp.el.VariableResolver;
-import javax.servlet.jsp.tagext.Tag;
-import java.io.IOException;
-import java.util.Enumeration;
-
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/03 21:05:14 $
- *
- */
-public class $tag.test.simpleClassName extends $tag.test.superclassname {
-
-
- private $tag.simpleClassName tag;
-
- /**
- * Constructor to init default renderers
- */
- public ${tag.test.simpleClassName} (String name){
- super(name);
- }
-
-
- public void setUp() throws Exception {
- super.setUp();
- tag = new ${tag.simpleClassName}();
- tag.setParent(new UIComponentTag(){
-
- public String getComponentType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRendererType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int doStartTag() throws JspException {
- // TODO Auto-generated method stub
- return Tag.EVAL_BODY_INCLUDE;
- }
-
- public int doEndTag() throws JspException {
- // TODO Auto-generated method stub
- return Tag.EVAL_BODY_INCLUDE;
- }
-
- });
-
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- tag = null;
- }
-
-
- public void testSetPropertiesUIComponent() {
- ${component.simpleClassName} component = new ${component.simpleClassName}();
- // create binding
- Application application = null;
- ValueBinding binding = null;
-
- #foreach( $prop in $tag.properties )
- #if($prop.el)
- application = facesContext.getApplication();
- binding = application.createValueBinding(component.getOnclick());
- component.setValueBinding("${prop.name}", binding);
- #if($prop.classname == "java.lang.String")
- component.${prop.setterName}( " __$prop.name" );
- #elseif($prop.classname == "java.lang.Boolean")
- component.${prop.setterName}( new Boolean(true) );
- #end
- #end
- //tag.${prop.setterName}("__${prop.name}");
- #end
-
- tag.setProperties(component);
-
-/*
- #foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- #if(!$prop.el)
- if(isValueReference(this._${prop.name})){
- throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext() +" not allowed EL expression for property ${prop.name}")
- }
- #end
- #if($prop.name == "action")
-
- setActionProperty(component, tag._${prop.name});
- #elseif($prop.name == "actionListener")
- setActionListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "converter")
- setConverterProperty(component, this._${prop.name});
- #elseif($prop.name == "validator")
- setValidatorProperty(component, this._${prop.name});
- #elseif($prop.name == "valueChangeListener")
- setValueChangedListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "value")
- setValueProperty(component, this._${prop.name});
- #elseif($prop.elonly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
- setValueBinding(component, "${prop.name}",this._${prop.name});
- #elseif(${prop.simpleType})
- // Simple type - ${prop.simpleClassName}
- set${prop.boxingClass}Property(component, "${prop.name}",this._${prop.name});
- #elseif($prop.classname == "java.lang.Boolean" || $prop.classname == "java.lang.Integer" || $prop.classname == "java.lang.Long")
- set${prop.simpleClassName}Property(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.String")
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.Object")
- // TODO - handle object
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
- if(null != this._${prop.name}){
- if (isValueReference(this._${prop.name}))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(this._${prop.name},
- new Class[]{${prop.methodArgsClasses}});
- ((${component.simpleClassName})component).${prop.setterName}(mb);
- }
- else
- {
- getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
- }
- }
- #else
- // TODO - setup properties for other cases.
- // name ${prop.name} with type $prop.classname
- #end
- #end
- #end
-*/
- }
-
- public void testGetRendererType(){
- assertNotNull(tag.getRendererType());
- }
-
- public void testGetComponentType(){
- assertNotNull(tag.getComponentType());
- }
-
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,232 +0,0 @@
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.component.StateHolder;
-
-/**
- * Validator-Id ${validator.id}
- * ${validator.xmlEncodedDescription}
- */
-public class $validator.simpleClassName extends $validator.superclass #if(${validator.stateHolderRequired} && !${validator.superclassImplementsStateHolder})implements StateHolder#end
-{
-
- public static final String VALIDATOR_ID = "${validator.id}";
-
- /**
- * Default no-args contstructor
- */
- public $validator.simpleClassName ()
- {
- }
-
-// Validator properties fields
-#set( $fieldCounter = 0 )
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
-#if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
-#set( $fieldCounter = $fieldCounter+2)
-#else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
-#set( $fieldCounter = $fieldCounter+1)
-#end
-#end
-#end
-
-// Getters and setters
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
-#if($prop.simpleType)
- this._${prop.name}Set = true;
-#end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding(_${prop.name});
-#if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
- }
- if (vb != null)
- {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value)
- {
- return this._${prop.name};
- }
- //return (value.${prop.classname}Value());
- } else
- {
- return (this._${prop.name});
- }
- }
-#else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
-#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
-#end
- else
- {
- return ${prop.defaultvalue};
- }
- }
-#end
-#if($prop.raw)
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- }
- /*
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw()
- {
- return this._${prop.name};
- }
-#end
-#end
-#end
-
-
-#if($validator.stateHolderRequired)
-
- // Save state
- // ----------------------------------------------------- StateHolder Methods
-
- private boolean _transient;
-#if(${validator.superclassImplementsStateHolder})
-#set($currentField=1)
-#set( $fieldCounter = $fieldCounter+1)
-#else
-#set($currentField=0)
-#end
- public Object saveState(FacesContext context) {
-#if(${validator.superSaveStateMethodExists})
- Object values[] = new Object[${fieldCounter}];
- values[0] = super.saveState(context);
-#else
- Object values[] = new Object[${fieldCounter}];
-#end
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
-#set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
-#set( $currentField = $currentField+1)
-#else
-#if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
-#else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
-#end
-#set( $currentField = $currentField+1)
-#end
-#end
-#end
- return values;
- }
-
-#if(${validator.superclassImplementsStateHolder})
-#set($currentField=1)
-#else
-#set($currentField=0)
-#end
- public void restoreState(FacesContext context, Object state) {
-#if(${validator.superRestoreStateMethodExists})
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
-#else
- Object values[] = (Object[]) state;
-#end
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
-#set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
-#set( $currentField = $currentField+1)
-#else
-#if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
-#else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
-#end
-#set( $currentField = $currentField+1)
-#end
-
-#end
-#end
- }
-
-#if(!$validator.superIsTransientMethodExists)
- public boolean isTransient()
- {
- return _transient;
- }
-#end
-
-#if(!$validator.superSetTransientMethodExists)
- public void setTransient(boolean newTransientValue)
- {
- this._transient = newTransientValue;
- }
-#end
-
-#end
-
-
-// Utilites
-
- private FacesContext getFacesContext()
- {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name)
- {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
-}
\ No newline at end of file
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validatorTag.vm
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validatorTag.vm 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validatorTag.vm 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,96 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import javax.faces.webapp.UIComponentTag;
-import javax.faces.validator.Validator;
-import org.apache.commons.beanutils.ConvertUtils;
-import javax.faces.context.FacesContext;
-import javax.servlet.jsp.JspException;
-import javax.faces.el.ValueBinding;
-import ${validator.classname};
-
-public class $tag.simpleClassName extends $tag.superclass {
-
- //private String validatorId = "${validator.id}";
-
-
-// Fields
-#foreach( $prop in $validator.properties )
-#if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- private String _$prop.name = null;
-
-#end
-#end
-// Setters
-#foreach( $prop in $validator.properties )
-#if( !$prop.existintag )
- /*
- * $prop.description
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( String __${prop.name} )
- {
- this._${prop.name} = __${prop.name};
- }
-
-#end
-#if( $prop.alias)
- /*
- * ${prop.xmlEncodedDescription}
- * Setter for alias of $prop.name as $prop.alias
- * @param $prop.name - new value
- */
- public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} )
- {
- this.${prop.setterName}(__${prop.alias});
- }
-#end
-#end
-
- protected Validator createValidator() throws JspException
- {
- ${validator.simpleClassName} validator = (${validator.simpleClassName}) FacesContext.getCurrentInstance().getApplication().createValidator("${validator.id}");
- _setProperties(validator);
- return validator;
- }
-
- // Support method to wire in properties
- private void _setProperties(${validator.simpleClassName} validator) throws JspException
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-#foreach( $prop in $validator.properties )
-#if( !$prop.existintag )
- if (_${prop.name} != null)
- {
-#if( ${prop.el} )
- if (UIComponentTag.isValueReference(_${prop.name}))
- {
- ValueBinding vb = facesContext.getApplication().createValueBinding(_${prop.name});
- validator.${prop.setterName}((${prop.simpleClassName}) vb.getValue(facesContext));
- }
-#if (!${prop.elonly})
- else
- {
- validator.${prop.setterName}((${prop.simpleClassName}) ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
- }
-#end
- }
-#else
- validator.${prop.setterName}((${prop.simpleClassName}) ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
-#end
-#end
-#end
- }
-}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java (from rev 15186, root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,347 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.apt;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+import static javax.lang.model.util.ElementFilter.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Set;
+import java.util.logging.LogManager;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import org.easymock.Capture;
+import org.easymock.CaptureType;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.apt.CdkProcessor.BeanProperty;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CdkProcessorTest {
+
+ private static final String ANNOTATION2 = TestAnnotation2.class.getName();
+
+ private static abstract class TestProcessor extends CdkProcessor {
+
+ protected ComponentLibrary library;
+
+ protected int numOfComponents;
+
+ public TestProcessor(CdkContext context) {
+ super(context);
+ }
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ }
+
+ @Override
+ public synchronized boolean isInitialized() {
+ return super.isInitialized();
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ // Process all annotations
+ return ImmutableSet.of("*");
+ }
+
+ }
+
+ private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
+ private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
+ private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
+ private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet
+ .of(TestAnnotation.class.getName());
+ private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
+
+ private File testSourceDirectory;
+ private ClassLoader testLoader;
+
+ @Before
+ public void setUp() throws Exception {
+ testSourceDirectory = getJavaFile("test.source.properties")
+ .getParentFile();
+ InputStream stream = this.getClass().getResourceAsStream(
+ "logging.properties");
+ if (null != stream) {
+ try {
+ LogManager.getLogManager().readConfiguration(stream);
+ } catch (Exception e) {
+ // Ignore it.
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Ignore it.
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDown() {
+ testSourceDirectory = null;
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcess() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
+ expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ TestAnnotation.class.getClassLoader());
+ replay(cdkContext);
+
+ Processor processor = createMock(Processor.class);
+ processor.init((ProcessingEnvironment) anyObject());
+ expect(processor.getSupportedOptions()).andReturn(
+ ImmutableSet.<String> of());
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>();
+ expect(
+ processor.process(capture(capturedTypes),
+ capture(new Capture<RoundEnvironment>()))).andReturn(
+ true).times(2);
+ expect(processor.getSupportedAnnotationTypes()).andReturn(
+ ImmutableSet.of(TestAnnotation.class.getName()));
+ expect(processor.getSupportedSourceVersion()).andReturn(
+ SourceVersion.RELEASE_6);
+ replay(processor);
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
+ verify(cdkContext, processor);
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcessSubClass() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
+ expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+
+ Processor processor = createMock(Processor.class);
+ processor.init((ProcessingEnvironment) anyObject());
+ expect(processor.getSupportedOptions()).andReturn(
+ ImmutableSet.<String> of());
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>(
+ CaptureType.FIRST);
+ expect(
+ processor.process(capture(capturedTypes),
+ capture(new Capture<RoundEnvironment>()))).andReturn(
+ true).times(2);
+ expect(processor.getSupportedAnnotationTypes()).andReturn(
+ ImmutableSet.of(TestAnnotation2.class.getName()));
+ expect(processor.getSupportedSourceVersion()).andReturn(
+ SourceVersion.RELEASE_6);
+ replay(processor);
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA),
+ getJavaFile(CLASS_JAVA)), processor);
+ verify(cdkContext, processor);
+ Set<? extends TypeElement> elements = capturedTypes.getValue();
+ assertFalse(elements.isEmpty());
+ assertEquals("TestAnnotation2", elements.iterator().next()
+ .getSimpleName().toString());
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetClassesAnnotatedWith() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
+ expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+ TestProcessor processor = new TestProcessor(cdkContext) {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations,
+ RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ this.numOfComponents = getClassesAnnotatedWith(
+ roundEnv, Component.class).size();
+
+ }
+ return true;
+ }
+ };
+ // ComponentLibrary library = new
+ // ComponentLibrary("org.richfaces.cdk.test");
+ // processor.library = library;
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
+ processor);
+ verify(cdkContext);
+ assertTrue(processor.isInitialized());
+ assertEquals(1, processor.numOfComponents);
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetPropertiesAnnotatedWith() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
+ expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+ TestProcessor processor = new TestProcessor(cdkContext) {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations,
+ RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ TypeElement typeElement = getClassesAnnotatedWith(
+ roundEnv, Component.class).iterator().next();
+ Set<BeanProperty> beanProperties = getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
+ assertEquals(3, beanProperties.size());
+ BeanProperty property = Iterables.get(beanProperties,2);
+ assertEquals("foo", property.getName());
+ assertEquals("int", property.getType().toString());
+ assertNull(property.getDocComment());
+
+ property = Iterables.get(beanProperties,1);
+ assertEquals("testValue", property.getName());
+ assertEquals("java.util.List<java.lang.String>", property.getType().toString());
+ assertEquals(" Test Attribute\n", property.getDocComment());
+
+ property = Iterables.get(beanProperties,0);
+ assertEquals("barValue", property.getName());
+ assertEquals("java.util.List<M>", property.getType().toString());
+ assertEquals(" Bar Attribute\n", property.getDocComment());
+// assertEquals("<M>" ,property.getTypeParameters());
+
+ numOfComponents++;
+ }
+ return true;
+ }
+ };
+ // ComponentLibrary library = new
+ // ComponentLibrary("org.richfaces.cdk.test");
+ // processor.library = library;
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
+ processor);
+ verify(cdkContext);
+ assertTrue(processor.isInitialized());
+ assertEquals(1, processor.numOfComponents);
+ }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ * TODO
+ * @return
+ * @throws URISyntaxException
+ */
+ private JavaFileObject getJavaFileObject(String name)
+ throws URISyntaxException {
+ final File classFile = getJavaFile(name);
+ SimpleJavaFileObject fileObject = new VirtualJavaFileSystemObject(
+ classFile);
+ return fileObject;
+ }
+
+ private File getJavaFile(String name) throws URISyntaxException {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ URL testResource = classLoader.getResource(name);
+ URI testUri = testResource.toURI();
+ final File classFile = new File(testUri);
+ return classFile;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,142 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.apt;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+import static javax.lang.model.util.ElementFilter.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Set;
+import java.util.logging.LogManager;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Property;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentProcessorTest {
+
+
+ private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
+ private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
+ private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
+ private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet
+ .of(TestAnnotation.class.getName());
+ private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
+
+ private File testSourceDirectory;
+ private ClassLoader testLoader;
+
+ @Before
+ public void setUp() throws Exception {
+ testSourceDirectory = getJavaFile("test.source.properties")
+ .getParentFile();
+ InputStream stream = this.getClass().getResourceAsStream(
+ "logging.properties");
+ if (null != stream) {
+ try {
+ LogManager.getLogManager().readConfiguration(stream);
+ } catch (Exception e) {
+ // Ignore it.
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Ignore it.
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDown() {
+ testSourceDirectory = null;
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcess() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(cdkContext,library);
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
+ verify(cdkContext);
+ Collection<Component> components = library.getComponents();
+ assertEquals(1, components.size());
+ Component component = Iterables.get(components, 0);
+ Collection<Property> attributes = component.getAttributes();
+ assertEquals(3, attributes.size());
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
+ expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ TestAnnotation.class.getClassLoader());
+ replay(cdkContext);
+ return cdkContext;
+ }
+
+ private File getJavaFile(String name) throws URISyntaxException {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ URL testResource = classLoader.getResource(name);
+ URI testUri = testResource.toURI();
+ final File classFile = new File(testUri);
+ return classFile;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java 2009-08-17 15:48:55 UTC (rev 15186)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -1,347 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.apt;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-import static javax.lang.model.util.ElementFilter.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Set;
-import java.util.logging.LogManager;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.Processor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.apt.CdkProcessor.BeanProperty;
-import org.richfaces.cdk.model.ComponentLibrary;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class ProcessorTest {
-
- private static final String ANNOTATION2 = TestAnnotation2.class.getName();
-
- private static abstract class TestProcessor extends CdkProcessor {
-
- protected ComponentLibrary library;
-
- protected int numOfComponents;
-
- public TestProcessor(CdkContext context) {
- super(context);
- }
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- }
-
- @Override
- public synchronized boolean isInitialized() {
- return super.isInitialized();
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- // Process all annotations
- return ImmutableSet.of("*");
- }
-
- }
-
- private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
- private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
- private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
- private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet
- .of(TestAnnotation.class.getName());
- private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
-
- private File testSourceDirectory;
- private ClassLoader testLoader;
-
- @Before
- public void setUp() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
- InputStream stream = this.getClass().getResourceAsStream(
- "logging.properties");
- if (null != stream) {
- try {
- LogManager.getLogManager().readConfiguration(stream);
- } catch (Exception e) {
- // Ignore it.
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // Ignore it.
- }
- }
- }
- }
-
- @After
- public void tearDown() {
- testSourceDirectory = null;
- }
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcess() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation.class.getClassLoader());
- replay(cdkContext);
-
- Processor processor = createMock(Processor.class);
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(
- ImmutableSet.<String> of());
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>();
- expect(
- processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(
- true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(
- ImmutableSet.of(TestAnnotation.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(
- SourceVersion.RELEASE_6);
- replay(processor);
- CdkCompiler compiler = new CdkCompiler();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
- }
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcessSubClass() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
-
- Processor processor = createMock(Processor.class);
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(
- ImmutableSet.<String> of());
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>(
- CaptureType.FIRST);
- expect(
- processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(
- true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(
- ImmutableSet.of(TestAnnotation2.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(
- SourceVersion.RELEASE_6);
- replay(processor);
- CdkCompiler compiler = new CdkCompiler();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA),
- getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
- Set<? extends TypeElement> elements = capturedTypes.getValue();
- assertFalse(elements.isEmpty());
- assertEquals("TestAnnotation2", elements.iterator().next()
- .getSimpleName().toString());
- }
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(Class, RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testGetClassesAnnotatedWith() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- TestProcessor processor = new TestProcessor(cdkContext) {
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- this.numOfComponents = getClassesAnnotatedWith(
- Component.class, roundEnv).size();
-
- }
- return true;
- }
- };
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- CdkCompiler compiler = new CdkCompiler();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
- processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- }
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(Class, RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testGetPropertiesAnnotatedWith() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- TestProcessor processor = new TestProcessor(cdkContext) {
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- TypeElement typeElement = getClassesAnnotatedWith(
- Component.class, roundEnv).iterator().next();
- Set<BeanProperty> beanProperties = getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
- assertEquals(3, beanProperties.size());
- BeanProperty property = Iterables.get(beanProperties,2);
- assertEquals("foo", property.getName());
- assertEquals("int", property.getType().toString());
- assertNull(property.getDocComment());
-
- property = Iterables.get(beanProperties,1);
- assertEquals("testValue", property.getName());
- assertEquals("java.util.List<java.lang.String>", property.getType().toString());
- assertEquals(" Test Attribute\n", property.getDocComment());
-
- property = Iterables.get(beanProperties,0);
- assertEquals("barValue", property.getName());
- assertEquals("java.util.List<M>", property.getType().toString());
- assertEquals(" Bar Attribute\n", property.getDocComment());
-// assertEquals("<M>" ,property.getTypeParameters());
-
- numOfComponents++;
- }
- return true;
- }
- };
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- CdkCompiler compiler = new CdkCompiler();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
- processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param name
- * TODO
- * @return
- * @throws URISyntaxException
- */
- private JavaFileObject getJavaFileObject(String name)
- throws URISyntaxException {
- final File classFile = getJavaFile(name);
- SimpleJavaFileObject fileObject = new VirtualJavaFileSystemObject(
- classFile);
- return fileObject;
- }
-
- private File getJavaFile(String name) throws URISyntaxException {
- ClassLoader classLoader = this.getClass().getClassLoader();
- URL testResource = classLoader.getResource(name);
- URI testUri = testResource.toURI();
- final File classFile = new File(testUri);
- return classFile;
- }
-
-}
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,112 @@
+package org.richfaces.cdk.freemarker;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.logging.LogManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.apt.TestAnnotation;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.JsfComponent;
+
+public class FreeMarkerRendererTest {
+
+ private File testSourceDirectory;
+ private ClassLoader testLoader;
+
+ @Before
+ public void setUp() throws Exception {
+ testSourceDirectory = getJavaFile("test.source.properties")
+ .getParentFile();
+ InputStream stream = this.getClass().getResourceAsStream(
+ "logging.properties");
+ if (null != stream) {
+ try {
+ LogManager.getLogManager().readConfiguration(stream);
+ } catch (Exception e) {
+ // Ignore it.
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Ignore it.
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDown() {
+ testSourceDirectory = null;
+ }
+ @Test
+ public void testRender() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testProcessComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ Component component = new Component();
+ component.setType(new Component.Type("foo.Bar"));
+ FreeMarkerRenderer<Component, Boolean> renderer = new FreeMarkerRenderer<Component, Boolean>(){
+
+ @Override
+ protected String getOutputFile(Component c) {
+ return null;
+ }
+
+ @Override
+ protected Writer getOutput(Component c) throws IOException {
+ return output;
+ }
+ @Override
+ protected String getTemplateName() {
+
+ return "testComponent.ftl";
+ }
+
+ @Override
+ protected boolean isMyComponent(JsfComponent c) {
+ return true;
+ }
+ };
+ CdkContext cdkContext = createMockContext();
+ renderer.init(cdkContext);
+ renderer.processComponent(component, Boolean.TRUE);
+ assertEquals("foo.Bar", output.toString());
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
+ expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ testLoader);
+ replay(cdkContext);
+ return cdkContext;
+ }
+
+ private File getJavaFile(String name) throws URISyntaxException {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ URL testResource = classLoader.getResource(name);
+ URI testUri = testResource.toURI();
+ final File classFile = new File(testUri);
+ return classFile;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,90 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.jaxb;
+
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+import static javax.lang.model.util.ElementFilter.*;
+
+import java.io.StringReader;
+import java.util.Set;
+
+import javax.xml.bind.JAXB;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.cdk.jaxb.model.Child;
+import org.richfaces.cdk.jaxb.model.Root;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class JaxbMarshallTest {
+
+ private static final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testRootElement() throws Exception {
+ String xml=XML_PROLOG+
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>";
+ StringReader reader = new StringReader(xml);
+ Root root = JAXB.unmarshal(reader, Root.class);
+ assertEquals("foo", root.getName());
+ Set<Child> children = root.getChildren();
+ assertEquals(1,children.size());
+ assertEquals("xxx",children.iterator().next().getId());
+ }
+ @Test
+ public void testUniqueElement() throws Exception {
+ String xml=XML_PROLOG+
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>";
+ StringReader reader = new StringReader(xml);
+ Root root = JAXB.unmarshal(reader, Root.class);
+ assertEquals("foo", root.getName());
+ Set<Child> children = root.getChildren();
+ assertEquals(1,children.size());
+ assertEquals("xxx",children.iterator().next().getId());
+ assertEquals("baz",children.iterator().next().getValue());
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,111 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.jaxb.model;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlType(name="ChildType",namespace=Root.HTTP_FOO_BAR_SCHEMA)
+public class Child implements Id {
+
+ private String id;
+
+ private String value;
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.jaxb.model.Id#getId()
+ */
+ @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the value
+ */
+ @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof Child)) {
+ return false;
+ }
+ Child other = (Child) obj;
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Id.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Id.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Id.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,14 @@
+package org.richfaces.cdk.jaxb.model;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public interface Id {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId();
+
+}
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Id.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Root.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Root.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Root.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,82 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.jaxb.model;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.google.common.collect.Sets;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlRootElement(name="root-config",namespace=Root.HTTP_FOO_BAR_SCHEMA)
+public class Root {
+
+ public static final String HTTP_FOO_BAR_SCHEMA = "http://foo.bar/schema";
+
+ public static final String EXTENSIONS_NAMESPACE = "http://foo.bar/extensions";
+
+ private String name;
+
+ private Set<Child> children = Sets.newHashSet();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(namespace=HTTP_FOO_BAR_SCHEMA)
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the children
+ */
+ @XmlElement(namespace=HTTP_FOO_BAR_SCHEMA)
+ public Set<Child> getChildren() {
+ return children;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param children the children to set
+ */
+ public void setChildren(Set<Child> children) {
+ this.children = children;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Root.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/package-info.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/package-info.java 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1,24 @@
+/**
+ * <h2>CDK library model classes used by all generation tasks.</h2>
+ * <p>CDK architecture seems like MVC-pattern implementation. The controller {@link org.richfaces.cdk.LibraryBuilder} class
+ * generates model from different sources ( Java Annotations, XML files and so on ). That model will be used to generate all necessary
+ * classes by the appropriate "renderers" that act as 'View' part of pattern.</p>
+ * <p>That model:</p>
+ * <ul>
+ * <li>Contains all information about JSF library components and their properties</li>
+ * <li>Encapsulates restrictions and references for model components, therefore it should be modified by model metods only.</li>
+ * <li>Encapsulates <a href="http://www.jboss.org/community/docs/DOC-13693">CDK naming conventions</a></li>
+ * <li>Provides 'Visitor' pattern methods. see {@link LibraryVisitor} for reference.</li>
+ * </ul>
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+(a)javax.xml.bind.annotation.XmlSchema(namespace=Root.HTTP_FOO_BAR_SCHEMA ,
+ xmlns = {(a)javax.xml.bind.annotation.XmlNs( prefix = "",
+ namespaceURI = Root.HTTP_FOO_BAR_SCHEMA ),
+ @javax.xml.bind.annotation.XmlNs( prefix = "ext",
+ namespaceURI = Root.EXTENSIONS_NAMESPACE ) })
+package org.richfaces.cdk.jaxb.model;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/resources/META-INF/templates/testComponent.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/META-INF/templates/testComponent.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/META-INF/templates/testComponent.ftl 2009-08-17 23:31:33 UTC (rev 15187)
@@ -0,0 +1 @@
+${type}
\ No newline at end of file
15 years, 4 months
JBoss Rich Faces SVN: r15186 - in root/framework/trunk/impl/src: main/java/org/richfaces/context and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-17 11:48:55 -0400 (Mon, 17 Aug 2009)
New Revision: 15186
Added:
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
root/framework/trunk/impl/src/main/resources/META-INF/components.faces-config.xml
root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
Log:
Dynamic execute/render updated
Small resources refactoring
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -25,6 +25,7 @@
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -127,6 +128,19 @@
public static final String SIMILARITY_GROUPING_ID_ATTR = "similarityGroupingId";
private static final RendererUtils rendererUtils = RendererUtils.getInstance();
+
+ public static final String ALL = "@all";
+
+ public static final Collection<String> ALL_SET = Collections.singleton(ALL);
+
+ public static final String FORM = "@form";
+
+ public static final String THIS = "@this";
+
+ public static final String NONE = "@none";
+
+ public static final Collection<String> NONE_SET = Collections.singleton(NONE);
+
/**
* Static class - protect constructor
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@@ -970,7 +971,19 @@
*/
public Collection<String> findComponentsFor(FacesContext context, UIComponent component, Collection<String> shortIds) {
//TODO - implement
- return shortIds;
+ //TODO add support for @*
+ Set<String> result = new LinkedHashSet<String>();
+ for (String id : shortIds) {
+ if (AjaxRendererUtils.THIS.equals(id)) {
+ result.add(component.getClientId(context));
+ } else if (AjaxRendererUtils.FORM.equals(id)) {
+ result.add(getNestingForm(context, component).getClientId(context));
+ } else {
+ result.add(id);
+ }
+ }
+
+ return result;
}
Added: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java (rev 0)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.context;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+import org.ajax4jsf.component.AjaxOutput;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PartialViewContextAjaxOutputTracker implements SystemEventListener {
+
+ private static final String AJAX_OUTPUT_COMPONENTS_SET_ATTRIBUTE =
+ PartialViewContextAjaxOutputTracker.class + ":AjaxOutputComponentsSet";
+
+ static Collection<AjaxOutput> getAjaxOutputComponentsSet(FacesContext context) {
+ AttributesContext attributes = SingletonsContext.FACES_CONTEXT.get(context);
+ Collection<AjaxOutput> components = (Collection<AjaxOutput>) attributes.getAttribute(AJAX_OUTPUT_COMPONENTS_SET_ATTRIBUTE);
+ if (components == null) {
+ components = new ArrayList<AjaxOutput>();
+ attributes.setAttribute(AJAX_OUTPUT_COMPONENTS_SET_ATTRIBUTE, components);
+ }
+
+ return components;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.SystemEventListener#isListenerForSource(java.lang.Object)
+ */
+ public boolean isListenerForSource(Object source) {
+ return source instanceof AjaxOutput;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
+ */
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ getAjaxOutputComponentsSet(facesContext).add((AjaxOutput) event.getSource());
+ }
+
+}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -50,9 +50,6 @@
return partialViewContext;
}
- /* (non-Javadoc)
- * @see javax.faces.context.PartialViewContextFactory#getWrapped()
- */
@Override
public PartialViewContextFactory getWrapped() {
return parentFactory;
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -21,13 +21,14 @@
package org.richfaces.context;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitHint;
@@ -37,6 +38,7 @@
import javax.faces.context.PartialViewContextWrapper;
import javax.faces.event.PhaseId;
+import org.ajax4jsf.component.AjaxOutput;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
@@ -50,6 +52,10 @@
private final String activatorId;
+ private boolean hasProcessedExecute = false;
+
+ private boolean executeAll = true;
+
public PartialViewContextImpl(PartialViewContext wrappedContext, String activatorId) {
super();
@@ -69,62 +75,189 @@
);
}
- private static final class ComponentIdsCallback implements VisitCallback {
+ private static class ComponentCallback implements VisitCallback {
+
+ private final String attributeName;
- private final String targetAttributeName;
+ private boolean handleAll;
- public ComponentIdsCallback(String targetAttributeName) {
+ private boolean handleNone;
+
+ private Collection<String> componentIds = new LinkedHashSet<String>();
+
+ public ComponentCallback(String attributeName, boolean handleNone,
+ boolean handleAll) {
super();
-
- this.targetAttributeName = targetAttributeName;
+ this.attributeName = attributeName;
+ this.handleNone = handleNone;
+ this.handleAll = handleAll;
}
-
- private Collection<String> componentIds = new LinkedHashSet<String>();
- public Collection<String> getComponentIds() {
- return componentIds;
+ protected void addDefaultComponents(Collection<String> ids) {
+
}
-
+
public VisitResult visit(VisitContext context, UIComponent target) {
- Object attributeValue = target.getAttributes().get(targetAttributeName);
+ Object attributeValue = target.getAttributes().get(attributeName);
Set<String> attributeIds = AjaxRendererUtils.asSet(attributeValue);
- if (attributeIds != null) {
- componentIds.addAll(RendererUtils.getInstance().findComponentsFor(context.getFacesContext(), target, attributeIds));
+ if (attributeIds != null && !attributeIds.isEmpty()) {
+ if (attributeIds.contains(AjaxRendererUtils.ALL)) {
+ if (!AjaxRendererUtils.ALL_SET.equals(attributeIds)) {
+ //TODO: log
+ }
+
+ handleAll = true;
+ } else {
+ handleAll = false;
+
+ if (attributeIds.contains(AjaxRendererUtils.NONE)) {
+ if (!AjaxRendererUtils.NONE_SET.equals(attributeIds)) {
+ //TODO: log
+ }
+
+ handleNone = true;
+ } else {
+ //asSet() returns copy of original set and we're free to modify it
+ addDefaultComponents(attributeIds);
+
+ componentIds.addAll(RendererUtils.getInstance().findComponentsFor(
+ context.getFacesContext(), target, attributeIds));
+ }
+ }
}
return VisitResult.COMPLETE;
}
+
+ public Collection<String> getComponentIds() {
+ return componentIds;
+ }
+
+ public boolean isHandleAll() {
+ return handleAll;
+ }
+
+ public boolean isHandleNone() {
+ return handleNone;
+ }
}
- private Collection<String> getComponentIds(String targetAttributeName) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ComponentIdsCallback componentIdsCallback = new ComponentIdsCallback(targetAttributeName);
+ private static class ExecuteComponentCallback extends ComponentCallback {
+
+ public ExecuteComponentCallback() {
+ super("execute", false, true);
+ }
+
+ @Override
+ protected void addDefaultComponents(Collection<String> ids) {
+ super.addDefaultComponents(ids);
+ ids.add(AjaxRendererUtils.THIS);
+ }
+
+ }
+
+ private static class RenderComponentCallback extends ComponentCallback {
- UIViewRoot viewRoot = facesContext.getViewRoot();
+ public RenderComponentCallback() {
+ super("render", false, false);
+ }
+
+ private boolean limitToList = false;
- boolean visitResult = viewRoot.visitTree(
- createVisitContext(facesContext),
- componentIdsCallback);
-
- if (!visitResult) {
- //TODO
+ public boolean isLimitToList() {
+ return limitToList;
}
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ VisitResult visitResult = super.visit(context, target);
+
+ limitToList = AjaxRendererUtils.isAjaxLimitToList(target);
+
+ return visitResult;
+ }
+ }
+
+ //TODO: data table support
+ private Collection<String> getAjaxOutputComponentIds(FacesContext facesContext) {
+ List<String> ids = new ArrayList<String>();
+ Collection<AjaxOutput> ajaxOutputComponentsSet = PartialViewContextAjaxOutputTracker.getAjaxOutputComponentsSet(facesContext);
+ for (AjaxOutput ajaxOutput : ajaxOutputComponentsSet) {
+ UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
+ ids.add(ajaxOutputComponent.getClientId(facesContext));
+ }
- return componentIdsCallback.getComponentIds();
+ return ids;
}
+
+ private void processExecute(PartialViewContext partialViewContext) {
+ if (!hasProcessedExecute) {
+ hasProcessedExecute = true;
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ ExecuteComponentCallback executeCallback = new ExecuteComponentCallback();
+
+ boolean visitResult = facesContext.getViewRoot().visitTree(
+ createVisitContext(facesContext),
+ executeCallback);
+
+ if (!visitResult) {
+ //TODO:
+ }
+
+ executeAll = executeCallback.isHandleAll();
+ if (!executeAll) {
+ Collection<String> executeIds = partialViewContext.getExecuteIds();
+ executeIds.clear();
+
+ if (!executeCallback.isHandleNone()) {
+ executeIds.addAll(executeCallback.getComponentIds());
+ //TODO ids from wrapped object?
+ }
+ }
+ }
+ }
+ private void processRender(PartialViewContext partialViewContext) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ if (!partialViewContext.isRenderAll()) {
+ RenderComponentCallback renderCallback = new RenderComponentCallback();
+ boolean visitResult = facesContext.getViewRoot().visitTree(
+ createVisitContext(facesContext),
+ renderCallback);
+
+ if (!visitResult) {
+ //TODO:
+ }
+
+ boolean renderAll = renderCallback.isHandleAll();
+ partialViewContext.setRenderAll(renderAll);
+ if (!renderAll) {
+ Collection<String> renderIds = partialViewContext.getRenderIds();
+ renderIds.clear();
+
+ if (!renderCallback.isHandleNone()) {
+ renderIds.addAll(renderCallback.getComponentIds());
+
+ if (!renderCallback.isLimitToList()) {
+ Collection<String> ajaxOutputComponentIds = getAjaxOutputComponentIds(facesContext);
+ renderIds.addAll(ajaxOutputComponentIds);
+ //TODO ids from wrapped object?
+ }
+ }
+ }
+ }
+ }
+
@Override
public void processPartial(PhaseId phaseId) {
PartialViewContext wrapped = getWrapped();
if (PhaseId.APPLY_REQUEST_VALUES.equals(phaseId)) {
- Collection<String> executeIds = wrapped.getExecuteIds();
- executeIds.clear();
- executeIds.addAll(getComponentIds("execute"));
+ processExecute(wrapped);
} else if (PhaseId.RENDER_RESPONSE.equals(phaseId)) {
- Collection<String> renderIds = wrapped.getRenderIds();
- renderIds.clear();
- renderIds.addAll(getComponentIds("render"));
+ processRender(wrapped);
}
wrapped.processPartial(phaseId);
@@ -132,7 +265,39 @@
@Override
public void setPartialRequest(boolean isPartialRequest) {
- // TODO Auto-generated method stub
-
+ getWrapped().setPartialRequest(isPartialRequest);
}
+
+ /* (non-Javadoc)
+ * @see javax.faces.context.PartialViewContextWrapper#getRenderIds()
+ */
+ @Override
+ public Collection<String> getRenderIds() {
+ return getWrapped().getRenderIds();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.context.PartialViewContextWrapper#getExecuteIds()
+ */
+ @Override
+ public Collection<String> getExecuteIds() {
+ return getWrapped().getExecuteIds();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.context.PartialViewContextWrapper#isExecuteAll()
+ */
+ @Override
+ public boolean isExecuteAll() {
+ processExecute(getWrapped());
+ return executeAll;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.context.PartialViewContextWrapper#isRenderAll()
+ */
+ @Override
+ public boolean isRenderAll() {
+ return getWrapped().isRenderAll();
+ }
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -79,7 +79,7 @@
* <b>IMPORTANT:</b> this method returned TTL in RF 3.x, now it returns expiration time
* @return Returns the expired.
*/
- protected Date getExpired(FacesContext context) {
+ protected Date getExpires(FacesContext context) {
return null;
}
@@ -252,7 +252,7 @@
if (maxAge > 0) {
formattedExpireDate = Util.formatHttpDate(currentTime + maxAge * 1000L);
} else {
- Date expired = getExpired(facesContext);
+ Date expired = getExpires(facesContext);
if (expired != null) {
formattedExpireDate = Util.formatHttpDate(expired);
maxAge = (expired.getTime() - currentTime) / 1000L;
@@ -327,7 +327,7 @@
return System.currentTimeMillis() + ttl * 1000;
}
- Date date = AbstractBaseResource.this.getExpired(facesContext);
+ Date date = AbstractBaseResource.this.getExpires(facesContext);
if (date != null) {
return date.getTime();
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -102,6 +102,7 @@
CacheManager cacheManager = CacheManager.getInstance();
Map<?,?> envMap = facesContext.getExternalContext().getInitParameterMap();
cacheManager.createCache(RESOURCE_CACHE_NAME, envMap);
+ cache = cacheManager.getCache(RESOURCE_CACHE_NAME);
}
private void markStartTime(FacesContext facesContext) {
Modified: root/framework/trunk/impl/src/main/resources/META-INF/components.faces-config.xml
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/components.faces-config.xml 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/main/resources/META-INF/components.faces-config.xml 2009-08-17 15:48:55 UTC (rev 15186)
@@ -6,5 +6,12 @@
<factory>
<partial-view-context-factory>org.richfaces.context.PartialViewContextFactoryImpl</partial-view-context-factory>
</factory>
+
+ <application>
+ <system-event-listener>
+ <system-event-listener-class>org.richfaces.context.PartialViewContextAjaxOutputTracker</system-event-listener-class>
+ <system-event-class>javax.faces.event.PostAddToViewEvent</system-event-class>
+ </system-event-listener>
+ </application>
</faces-config>
Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -164,7 +164,7 @@
}
@Override
- protected Date getExpired(FacesContext context) {
+ protected Date getExpires(FacesContext context) {
return expired;
}
@@ -362,7 +362,7 @@
assertEquals(-1, defaultResource.getContentLength(facesContext));
assertNull(defaultResource.getEntityTag(facesContext));
assertNull(defaultResource.getVersion());
- assertNull(defaultResource.getExpired(facesContext));
+ assertNull(defaultResource.getExpires(facesContext));
Date lastModified = defaultResource.getLastModified(facesContext);
assertNotNull(lastModified);
assertTrue(System.currentTimeMillis() >= lastModified.getTime());
Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java 2009-08-17 13:01:57 UTC (rev 15185)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java 2009-08-17 15:48:55 UTC (rev 15186)
@@ -77,7 +77,7 @@
}
@Override
- protected Date getExpired(FacesContext context) {
+ protected Date getExpires(FacesContext context) {
return ResourceHandlerImplTest.expires;
}
}
15 years, 4 months