JBoss Rich Faces SVN: r17785 - root/build/resources/tags.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-07-09 11:21:46 -0400 (Fri, 09 Jul 2010)
New Revision: 17785
Added:
root/build/resources/tags/richfaces-shade-transformers-2/
Log:
[maven-scm] copy for tag richfaces-shade-transformers-2
Copied: root/build/resources/tags/richfaces-shade-transformers-2 (from rev 17784, root/build/resources/trunk/faces-shade-transformers)
14 years, 6 months
JBoss Rich Faces SVN: r17782 - in root: archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-07-09 11:15:39 -0400 (Fri, 09 Jul 2010)
New Revision: 17782
Added:
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/TogglePanelBean.java
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/examples/
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/examples/divPanel.xhtml
Removed:
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/RichBean.java
Modified:
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/index.xhtml
root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/templates/template.xhtml
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/resources/META-INF/resources/script/TogglePanel.js
Log:
RF-8745 TogglePanel component
Deleted: root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/RichBean.java
===================================================================
--- root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/RichBean.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/RichBean.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -1,27 +0,0 @@
-package org.richfaces;
-
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-import java.io.Serializable;
-
-public class RichBean implements Serializable {
-
- private static final long serialVersionUID = -2403138958014741653L;
- private Logger logger;
- private String name;
-
- public RichBean() {
- logger = LoggerFactory.getLogger(RichBean.class);
- logger.info("post construct: initialize");
- name = "John";
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
Copied: root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/TogglePanelBean.java (from rev 17626, root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/RichBean.java)
===================================================================
--- root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/TogglePanelBean.java (rev 0)
+++ root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/java/org/richfaces/TogglePanelBean.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -0,0 +1,32 @@
+package org.richfaces;
+
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+
+import java.io.Serializable;
+
+public class TogglePanelBean implements Serializable {
+
+ private static final long serialVersionUID = -2403138958014741653L;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TogglePanelBean.class);
+
+ private String name;
+
+ public TogglePanelBean() {
+ LOGGER.info("post construct: initialize");
+ name = "John";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void itemChangeActionListener() {
+ LOGGER.info("TogglePanelBean.itemChangeActionListener");
+ }
+}
Modified: root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml 2010-07-09 15:15:39 UTC (rev 17782)
@@ -3,8 +3,38 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<managed-bean>
- <managed-bean-name>richBean</managed-bean-name>
- <managed-bean-class>org.richfaces.RichBean</managed-bean-class>
+ <managed-bean-name>togglePanelBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.TogglePanelBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
</managed-bean>
+
+ <navigation-rule>
+ <!-- Examples -->
+ <navigation-case>
+ <from-outcome>togglePanel</from-outcome>
+ <to-view-id>/examples/togglePanel.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>togglePanel/server</from-outcome>
+ <to-view-id>/examples/togglePanel-server.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>togglePanel/ajax</from-outcome>
+ <to-view-id>/examples/togglePanel-ajax.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>togglePanel/client</from-outcome>
+ <to-view-id>/examples/togglePanel-client.xhtml</to-view-id>
+ </navigation-case>
+
+ <!-- QUnit -->
+ <navigation-case>
+ <from-outcome>qunit/togglePanel</from-outcome>
+ <to-view-id>/qunit/togglePanel.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>qunit/togglePanelItem</from-outcome>
+ <to-view-id>/qunit/togglePanelItem.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Added: root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/examples/divPanel.xhtml
===================================================================
--- root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/examples/divPanel.xhtml (rev 0)
+++ root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/examples/divPanel.xhtml 2010-07-09 15:15:39 UTC (rev 17782)
@@ -0,0 +1,21 @@
+<!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:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/panels">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="title">Toggle Panel Example</ui:define>
+ <ui:define name="body_head">Toggle Panel Example</ui:define>
+
+ <ui:define name="body">
+ <pn:divPanel id="my_id" lang="en" onclick="#{togglePanelBean.name}" hi="Hello" >
+ other html
+ </pn:divPanel>
+ </ui:define>
+</ui:composition>
+</body>
+</html>
Modified: root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/index.xhtml
===================================================================
--- root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/index.xhtml 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/index.xhtml 2010-07-09 15:15:39 UTC (rev 17782)
@@ -11,10 +11,10 @@
<ui:define name="title">RichFaces Sample</ui:define>
<ui:define name="body">
- <pa:divPanel id="my_id" lang="en" onclick="#{richBean.name}">
- other html
- </pa:divPanel>
+ look at left
</ui:define>
+
+ <div style="top: auto;"></div>
</ui:composition>
</body>
</html>
Modified: root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/templates/template.xhtml
===================================================================
--- root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/templates/template.xhtml 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/archetypes/richfaces-archetype-simpleapp/trunk/src/main/resources/archetype-resources/src/main/webapp/templates/template.xhtml 2010-07-09 15:15:39 UTC (rev 17782)
@@ -5,11 +5,50 @@
xmlns:ui="http://java.sun.com/jsf/facelets" >
<h:head>
- <title><ui:define name="title">Application Title</ui:define></title>
+ <title>
+ <ui:define name="title">Application Title</ui:define>
+ </title>
+
<meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />
+
</h:head>
<h:body>
- <ui:insert name="body">Default content</ui:insert>
+ <ui:insert name="scripts" ></ui:insert>
+ <table width="100%">
+ <thead>
+ <tr>
+ <th width="20%" align="left">Content</th>
+ <th width="80%" align="left">
+ <ui:insert name="body_head">Example</ui:insert>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr valign="top">
+ <td>
+ <h:form id="nav">
+ <p>Examples</p>
+ <ul>
+ <li><h:commandLink value="divPanel" action="divPanel" /></li>
+ <li><h:commandLink value="togglePanel" action="togglePanel" /></li>
+ <li><h:commandLink value="togglePanel Ajax" action="togglePanel/ajax" /></li>
+ <li><h:commandLink value="togglePanel Client" action="togglePanel/client" /></li>
+ <li><h:commandLink value="togglePanel Server" action="togglePanel/server" /></li>
+ </ul>
+ <p>QUnit</p>
+ <ul>
+ <li><h:commandLink value="togglePanel" action="qunit/togglePanel" /></li>
+ <li><h:commandLink value="togglePanelItem" action="qunit/togglePanelItem" /></li>
+ </ul>
+ </h:form>
+ </td>
+ <td>
+ <ui:insert name="body">Default content</ui:insert>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
</h:body>
</html>
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -581,9 +581,11 @@
res.append(this.oncomplete);
res.append(';');
}
+
+ if (onComplete != null) {
+ res.append(onComplete).append(';');
+ }
- res.append(onComplete).append(';');
-
this.oncomplete = res.toString();
}
Modified: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -31,13 +31,14 @@
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.EditableValueHolder;
-//import javax.faces.component.MessageFactory;
import javax.faces.component.UIComponent;
import javax.faces.component.UpdateModelException;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.ExceptionQueuedEvent;
import javax.faces.event.ExceptionQueuedEventContext;
+import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PostValidateEvent;
import javax.faces.event.PreValidateEvent;
@@ -49,7 +50,6 @@
/**
* @author akolonitsky
* @version 1.0
- * @since -4712-01-01
*/
public abstract class AbstractTogglePanel extends AbstractDivPanel implements EditableValueHolder {
@@ -57,9 +57,6 @@
public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanel";
- public static final String UPDATE_MESSAGE_ID =
- "javax.faces.component.UIInput.UPDATE";
-
private String submittedSelectedItem = null;
private enum PropertyKeys {
@@ -227,9 +224,7 @@
popComponentFromEL(context);
}
- if (isImmediate()) {
- executeValidate(context);
- }
+ executeValidate(context);
}
/**
@@ -271,10 +266,6 @@
}
app.publishEvent(context, PostValidateEvent.class, this);
popComponentFromEL(context);
-
- if (!isImmediate()) {
- executeValidate(context);
- }
}
/**
@@ -342,50 +333,6 @@
super.decode(context);
}
- /**
- * <p><span class="changed_modified_2_0">Perform</span>
- * the following algorithm to update the model data
- * associated with this {@link javax.faces.component.UIInput}, if any, as appropriate.</p>
- * <ul>
- * <li>If the <code>valid</code> property of this component is
- * <code>false</code>, take no further action.</li>
- * <li>If the <code>localValueSet</code> property of this component is
- * <code>false</code>, take no further action.</li>
- * <li>If no {@link javax.el.ValueExpression} for <code>value</code> exists,
- * take no further action.</li>
- * <li>Call <code>setValue()</code> method of the {@link javax.el.ValueExpression}
- * to update the value that the {@link javax.el.ValueExpression} points at.</li>
- * <li>If the <code>setValue()</code> method returns successfully:
- * <ul>
- * <li>Clear the local value of this {@link javax.faces.component.UIInput}.</li>
- * <li>Set the <code>localValueSet</code> property of this
- * {@link javax.faces.component.UIInput} to false.</li>
- * </ul></li>
- * <li>If the <code>setValue()</code> method throws an Exception:
- * <ul>
- * <li class="changed_modified_2_0">Enqueue an error message. Create a
- * {@link javax.faces.application.FacesMessage} with the id {@link #UPDATE_MESSAGE_ID}. Create a
- * {@link javax.faces.component.UpdateModelException}, passing the <code>FacesMessage</code> and
- * the caught exception to the constructor. Create an
- * {@link javax.faces.event.ExceptionQueuedEventContext}, passing the <code>FacesContext</code>,
- * the <code>UpdateModelException</code>, this component instance, and
- * {@link javax.faces.event.PhaseId#UPDATE_MODEL_VALUES} to its constructor. Call
- * {@link FacesContext#getExceptionHandler} and then call
- * {@link javax.faces.context.ExceptionHandler#processEvent}, passing the
- * <code>ExceptionQueuedEventContext</code>.
- * </li>
- * <li>Set the <code>valid</code> property of this {@link javax.faces.component.UIInput}
- * to <code>false</code>.</li>
- * </ul></li>
- * The exception must not be re-thrown. This enables tree traversal
- * to continue for this lifecycle phase, as in all the other lifecycle
- * phases.
- * </ul>
- *
- * @param context {@link FacesContext} for the request we are processing
- * @throws NullPointerException if <code>context</code>
- * is <code>null</code>
- */
public void updateModel(FacesContext context) {
if (context == null) {
@@ -442,7 +389,7 @@
}
}
- /**
+ /**
* Executes validation logic.
*/
private void executeValidate(FacesContext context) {
@@ -478,8 +425,29 @@
}
}
-
+ public void queueEvent(FacesEvent event) {
+ if ((event instanceof SelectedItemChangeEvent) && (event.getComponent() == this)) {
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else if (isBypassUpdates()) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+ super.queueEvent(event);
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ if (event instanceof SelectedItemChangeEvent && isBypassUpdates()) {
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+ }
+
// -------------------------------------------------- Panel Items Managing
@Override
public String getFamily() {
@@ -587,9 +555,9 @@
public abstract Method getSwitchType();
- public abstract boolean getBypassUpdates();
+ public abstract boolean isBypassUpdates();
- public abstract boolean getLimitToList();
+ public abstract boolean isLimitToList();
public abstract Object getData();
Modified: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -59,7 +59,7 @@
getStateHelper().put(PropertyKeys.switchType, switchType);
}
- public boolean getBypassUpdates() {
+ public boolean isBypassUpdates() {
return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.bypassUpdates)));
}
@@ -67,7 +67,7 @@
getStateHelper().put(PropertyKeys.bypassUpdates, bypassUpdates);
}
- public boolean getLimitToList() {
+ public boolean isLimitToList() {
return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.limitToList)));
}
Modified: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -28,6 +28,7 @@
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehaviorContext;
/**
* @author akolonitsky
@@ -41,6 +42,7 @@
event,
targetItem,
forPanel,
+ disableDefault
}
public String getEvent() {
@@ -67,6 +69,18 @@
getStateHelper().put(PropertyKeys.forPanel, selector);
}
+ public void setDisableDefault(String disableDefault) {
+ getStateHelper().put(PropertyKeys.disableDefault, disableDefault);
+ }
+
+ public Boolean getDisableDefault() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.disableDefault, true)));
+ }
+
+ public String getPanelId(ClientBehaviorContext behaviorContext) throws FacesException {
+ return getPanel(behaviorContext.getComponent()).getClientId();
+ }
+
public AbstractTogglePanel getPanel(UIComponent comp) throws FacesException {
String target = this.getForPanel();
Modified: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -34,7 +34,7 @@
/**
* @author akolonitsky
- * @since -4712-01-01
+ *
*/
public class DivPanelRenderer extends RendererBase {
Modified: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit.html;
-import org.richfaces.component.AbstractTogglePanel;
import org.richfaces.component.behavior.ToggleControl;
import javax.faces.application.ResourceDependencies;
@@ -34,13 +33,13 @@
import javax.faces.render.RenderKitFactory;
/**
- * @author Anton Belevich
+ * @author akolonitsky
*
*/
@FacesBehaviorRenderer(
rendererType = "org.richfaces.component.behavior.ToggleControl",
renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT)
-@ResourceDependencies({
+@ResourceDependencies({ // TODO review
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js") })
@@ -50,7 +49,10 @@
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior) {
ToggleControl control = (ToggleControl) behavior;
- AbstractTogglePanel panel = control.getPanel(behaviorContext.getComponent());
- return "RichFaces.$('" + panel.getClientId() + "').switchToItem('" + control.getTargetItem() + "'); return false;";
+ StringBuilder builder = new StringBuilder();
+ builder.append("RichFaces.$('").append(control.getPanelId(behaviorContext)).append("').switchToItem('")
+ .append(control.getTargetItem()).append("'); return ").append(!control.getDisableDefault()).append(';');
+
+ return builder.toString();
}
}
\ No newline at end of file
Modified: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-07-09 15:15:39 UTC (rev 17782)
@@ -88,7 +88,7 @@
private void addOnCompleteParam(String newValue, AbstractTogglePanel panel) {
StringBuilder onComplete = new StringBuilder();
onComplete.append("RichFaces.$('").append(panel.getClientId()).append("').onCompleteHandler('")
- .append(panel.getSelectedItem()).append("','").append(newValue).append("'); return false;");
+ .append(panel.getSelectedItem()).append("','").append(newValue).append("');");
AjaxContext.getCurrentInstance().appendOncomplete(onComplete.toString());
}
Modified: root/ui-sandbox/panels/trunk/ui/src/main/resources/META-INF/resources/script/TogglePanel.js
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/resources/META-INF/resources/script/TogglePanel.js 2010-07-09 14:24:26 UTC (rev 17781)
+++ root/ui-sandbox/panels/trunk/ui/src/main/resources/META-INF/resources/script/TogglePanel.js 2010-07-09 15:15:39 UTC (rev 17782)
@@ -22,7 +22,6 @@
(function ($, rf) {
- /***************************** Stuff ******************************************************************************/
rf.ui = rf.ui || {};
/***************************** Constructor definition *************************************************************/
@@ -37,7 +36,7 @@
* @param {String} componentId - component id
* @param {Hash} options - params
* */
- rf.ui.TogglePanel = function(componentId, options) {
+ rf.ui.TogglePanel = function (componentId, options) {
// call constructor of parent class
$super.constructor.call(this, componentId);
$p.attachToDom.call(this, componentId);
@@ -55,8 +54,121 @@
var $super = rf.ui.TogglePanel.$super;
- /***************************** Private Static Methods *************************************************************/
+ /***************************** Private Static Area ****************************************************************/
+
+ /* SIMPLE INNER CLASS for handle switch operation*/
+ function SwitchItems (comp) {
+ this.comp = comp;
+ }
+
+ SwitchItems.prototype = {
+
+ /**
+ * @param {TogglePanel} comp
+ * @param {TogglePanelItem} oldPanel
+ * @param {TogglePanelItem} newPanel
+ *
+ * @return {void}
+ * */
+ exec : function (oldPanel, newPanel) {
+ if (this.comp.switchMode == "server") {
+ return this.execServer(oldPanel, newPanel);
+ } else if (this.comp.switchMode == "ajax") {
+ return this.execAjax(oldPanel, newPanel);
+ } else if (this.comp.switchMode == "client") {
+ return this.execClient(oldPanel, newPanel);
+ } else {
+ rf.log.error("SwitchItems.exec : unknown switchMode (" + this.comp.switchMode + ")");
+ }
+ },
+
+ /**
+ * @protected
+ * @param {TogglePanelItem} oldPanel
+ * @param {TogglePanelItem} newPanel
+ *
+ * @return {Boolean} false
+ * */
+ execServer : function (oldPanel, newPanel) {
+ var continueProcess = oldPanel.leave();
+ if (!continueProcess) {
+ return false;
+ }
+
+ this.setSelectedItem(newPanel.getName());
+
+ rf.submitForm(this.getParentForm(), null, {});
+
+ return false;
+ },
+
+ /**
+ * @protected
+ * @param {TogglePanelItem} oldPanel
+ * @param {TogglePanelItem} newPanel
+ *
+ * @return {Boolean} false
+ * */
+ execAjax : function (oldPanel, newPanel) {
+ var options = $.extend({}, this.comp.options["ajax"], {}/*this.getParameters(newPanel)*/);
+
+ this.setSelectedItem(newPanel.getName());
+ rf.ajax(this.comp.id, null, options);
+ this.setSelectedItem(oldPanel.getName());
+
+ return false;
+ },
+
+ /**
+ * @protected
+ * @param {TogglePanelItem} oldPanel
+ * @param {TogglePanelItem} newPanel
+ *
+ * @return {undefined}
+ * - false - if process has been terminated
+ * - true - in other cases
+ * */
+ execClient : function (oldPanel, newPanel) {
+ var continueProcess = oldPanel.leave();
+ if (!continueProcess) {
+ return false;
+ }
+
+ this.setSelectedItem(newPanel.getName());
+
+ newPanel.enter();
+ fireItemChange(this.comp, oldPanel, newPanel);
+
+ return true;
+ },
+
+ /**
+ * @private
+ * */
+ getParentForm : function () {
+ return $(RichFaces.getDomElement(this.comp.id)).parent('form');
+ },
+
+ /**
+ * @private
+ * */
+ setSelectedItem : function (name) {
+ rf.getDomElement(this.getValueInputId()).value = name;
+ this.comp.selectedItem = name;
+ },
+
+ /**
+ * @private
+ * */
+ getValueInputId: function () {
+ return this.comp.id + "-value"
+ }
+
+ };
+
+ /********************* Events *************************/
+
/**
* Fire Concealable Event
* */
@@ -76,16 +188,54 @@
});
}
+ /********************* Methods *************************/
- function getEventHandler() {}
+ function getItemIndex (items, itemName) {
+ for (var i = 0; i < items.length; i++) {
+ if (items[i].getName() === itemName) {
+ return i;
+ }
+ }
+ rf.log.info("TogglePanel.getItemIndex: item with name '" + itemName + "' not found");
+ return -1;
+ }
+
+ /**
+ * @param {TogglePanelItem[]} items
+ * @param {Number} index - array index
+ *
+ * @return {TogglePanelItem}
+ * null - if item not found
+ * */
+ function getItem (items, index) {
+ if (index >= 0 && index < items.length) {
+ return items[index]
+ }
+
+ return null;
+ }
+
+ function getItemByName (items, name) {
+ return getItem(items, getItemIndex(items, name));
+ }
+
+ function getItemName (items, index) {
+ var item = getItem(items, index);
+ if (item == null) {
+ return null;
+ }
+
+ return item.getName();
+ }
+
+
/***************************** Public Methods ********************************************************************/
$.extend(rf.ui.TogglePanel.prototype, (function () {
return {
// class name
name:"TogglePanel",
- // public api
/**
* @methodOf
* @name TogglePanel#getSelectItem
@@ -96,10 +246,6 @@
return this.selectedItem;
},
- getValueInputId: function () {
- return this.id + "-value"
- },
-
/**
* @methodOf
* @name TogglePanel#switchToItem
@@ -108,125 +254,32 @@
* @return {Boolean} - always false
*/
switchToItem: function (name) {
- var oldPanel = this.getItemByName(this.getSelectItem());
- var newPanel = name ? this.getItemByName(name)
- : this.getItem(this.nextItem());
+ var oldPanel = getItemByName(this.items, this.getSelectItem());
+ var newPanel = getItemByName(this.items, name || this.nextItem());
var continueProcess = fireBeforeItemChange(this, oldPanel, newPanel);
if (!continueProcess) {
return false
}
- this.switchItems(oldPanel, newPanel);
+ new SwitchItems(this).exec(oldPanel, newPanel);
return false;
},
- setSelectedItem : function (name) {
- rf.getDomElement(this.getValueInputId()).value = name;
- this.selectedItem = name;
- },
-
/**
- * @param {TogglePanelItem} oldPanel
- * @param {TogglePanelItem} newPanel
- *
- * @return {void}
- * */
- switchItems : function (oldPanel, newPanel) {
- if (this.switchMode == "server") {
- return this.switchItems_server(oldPanel, newPanel);
- } else if (this.switchMode == "ajax") {
- return this.switchItems_ajax(oldPanel, newPanel);
- } else if (this.switchMode == "client") {
- return this.switchItems_client(oldPanel, newPanel);
- } else {
- rf.log.error("TogglePanel.switchItems : unknown switchMode (" + this.switchMode + ")");
- }
- },
-
- /**
- * @param {TogglePanelItem} oldPanel
- * @param {TogglePanelItem} newPanel
- *
- * @return {void}
- * */
- switchItems_server : function (oldPanel, newPanel) {
- var continueProcess = oldPanel.leave();
- if (!continueProcess) {
- return false;
- }
-
- this.setSelectedItem(newPanel.getName());
-
- rf.submitForm(this.getParentForm(), null, this.getParameters(newPanel));
-
- return false;
- },
-
- getParentForm : function () {
- return $(RichFaces.getDomElement(this.id)).parent('form');
- },
-
- getParameters : function (newPanel) {
- return {"parameters" : this.getServerParams(newPanel)};
- },
-
- getServerParams : function (newPanel) {
- var params = {};
-// params[this.getValueInputId()] = newPanel.getName();
-
- return params;
- },
-
- /**
- * @param {TogglePanelItem} oldPanel
- * @param {TogglePanelItem} newPanel
- *
- * @return {undefined}
- * */
- switchItems_ajax : function (oldPanel, newPanel) {
- var options = $.extend({}, this.options["ajax"], {}/*this.getParameters(newPanel)*/);
-
- this.setSelectedItem(newPanel.getName());
- rf.ajax(this.id, null, options);
- this.setSelectedItem(oldPanel.getName());
-
- return false;
- },
-
- /**
* please, remove this method when client side ajax events will be added
*
* */
onCompleteHandler : function (oldItemName, newItemName) {
- var oldItem = this.getItemByName(oldItemName);
- var newItem = this.getItemByName(newItemName);
+ var oldItem = getItemByName(this.items, oldItemName);
+ var newItem = getItemByName(this.items, newItemName);
- this.switchItems_client(oldItem, newItem);
+ // Don't do like this and remove it ASAP
+ new SwitchItems(this).execClient(oldItem, newItem);
},
/**
- * @param {TogglePanelItem} oldPanel
- * @param {TogglePanelItem} newPanel
- *
- * @return {undefined} false - if process has been terminated
- * */
- switchItems_client : function (oldPanel, newPanel) {
- var continueProcess = oldPanel.leave();
- if (!continueProcess) {
- return false;
- }
-
- this.setSelectedItem(newPanel.getName());
-
- newPanel.enter();
- fireItemChange(this, oldPanel, newPanel);
- },
-
-
-
- /**
* @methodOf
* @name TogglePanel#getItems
*
@@ -259,7 +312,12 @@
* @return {String} name of next panel item
*/
nextItem: function (itemName) {
- return this.getItemName(this.getItemIndex(itemName) + 1);
+ var itemIndex = getItemIndex(this.items, itemName || this.selectedItem);
+ if (itemIndex == -1) {
+ return null;
+ }
+
+ return getItemName(this.items, itemIndex + 1);
},
/**
@@ -269,7 +327,7 @@
* @return {String} name of first panel item
*/
firstItem: function () {
- return this.getItemName(0);
+ return getItemName(this.items, 0);
},
/**
@@ -279,93 +337,26 @@
* @return {String} name of last panel item
*/
lastItem: function () {
- return this.getItemName(this.items.length - 1);
+ return getItemName(this.items, this.items.length - 1);
},
/**
* @methodOf
* @name TogglePanel#prevItem
*
- * @param {String} [itemName = selectedItem]
+ * @param {String} itemName
* @return {String} name of prev panel item
+ * null if it is first item
*/
prevItem: function (itemName) {
- var itemIndex = this.getItemIndex(itemName);
- if (itemIndex == -1) {
- return this.firstItem();
+ var itemIndex = getItemIndex(this.items, itemName || this.selectedItem);
+ if (itemIndex < 1) {
+ return null;
}
- return this.getItemName((this.items.length + itemIndex - 1) % this.items.length);
+
+ return getItemName(this.items, itemIndex - 1);
},
-
-
- // event handlers
- /**
- * @methodOf
- * @name TogglePanel#oncomplete
- */
- oncomplete: function () {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name TogglePanel#onbeforedomupdate
- */
- onbeforedomupdate: function () {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name TogglePanel#onitemchange
- */
- onitemchange: function () {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name TogglePanel#onitemchanged
- */
- onitemchanged: function () {
- // TODO implement
- },
-
- // private methods
- getItemName : function (index) {
- return this.getItem(index).getName();
- },
-
- getItemByName : function (name) {
- return this.getItem(this.getItemIndex(name));
- },
-
- getItemIndex : function (itemName) {
- var name = itemName || this.selectedItem;
- for (var i = 0; i < this.items.length; i++) {
- if (this.items[i].getName() === name) {
- return i;
- }
- }
-
- rf.log.warn("TogglePanel.getItemIndex: item with name '" + itemName + "' not found");
- return -1;
- },
-
- /**
- * @param {Number} index - array index
- *
- * @return {TogglePanelItem}
- * */
- getItem : function (index) {
- if (index >= this.items.length || index < 0) {
- return this.items[0];
- } else {
- return this.items[index]
- }
- },
-
// class stuff
destroy: function () {
// rf.Event.unbindById(this.options.buttonId, "."+this.namespace);
14 years, 6 months
JBoss Rich Faces SVN: r17780 - root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-07-09 10:10:13 -0400 (Fri, 09 Jul 2010)
New Revision: 17780
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/SelectBase.js
Log:
https://jira.jboss.org/browse/RF-8875
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js 2010-07-09 13:35:41 UTC (rev 17779)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js 2010-07-09 14:10:13 UTC (rev 17780)
@@ -10,6 +10,10 @@
var getItems = function (key) {
var newCache = [];
+
+ if (key.length < this.key.length) {
+ return newCache;
+ }
if (this.cache[key]) {
newCache = this.cache[key];
@@ -34,10 +38,15 @@
return newCache;
};
+
+ var isCached = function (key) {
+ return this.cache[key];
+ }
$.extend(rf.utils.Cache.prototype, (function () {
return {
- getItems: getItems
+ getItems: getItems,
+ isCached: isCached
};
})());
@@ -55,8 +64,9 @@
$p.attachToDom.call(this, componentId);
this.componentId = componentId;
this.options = $.extend(this.options, defaultOptions, options);
- //this.currentValue = rf.getDomElement(this.fieldId).value;
+ this.inputValue = rf.getDomElement(this.fieldId).value;
this.index = -1;
+ this.isFirstAjax = true;
bindEventHandlers.call(this);
updateItemsList.call(this, "");
};
@@ -72,14 +82,25 @@
var defaultOptions = {
selectedItemClass:'cb_select',
autoFill:true,
- minChars:0,
- selectFirst:false
+ minChars:1,
+ selectFirst:true,
+ ajaxMode:true
};
var ID = {
SELECT:'List',
ITEMS:'Items'
};
+
+ var REGEXP_TRIM = /^[\n\s]*(.*)[\n\s]*$/;
+
+ var getData = function (nodeList) {
+ var data = [];
+ nodeList.each(function () {;
+ data.push($(this).text().replace(REGEXP_TRIM, "$1"));
+ });
+ return data;
+ }
var bindEventHandlers = function () {
rf.Event.bind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode, "mouseover"+this.namespace, onMouseOver, this);
@@ -105,14 +126,6 @@
});
};
- var getData = function (nodeList) {
- var data = [];
- nodeList.each(function () {
- data.push($(this).text());
- });
- return data;
- };
-
var scrollToSelectedItem = function() {
var offset = 0;
this.items.slice(0, this.index).each(function() {
@@ -132,19 +145,34 @@
var autoFill = function (inputValue, value) {
if( this.options.autoFill) {
var field = rf.getDomElement(this.fieldId);
+ var start = rf.Selection.getStart(field);
field.value = inputValue + value.substring(inputValue.length);
- rf.Selection.set(field, inputValue.length, field.value.length);
+ rf.Selection.set(field, start, field.value.length);
}
};
var callAjax = function(event) {
+
+ var _this = this;
+ var ajaxSuccess = function () {
+ updateItemsList.call(_this, _this.inputValue);
+ if (_this.options.selectFirst) {
+ _this.selectItem(0);
+ }
+ }
+
+ var ajaxError = function () {
+ alert("error");
+ }
+
+ this.isFirstAjax = false;
//caution: JSF submits inputs with empty names causing "WARNING: Parameters: Invalid chunk ignored." in Tomcat log
var params = {};
params[this.componentId + ".ajax"] = "1";
- rf.ajax(this.componentId, event, {parameters: params});
+ rf.ajax(this.componentId, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});
};
-
+
// Add new properties and methods
$.extend(rf.ui.ComboBox.prototype, (function () {
return {
@@ -189,7 +217,7 @@
item.addClass(this.options.selectedItemClass);
scrollToSelectedItem.call(this);
- !noAutoFill && autoFill.call(this, this.newValue, item.text());
+ !noAutoFill && autoFill.call(this, this.inputValue, getData(item)[0]);
},
selectPrevItem: function () {
@@ -205,19 +233,33 @@
},
onBeforeShow: function (event) {
- callAjax.call(this, event);
},
changeValue: function (event, value) {
+ this.selectItem();
+
+ if (typeof value == "undefined") {
+ // called from show method, not actually value changed
+ if (this.items.length==0 && this.inputValue.length>=this.options.minChars && this.isFirstAjax) {
+ this.options.ajaxMode && callAjax.call(this, event);
+ }
+ return;
+ }
+
// TODO: ajax call here if needed
-
- this.selectItem();
+ if (( value.indexOf(this.cache.key)!=0 || this.inputValue.length==0) &&
+ value.length>=this.options.minChars) {
+ this.inputValue = value;
+ this.options.ajaxMode && callAjax.call(this, event);
+ return;
+ }
+
var newItems = this.cache.getItems(value);
this.items = $(newItems);
//TODO: works only with simple markup, not with <tr>
$(rf.getDomElement(this.componentId+ID.ITEMS)).empty().append(newItems);
this.index = -1;
- this.newValue = value;
+ this.inputValue = value;
if (this.options.selectFirst) {
this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
}
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/SelectBase.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/SelectBase.js 2010-07-09 13:35:41 UTC (rev 17779)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/SelectBase.js 2010-07-09 14:10:13 UTC (rev 17780)
@@ -108,7 +108,7 @@
if (this.isVisible) {
this.hide(event);
} else {
- this.show(event);
+ onShow.call(this, event);
//rf.getDomElement(this.fieldId).focus();
}
};
@@ -135,17 +135,21 @@
var onChange = function (event) {
var value = this.getInputValue();
var flag = value != this.currentValue;
+ //TODO: is it needed to chesk keys?
if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
if (flag) {
this.changeValue(event, value);
this.currentValue = value;
- if (!this.isVisible) {
- this.show();
- }
+ onShow.call(this, event, true);
}
}
}
+ var onShow = function (event, noChangeValue) {
+ !noChangeValue && this.changeValue(event);
+ this.show(event);
+ }
+
/*var checkOnBlur = function (event) {
var e = $(rf.getDomElement(this.options.buttonId));
@@ -165,7 +169,7 @@
if (this.isVisible) {
this.selectNextItem();
} else {
- this.show();
+ onShow.call(this, event);
}
break;
case rf.KEYS.PAGEUP:
@@ -209,22 +213,26 @@
return {
name:"SelectBase",
show: function (event) {
- if (this.onBeforeShow(event)!=false) {
- $(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
- this.isVisible = true;
- this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
- if (this.onShow) {
- this.onShow(event);
- }
+ if (!this.isVisible) {
+ if (this.onBeforeShow(event)!=false) {
+ $(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
+ this.isVisible = true;
+ this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
+ if (this.onShow) {
+ this.onShow(event);
+ }
+ }
}
},
hide: function (event) {
- rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- $(rf.getDomElement(this.selectId)).hide();
- this.isVisible = false;
- if (this.onHide) {
- this.onHide(event);
- }
+ if (this.isVisible) {
+ rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ $(rf.getDomElement(this.selectId)).hide();
+ this.isVisible = false;
+ if (this.onHide) {
+ this.onHide(event);
+ }
+ }
},
destroy: function () {
//TODO: add all unbind
14 years, 6 months
JBoss Rich Faces SVN: r17779 - root/tests.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-09 09:35:41 -0400 (Fri, 09 Jul 2010)
New Revision: 17779
Removed:
root/tests/branches/
root/tests/tags/
root/tests/trunk/
Log:
removing t/b/t structure, will be replaced by particular projects
14 years, 6 months
JBoss Rich Faces SVN: r17778 - in root/docs/trunk: Developer_Guide and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-07-09 01:28:38 -0400 (Fri, 09 Jul 2010)
New Revision: 17778
Modified:
root/docs/trunk/Component_Reference/pom.xml
root/docs/trunk/Developer_Guide/pom.xml
root/docs/trunk/Migration_Guide/pom.xml
Log:
Docs poms now point to docs-parent
Modified: root/docs/trunk/Component_Reference/pom.xml
===================================================================
--- root/docs/trunk/Component_Reference/pom.xml 2010-07-09 04:17:25 UTC (rev 17777)
+++ root/docs/trunk/Component_Reference/pom.xml 2010-07-09 05:28:38 UTC (rev 17778)
@@ -10,9 +10,9 @@
<url>http://www.jboss.org/richfaces</url>
<parent>
- <groupId>org.richfaces</groupId>
- <artifactId>richfaces-parent</artifactId>
- <version>8-SNAPSHOT</version>
+ <groupId>org.richfaces.docs</groupId>
+ <artifactId>docs-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<properties>
Modified: root/docs/trunk/Developer_Guide/pom.xml
===================================================================
--- root/docs/trunk/Developer_Guide/pom.xml 2010-07-09 04:17:25 UTC (rev 17777)
+++ root/docs/trunk/Developer_Guide/pom.xml 2010-07-09 05:28:38 UTC (rev 17778)
@@ -10,9 +10,9 @@
<url>http://www.jboss.org/richfaces</url>
<parent>
- <groupId>org.richfaces</groupId>
- <artifactId>richfaces-parent</artifactId>
- <version>8-SNAPSHOT</version>
+ <groupId>org.richfaces.docs</groupId>
+ <artifactId>docs-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<properties>
Modified: root/docs/trunk/Migration_Guide/pom.xml
===================================================================
--- root/docs/trunk/Migration_Guide/pom.xml 2010-07-09 04:17:25 UTC (rev 17777)
+++ root/docs/trunk/Migration_Guide/pom.xml 2010-07-09 05:28:38 UTC (rev 17778)
@@ -10,9 +10,9 @@
<url>http://www.jboss.org/richfaces</url>
<parent>
- <groupId>org.richfaces</groupId>
- <artifactId>richfaces-parent</artifactId>
- <version>8-SNAPSHOT</version>
+ <groupId>org.richfaces.docs</groupId>
+ <artifactId>docs-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<properties>
14 years, 6 months
JBoss Rich Faces SVN: r17777 - in root: docs/trunk and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-07-09 00:17:25 -0400 (Fri, 09 Jul 2010)
New Revision: 17777
Added:
root/docs/trunk/parent/
root/docs/trunk/parent/pom.xml
root/docs/trunk/pom.xml
Modified:
root/build/parent/trunk/pom.xml
Log:
Added docs-parent pom
Modified: root/build/parent/trunk/pom.xml
===================================================================
--- root/build/parent/trunk/pom.xml 2010-07-09 00:18:37 UTC (rev 17776)
+++ root/build/parent/trunk/pom.xml 2010-07-09 04:17:25 UTC (rev 17777)
@@ -256,6 +256,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.2</version>
</plugin>
+ <!--
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
@@ -309,6 +310,7 @@
</options>
</configuration>
</plugin>
+ -->
</plugins>
</pluginManagement>
<plugins>
Added: root/docs/trunk/parent/pom.xml
===================================================================
--- root/docs/trunk/parent/pom.xml (rev 0)
+++ root/docs/trunk/parent/pom.xml 2010-07-09 04:17:25 UTC (rev 17777)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat, Inc.
+ and individual contributors by the @authors tag. See the copyright.txt
+ in the distribution for a full listing of individual contributors. This
+ is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software 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
+ software; if not, write to the Free Software Foundation, Inc., 51
+ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ site: http://www.fsf.org.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-parent</artifactId>
+ <version>8-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.docs</groupId>
+ <artifactId>docs-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>Richfaces Docs: Parent</name>
+ <packaging>pom</packaging>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.2.3</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDirectory>${project.basedir}/src/main/docbook</sourceDirectory>
+ <sourceDocumentName>${docname}.xml</sourceDocumentName>
+ <masterTranslation>en-US</masterTranslation>
+ <imageResource>
+ <directory>${project.basedir}/src/main/docbook/en-US</directory>
+ <includes>
+ <include>images/*.png</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>${pdf.name}</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ <localeSeparator>-</localeSeparator>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <!--
+ <profiles>
+ <!- mvn compile ->
+ <profile>
+ <id>all</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>${docname}.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!- mvn compile -Phtml ->
+ <profile>
+ <id>html</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!- mvn compile -Phtml-single ->
+ <profile>
+ <id>html-single</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!- mvn compile -Ppdf ->
+ <profile>
+ <id>pdf</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>${docname}.pdf</finalName>
+ </format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ -->
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/docs/trunk/parent</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root/docs/trunk/parent</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/</url>
+ </scm>
+</project>
Added: root/docs/trunk/pom.xml
===================================================================
--- root/docs/trunk/pom.xml (rev 0)
+++ root/docs/trunk/pom.xml 2010-07-09 04:17:25 UTC (rev 17777)
@@ -0,0 +1,29 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-parent</artifactId>
+ <version>8-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.docs</groupId>
+ <artifactId>docs-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>RichFaces Document Aggregator</name>
+
+ <modules>
+ <module>parent</module>
+ <module>Component_Reference</module>
+ <module>Developer_Guide</module>
+ <module>Migration_Guide</module>
+ </modules>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/docs/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root/docs/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/</url>
+ </scm>
+</project>
+
14 years, 6 months
JBoss Rich Faces SVN: r17776 - in root: cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-08 20:18:37 -0400 (Thu, 08 Jul 2010)
New Revision: 17776
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ContextVariables.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/QNameTemplateModel.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementBase.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/define-object.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/for-each.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-text.ftl
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatementTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementTest1.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTestBase.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeTest.java
root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
Log:
https://jira.jboss.org/browse/RF-8306
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -66,7 +66,7 @@
}
@Inject(optional=true)
- protected void setSharedVariables(Map<String,Object> variables) {
+ public void setSharedVariables(@ContextVariables Map<String,Object> variables) {
// template method for subclasses.
for (Map.Entry<String,Object> entry : variables.entrySet()) {
try {
Added: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ContextVariables.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ContextVariables.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ContextVariables.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -0,0 +1,48 @@
+/*
+ * $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.generate.freemarker;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * <p class="changed_added_4_0">
+ * Marks {@link org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer} instance that is targeted to work with JSF
+ * library model
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@Retention(RUNTIME)
+@Target({ FIELD, PARAMETER, METHOD })
+@BindingAnnotation
+public @interface ContextVariables {
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ContextVariables.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -10,6 +10,8 @@
TypedTemplateStatement parse(String expression, Variables variables, ELType expectedType) throws ParsingException;
+ TypedTemplateStatement parse(String expression, Variables variables, String expectedType) throws ParsingException;
+
ELType getType(Class<?> targetClass);
ELType getType(String classExpression);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -1,5 +1,7 @@
package org.richfaces.cdk.templatecompiler;
+import javax.xml.namespace.QName;
+
import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
import org.richfaces.cdk.templatecompiler.el.types.ELType;
@@ -24,6 +26,8 @@
templateModel = new MethodBodyTemplateModel((JavaStatement) obj, this);
} else if (obj instanceof ELType){
templateModel = new ELTypeTemplateModel((ELType)obj, this);
+ } else if (obj instanceof QName){
+ templateModel = new QNameTemplateModel((QName)obj, this);
} else {
templateModel = super.wrap(obj);
}
Added: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/QNameTemplateModel.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/QNameTemplateModel.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/QNameTemplateModel.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -0,0 +1,57 @@
+/*
+ * $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.templatecompiler;
+
+import javax.xml.namespace.QName;
+
+import org.richfaces.cdk.templatecompiler.model.Template;
+
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.beans.StringModel;
+import freemarker.template.TemplateModel;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class QNameTemplateModel extends StringModel implements TemplateModel {
+
+ private final QName qName;
+
+ public QNameTemplateModel(QName obj, BeansWrapper wrapper) {
+ super(obj, wrapper);
+ this.qName = obj;
+ }
+
+ @Override
+ public String getAsString() {
+ StringBuilder nameBuilder = new StringBuilder();
+ if(!Template.isDefaultNamespace(qName)){
+ nameBuilder.append(qName.getPrefix()).append(':');
+ }
+ return nameBuilder.append(qName.getLocalPart()).toString();
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/QNameTemplateModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -27,7 +27,6 @@
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.EnumSet;
-import java.util.Map;
import java.util.Set;
import javax.faces.component.UIComponent;
@@ -83,7 +82,6 @@
import org.richfaces.cdk.util.Strings;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
/**
@@ -134,9 +132,6 @@
*/
private static final String PASS_THROUGH_ATTRIBUTES_FIELD_NAME = "PASS_THROUGH_ATTRIBUTES";
- private static final Set<String> DEFAULT_NAMESPACES = ImmutableSet.of(Template.XHTML_EL_NAMESPACE,
- Template.XHTML_NAMESPACE);
-
private final Logger log;
private final Injector injector;
@@ -200,19 +195,6 @@
}
}
- private boolean isDefaultNamespace(String namespaceURI) {
- // TODO - another namespaces
- if (Strings.isEmpty(namespaceURI)) {
- return true;
- }
-
- if (DEFAULT_NAMESPACES.contains(namespaceURI)) {
- return true;
- }
-
- return false;
- }
-
private ELType getType(Type type) {
return typesFactory.getType(type);
}
@@ -281,7 +263,7 @@
protected <T extends StatementsContainer> T pushStatement(Class<T> container) {
T statement = createStatement(container);
- pushStatement(container);
+ pushStatement(statement);
return statement;
}
@@ -344,69 +326,14 @@
@Override
public void startElement(AnyElement anyElement) throws CdkException {
QName elementName = anyElement.getName();
- Map<QName, Object> elementAttributes = anyElement.getAttributes();
-
- if (!isDefaultNamespace(elementName.getNamespaceURI())) {
- // TODO: add support
- return;
+ if (Template.isDirectiveNamespace(elementName)) {
+ log.error("Unknown directive element "+elementName);
+ } else {
+ StartElementStatement startElementStatement = addStatement(StartElementStatement.class);
+ startElementStatement.setElementName(elementName);
+ AttributesStatement attributesStatement = addStatement(AttributesStatement.class);
+ attributesStatement.processAttributes(anyElement, attributes);
}
- StartElementStatement startElementStatement = addStatement(StartElementStatement.class);
- startElementStatement.setElementName(elementName.getLocalPart());
- AttributesStatement attributesStatement = addStatement(AttributesStatement.class);
- attributesStatement.processAttributes(anyElement, attributes);
- // Set<String> writtenAttributes = new HashSet<String>();
- // boolean shouldEncodePassThrough = false;
- // String[] passThroughExclusions = null;
- //
- // Map<QName, Object> sortedElementAttributes = new TreeMap<QName, Object>(QNAME_COMPARATOR);
- // sortedElementAttributes.putAll(elementAttributes);
- //
- // for (Map.Entry<QName, Object> attribute : sortedElementAttributes.entrySet()) {
- // QName attributeName = attribute.getKey();
- // Object attributeValue = attribute.getValue();
- //
- // if (!isDefaultNamespace(attributeName.getNamespaceURI())) {
- // // TODO: add support
- // if (Template.CDK_NAMESPACE.equals(attributeName.getNamespaceURI())
- // && "passThroughWithExclusions".equals(attributeName.getLocalPart())) {
- //
- // shouldEncodePassThrough = true;
- // if (attributeValue != null) {
- // passThroughExclusions = attributeValue.toString().split("\\s+");
- // }
- // }
- // } else {
- // String attributeLocalName = attributeName.getLocalPart();
- // if (writtenAttributes.add(attributeLocalName)) {
- // addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(
- // attributeValue.toString(), Object.class)));
- // }
- // }
- // }
- //
- // if (shouldEncodePassThrough) {
- // Element attributesElement = attributesSchema.getElements().get(elementName.getLocalPart());
- // if (attributesElement != null) {
- // // make a copy of original set
- // TreeMap<String, Attribute> actualAttributesMap =
- // new TreeMap<String, Attribute>(attributesElement.getAttributes());
- //
- // if (passThroughExclusions != null) {
- // for (String passThroughExclusion : passThroughExclusions) {
- // actualAttributesMap.remove(passThroughExclusion);
- // }
- // }
- //
- // for (String writtenAttribute : writtenAttributes) {
- // actualAttributesMap.remove(writtenAttribute);
- // }
- //
- // if (!actualAttributesMap.isEmpty()) {
- // String passThroughFieldName = createPassThroughField(actualAttributesMap);
- // addStatement(new WriteAttributesSetStatement(passThroughFieldName));
- // }
- // }
- // }
}
/*
@@ -420,7 +347,7 @@
public void endElement(AnyElement anyElement) throws CdkException {
QName elementName = anyElement.getName();
EndElementStatement endElementStatement = addStatement(EndElementStatement.class);
- endElementStatement.setElementName(elementName.getLocalPart());
+ endElementStatement.setElementName(elementName);
}
/*
@@ -433,7 +360,7 @@
public void visitElement(String text) throws CdkException {
if (text != null) {
String trimmedText = text.trim();
- if (!Strings.isEmpty(trimmedText)) {
+ if (trimmedText.length()>0) {
WriteTextStatement statement = addStatement(WriteTextStatement.class);
statement.setExpression(trimmedText);
}
@@ -541,7 +468,7 @@
@Override
public void startElement(CdkOtherwiseElement cdkOtherwiseElement) {
- IfStatement ifStatement = pushStatement(IfStatement.class);
+ pushStatement(StatementsContainer.class);
}
/*
@@ -566,45 +493,13 @@
@Override
public void visitElement(CdkObjectElement cdkObjectElement) {
String name = cdkObjectElement.getName();
-
String value = cdkObjectElement.getValue();
if (Strings.isEmpty(value)) {
value = cdkObjectElement.getBodyValue();
}
-
- String typeString = cdkObjectElement.getType();
- String typeArgumentsString = cdkObjectElement.getTypeArguments();
- if (!Strings.isEmpty(typeArgumentsString)) {
- // TODO: generic arrays
- typeString += "<" + typeArgumentsString + ">";
- }
-
- // ELType type = null;
- // if (!Strings.isEmpty(typeString)) {
- // type = TypesFactoryImpl.getType(typeString, typesFactory);
- // }
- //
- // if (!Strings.isEmpty(value)) {
- // Class<?> valueType;
- // if (type != null) {
- // valueType = type.getRawType();
- // } else {
- // valueType = Object.class;
- // }
- //
- // value = compileEl(value, valueType);
- // if (type == null) {
- // type = lastCompiledExpressionType;
- // }
- // }
- //
- // if (type == null) {
- // type = TypesFactory.OBJECT_TYPE;
- // }
- //
- // defineObject(type, name, value);
+ String type = cdkObjectElement.getType();
DefineObjectStatement statement = addStatement(DefineObjectStatement.class);
- // TODO - set parameters.
+ statement.setObject(name,type,value);
}
/*
@@ -625,7 +520,7 @@
// collectionElementClass = Object.class;
// }
ForEachStatement forEachStatement = pushStatement(ForEachStatement.class);
- forEachStatement.setItemsExpression(items);
+ forEachStatement.setItemsExpression(items,cdkForEachElement.getVar());
// currentStatement.setVariable(cdkForEachElement.getVar(), lastCompiledExpressionType.getContainerType());
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.attributes.Schema;
import org.richfaces.cdk.generate.freemarker.CdkConfiguration;
+import org.richfaces.cdk.generate.freemarker.ContextVariables;
import org.richfaces.cdk.generate.freemarker.DefaultImports;
import org.richfaces.cdk.generate.freemarker.FreeMakerUtils;
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
@@ -37,10 +38,12 @@
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.templatecompiler.statements.HelperMethod;
import org.richfaces.cdk.templatecompiler.statements.HelperMethodFactory;
import org.richfaces.cdk.templatecompiler.statements.HelperMethodFactoryImpl;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
import com.google.inject.AbstractModule;
import com.google.inject.PrivateBinder;
import com.google.inject.Singleton;
@@ -83,9 +86,17 @@
privateBinder.bind(FreeMakerUtils.class);
privateBinder.bind(ObjectWrapper.class).to(JavaClassModelWrapper.class);
privateBinder.bind(new TypeLiteral<Map<String, Object>>() {
- }).toInstance(RendererClassVisitor.ENCODE_METHOD_VARIABLES);
+ }).annotatedWith(ContextVariables.class).toInstance(buildVariables());
privateBinder.bind(String.class).annotatedWith(TemplatesFolder.class).toInstance("/META-INF/templates/java");
privateBinder.bind(new TypeLiteral<Map<String,String>>(){}).annotatedWith(DefaultImports.class).toInstance(ImmutableMap.of("util","util.ftl"));
}
+ public static Map<String, Object> buildVariables() {
+ Map<String, Object> variables = Maps.newHashMap(RendererClassVisitor.ENCODE_METHOD_VARIABLES);
+ for (Map.Entry<HelperMethod, String> entry : HelperMethod.METHOD_NAMES.entrySet()) {
+ variables.put(entry.getKey().toString(),entry.getValue());
+ }
+ return variables;
+ }
+
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -38,6 +38,12 @@
return visitor;
}
+ @Override
+ public TypedTemplateStatement parse(String expression, Variables variables, String expectedType)
+ throws ParsingException {
+ return parse(expression,variables,typesFactory.getType(expectedType));
+ }
+
/* (non-Javadoc)
* @see org.richfaces.cdk.templatecompiler.ELParser#getType(java.lang.Class)
*/
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -43,7 +43,7 @@
public static final String CDK_NAMESPACE = "http://richfaces.org/cdk/core";
- public static final String CDK_PASS_THROUGH_NAMESPACE = "http://richfaces.org/cdk/passThrough";
+ public static final String CDK_PASS_THROUGH_NAMESPACE = "http://richfaces.org/cdk/ext";
public static final String COMPOSITE_NAMESPACE = "http://richfaces.org/cdk/jsf/composite";
@@ -111,6 +111,15 @@
this.compositeImplementation = implementation;
}
+ public static boolean isDirectiveNamespace(QName name) {
+ return isDirectiveNamespace(name.getNamespaceURI());
+ }
+
+ public static boolean isDirectiveNamespace(String namespace) {
+ return JSTL_CORE_NAMESPACE.equals(namespace) || CDK_NAMESPACE.equals(namespace)
+ || CDK_PASS_THROUGH_NAMESPACE.equals(namespace)|| COMPOSITE_NAMESPACE.equals(namespace);
+ }
+
public static boolean isDefaultNamespace(QName name) {
return isDefaultNamespace(name.getNamespaceURI());
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -21,12 +21,17 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import java.util.Collections;
+import java.util.List;
+
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.TemplateModel;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
import org.richfaces.cdk.templatecompiler.el.types.ELType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.util.Strings;
import com.google.inject.Inject;
@@ -41,47 +46,46 @@
private final ELParser parser;
+ private final Logger log;
+
+ private final TypesFactory typesFactory;
+
private TypedTemplateStatement initializationStatement;
@Inject
- public DefineObjectStatement(@TemplateModel FreeMarkerRenderer renderer, ELParser parser) {
+ public DefineObjectStatement(Logger log, @TemplateModel FreeMarkerRenderer renderer, ELParser parser,
+ TypesFactory typesFactory) {
super(renderer, "define-object");
+ this.log = log;
this.parser = parser;
+ this.typesFactory = typesFactory;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param type
- * the type to set
- */
- public void setType(ELType type) {
- this.type = type;
- }
-
- /**
- * <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>
- *
* @param initializationExpression
* the initializationExpression to set
* @throws ParsingException
*/
- public void setInitializationExpression(String initializationExpression) throws ParsingException {
- initializationStatement = parser.parse(initializationExpression, this, TypesFactory.OBJECT_TYPE);
- initializationStatement.setParent(this);
+ public void setObject(String name, String type, String initializationExpression) {
+ try {
+ this.name = name;
+ if (!Strings.isEmpty(initializationExpression)) {
+ initializationStatement = parser.parse(initializationExpression, this, TypesFactory.OBJECT_TYPE);
+ initializationStatement.setParent(this);
+ this.type = initializationStatement.getType();
+ } else {
+ this.type = TypesFactory.OBJECT_TYPE;
+ }
+ if (!Strings.isEmpty(type)) {
+ this.type = typesFactory.getType(type);
+ addImports(this.type.getRequiredImports());
+ }
+ } catch (ParsingException e) {
+ log.error("Error parse initialization expression for variable " + name, e);
+ }
}
/**
@@ -99,10 +103,18 @@
}
/**
- * @return the initializationExpression
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the initializationStatement
*/
- public TemplateStatement getInitializationExpression() {
- return initializationStatement;
+ public TypedTemplateStatement getInitializationStatement() {
+ return this.initializationStatement;
}
+ @Override
+ public List<TemplateStatement> getStatements() {
+ return null != initializationStatement ? Collections.<TemplateStatement> singletonList(initializationStatement)
+ : Collections.<TemplateStatement> emptyList();
+ }
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -21,6 +21,8 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import javax.xml.namespace.QName;
+
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
/**
@@ -29,7 +31,7 @@
*/
public class ElementStatement extends FreeMarkerTemplateStatementBase {
- private String elementName;
+ private QName elementName;
public ElementStatement(FreeMarkerRenderer renderer, String template) {
super(renderer, template);
@@ -38,7 +40,7 @@
/**
* @return the elementName
*/
- public String getElementName() {
+ public QName getElementName() {
return elementName;
}
@@ -49,7 +51,7 @@
* @param elementName
* the elementName to set
*/
- public void setElementName(String elementName) {
+ public void setElementName(QName elementName) {
this.elementName = elementName;
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -21,9 +21,16 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
+import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.TemplateModel;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
+import org.richfaces.cdk.templatecompiler.el.ParsingException;
+import org.richfaces.cdk.templatecompiler.el.types.ELType;
+import com.google.common.collect.Iterables;
import com.google.inject.Inject;
/**
@@ -31,22 +38,28 @@
*/
public class ForEachStatement extends FreeMarkerTemplateStatementBase {
- private String itemsExpression;
+ private TypedTemplateStatement itemsStatement;
private String var;
- private String varType;
+ private ELType varType;
+ private final ELParser parser;
+
+ private final Logger log;
+
@Inject
- public ForEachStatement(@TemplateModel FreeMarkerRenderer renderer) {
+ public ForEachStatement(@TemplateModel FreeMarkerRenderer renderer,ELParser parser,Logger log) {
super(renderer,"for-each");
+ this.parser = parser;
+ this.log = log;
}
/**
* @return the itemsExpression
*/
- public String getItemsExpression() {
- return itemsExpression;
+ public TypedTemplateStatement getItemsExpression() {
+ return itemsStatement;
}
/**
@@ -59,32 +72,39 @@
/**
* @return the varType
*/
- public String getVarType() {
+ public ELType getVarType() {
return varType;
}
/**
* <p class="changed_added_4_0"></p>
* @param itemsExpression the itemsExpression to set
+ * @param var
*/
- public void setItemsExpression(String itemsExpression) {
- this.itemsExpression = itemsExpression;
+ public void setItemsExpression(String itemsExpression, String var) {
+ try {
+ this.itemsStatement = parser.parse(itemsExpression, this, Iterable.class.getName());
+ this.itemsStatement.setParent(this);
+ this.varType = this.itemsStatement.getType().getContainerType();
+ this.var=var;
+ setVariable(var, this.varType);
+ } catch (ParsingException e) {
+ log.error("Error parsing expression for iteration in <foreach> statement",e);
+ }
}
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param var the var to set
- */
- public void setVar(String var) {
- this.var = var;
+ @Override
+ public Iterable<JavaImport> getRequiredImports() {
+ return Iterables.concat(super.getRequiredImports(),itemsStatement.getRequiredImports());
}
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param varType the varType to set
- */
- public void setVarType(String varType) {
- this.varType = varType;
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return Iterables.concat(super.getRequiredMethods(),itemsStatement.getRequiredMethods());
}
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Iterables.concat(super.getRequiredFields(),itemsStatement.getRequiredFields());
+ }
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementBase.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementBase.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementBase.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -124,6 +124,11 @@
imports.add(new RuntimeImport(name));
}
+ protected void addImports(Iterable<JavaImport> requiredImports) {
+ Iterables.addAll(imports, requiredImports);
+ }
+
+
public void addRequiredMethod(String helperMethodName) {
HelperMethod helperMethod = HelperMethod.valueOf(helperMethodName);
requiredMethods.add(helperMethod);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -24,12 +24,15 @@
import static org.richfaces.cdk.templatecompiler.el.ELNodeConstants.*;
import java.util.Collection;
+import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import com.google.common.collect.Maps;
+
/**
* @author Nick Belaevski
*
@@ -45,6 +48,8 @@
RENDER_ATTRIBUTES_SET("renderPassThroughAttributes", Void.TYPE,FacesContext.class,UIComponent.class,Collection.class),
RENDER_ATTRIBUTE("renderAttribute",Void.TYPE,FacesContext.class,String.class,Object.class);
+ public static final EnumMap<HelperMethod, String> METHOD_NAMES = Maps.newEnumMap(HelperMethod.class);
+
private static final Set<HelperMethod> CONVERSION_METHODS = EnumSet.of(TO_STRING_CONVERSION, TO_BOOLEAN_CONVERSION);
private String name;
@@ -53,7 +58,13 @@
private Class<?>[] argumentTypes;
+ static {
+ for (HelperMethod method : HelperMethod.values()) {
+ METHOD_NAMES.put(method, method.getName());
+ }
+ }
+
private HelperMethod(String name, Class<?> returnType, Class<?>... argumentTypes) {
this.name = name;
this.returnType = returnType;
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -21,13 +21,28 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.ELParser;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
+import org.richfaces.cdk.templatecompiler.el.ParsingException;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+
public final class IfStatement extends StatementsContainer {
- private String test;
+ private TypedTemplateStatement testStatement;
+ private final ELParser parser;
+ private final Logger log;
- public IfStatement() {
+ @Inject
+ public IfStatement(ELParser parser,Logger log) {
super();
+ this.parser = parser;
+ this.log = log;
}
/**
@@ -35,10 +50,30 @@
* @param test the test to set
*/
public void setTest(String test) {
- this.test = test;
+ try {
+ testStatement = parser.parse(test, this, TypesFactory.BOOLEAN_TYPE);
+ testStatement.setParent(this);
+ } catch (ParsingException e) {
+ log.error("Error parsing if statement condition",e);
+ }
}
- public String getTest() {
- return test;
+ public TypedTemplateStatement getTest() {
+ return testStatement;
}
+
+ @Override
+ public Iterable<JavaImport> getRequiredImports() {
+ return Iterables.concat(super.getRequiredImports(),testStatement.getRequiredImports());
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return Iterables.concat(super.getRequiredMethods(),testStatement.getRequiredMethods());
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Iterables.concat(super.getRequiredFields(),testStatement.getRequiredFields());
+ }
}
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -23,7 +23,6 @@
import java.util.Collections;
-import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import org.richfaces.cdk.Logger;
@@ -41,7 +40,7 @@
*/
public class WriteAttributeStatement extends FreeMarkerTemplateStatementBase {
- private String attributeName;
+ private QName attributeName;
private TypedTemplateStatement valueExpression;
@@ -87,14 +86,10 @@
}
private void setAttributeName(QName qName) {
- StringBuilder nameBuilder = new StringBuilder();
- if(!XMLConstants.DEFAULT_NS_PREFIX.equals(qName.getPrefix())){
- nameBuilder.append(qName.getPrefix()).append(':');
- }
- this.attributeName = nameBuilder.append(qName.getLocalPart()).toString();
+ this.attributeName = qName;
}
- public String getAttributeName() {
+ public QName getAttributeName() {
return attributeName;
}
@@ -107,6 +102,7 @@
* @return the defaultValue
*/
public String getDefaultValue() {
+ // TODO - convert to Java syntax according to type.
return this.defaultValue;
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -21,8 +21,8 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import java.util.Collection;
import java.util.Set;
-import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicInteger;
import javax.xml.namespace.QName;
@@ -39,14 +39,61 @@
*/
public class WriteAttributesSetStatement extends FreeMarkerTemplateStatementBase {
+ /**
+ * <p class="changed_added_4_0">object contains information about attribute</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
public static final class PassThrough implements Comparable<PassThrough> {
QName name;
- Kind kind;
+ Kind kind = Kind.GENERIC;
String componentAttribute;
String type;
Object defaultValue;
Set<String> behaviors = Sets.newHashSet();
-
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public QName getName() {
+ return this.name;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the kind
+ */
+ public Kind getKind() {
+ return this.kind;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the componentAttribute
+ */
+ public String getComponentAttribute() {
+ return this.componentAttribute;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public String getType() {
+ return this.type;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ public Object getDefaultValue() {
+ return this.defaultValue;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the behaviors
+ */
+ public Set<String> getBehaviors() {
+ return this.behaviors;
+ }
public String getBuilderMethod() {
if(Kind.BOOLEAN.equals(kind)){
return "bool";
@@ -70,7 +117,7 @@
private String fieldName;
- private TreeSet<PassThrough> attributes;
+ private Collection<PassThrough> attributes;
@Inject
public WriteAttributesSetStatement(@TemplateModel FreeMarkerRenderer renderer) {
@@ -93,7 +140,7 @@
this.fieldName = fieldName;
}
- public void setAttributes(TreeSet<PassThrough> passThroughAttributes) {
+ public void setAttributes(Collection<PassThrough> passThroughAttributes) {
this.attributes = passThroughAttributes;
}
@@ -101,7 +148,7 @@
* <p class="changed_added_4_0"></p>
* @return the attributes
*/
- public TreeSet<PassThrough> getAttributes() {
+ public Collection<PassThrough> getAttributes() {
return this.attributes;
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -49,7 +49,7 @@
this.log = log;
}
- public TemplateStatement getTextStatement() {
+ public TemplateStatement getValue() {
return textStatement;
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd 2010-07-09 00:18:37 UTC (rev 17776)
@@ -1,30 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, Red Hat, Inc. and individual contributors
-by the @authors tag. See the copyright.txt in the distribution for a
-full listing of individual contributors.
+<!-- JBoss, Home of Professional Open Source Copyright ${year}, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the copyright.txt
+ in the distribution for a full listing of individual contributors. This is
+ free software; you can redistribute it and/or modify it under the terms of
+ the GNU Lesser General Public License as published by the Free Software Foundation;
+ either version 2.1 of the License, or (at your option) any later version.
+ This software 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 software; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the
+ FSF site: http://www.fsf.org. -->
-
-This is free software; you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as
-published by the Free Software Foundation; either version 2.1 of
-the License, or (at your option) any later version.
-
-
-This software 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 software; if not, write to the Free
-Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-02110-1301 USA, or see the FSF site: http://www.fsf.org.
--->
-
<xs:schema version="1.0" xml:lang="en"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://richfaces.org/cdk/xhtml-el"
xmlns="http://richfaces.org/cdk/xhtml-el" xmlns:xml="http://www.w3.org/XML/1998/namespace"
@@ -472,7 +461,8 @@
<xs:attribute name="class" type="NMTOKENS">
<xs:annotation>
<xs:appinfo>
- <cdk-addinfo:component-attribute-name>styleClass</cdk-addinfo:component-attribute-name>
+ <cdk-addinfo:component-attribute-name>styleClass
+ </cdk-addinfo:component-attribute-name>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
@@ -2194,7 +2184,7 @@
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
-
+
<xs:attributeGroup name="disabledGroup">
<xs:attribute name="disabled">
<xs:simpleType>
@@ -2211,7 +2201,7 @@
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
-
+
<xs:attributeGroup name="readonlyGroup">
<xs:attribute name="readonly">
<xs:simpleType>
@@ -2973,7 +2963,13 @@
<xs:group ref="cdk:structural" minOccurs="0" maxOccurs="unbounded" />
<xs:attributeGroup ref="attrs"></xs:attributeGroup>
<xs:attribute use="required" name="src" type="URI"></xs:attribute>
- <xs:attribute use="required" name="alt" type="Text"></xs:attribute>
+ <xs:attribute use="required" name="alt" type="Text">
+ <xs:annotation>
+ <xs:appinfo>
+ <cdk-addinfo:default-value></cdk-addinfo:default-value>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="name" type="NMTOKEN"></xs:attribute>
<xs:attribute name="longdesc" type="URI"></xs:attribute>
<xs:attribute name="height" type="Length"></xs:attribute>
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/define-object.ftl
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/define-object.ftl 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/define-object.ftl 2010-07-09 00:18:37 UTC (rev 17776)
@@ -1 +1 @@
-${modelItem.type.code} ${modelItem.name} <#if modelItem.initializationExpression.length() != 0> = ${modelItem.initializationExpression}</#if>;
\ No newline at end of file
+${type} ${name} <#if initializationStatement?exists> = ${initializationStatement}</#if>;
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/for-each.ftl
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/for-each.ftl 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/for-each.ftl 2010-07-09 00:18:37 UTC (rev 17776)
@@ -1,5 +1,5 @@
-for (${modelItem.varType} ${modelItem.var}: ${modelItem.itemsExpression}) {
- <#list modelItem.statements as subStatement>
+for (${varType} ${var}: ${itemsExpression}) {
+ <#list statements as subStatement>
${subStatement.code}
</#list>
}
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl 2010-07-09 00:18:37 UTC (rev 17776)
@@ -2,7 +2,7 @@
<#if statement_index == 0>
if (${statement.test}) {
<#else>
- } else <#if statement.test.length() != 0>if (${statement.test}) </#if> {
+ } else <#if statement.test?exists>if (${statement.test}) </#if> {
</#if>
<#list statement.statements as subStatement>
${subStatement.code}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl 2010-07-09 00:18:37 UTC (rev 17776)
@@ -3,7 +3,7 @@
<#else>
{
${value.type} value = ${value};
- if(null != value &&
+ if(<#if defaultValue?exists>null == value || !(<#else>null != value &&</#if>
<#if value.type == "Integer" || value.type == "int" >
value != Integer.MIN_VALUE
<#elseif value.type == "Double" || value.type == "double">
@@ -21,10 +21,18 @@
<#elseif value.type == "String" >
value.length()>0
<#else>
- <@util.require "SHOULD_RENDER_ATTRIBUTE"/>shouldRenderAttribute(value)
+ <@util.require "SHOULD_RENDER_ATTRIBUTE"/>${SHOULD_RENDER_ATTRIBUTE}(value)
</#if>
+ <#if defaultValue?exists>
+ )) {
+ value="${defaultValue}";
+ }
+ ${responseWriterVariable}.writeAttribute(${attributeName},value,null);
+ <#else>
) {
${responseWriterVariable}.writeAttribute(${attributeName},value,null);
}
+ </#if>
+
}
</#if>
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl 2010-07-09 00:18:37 UTC (rev 17776)
@@ -1,6 +1,7 @@
-<@util.constant "Attributes" "${fieldName}"><#list attributes as attribute>
- .{attribute.builderMethod}(${attribute.name},${attribute.componentAttribute}<#list attribute.behaviors as behavior>,${behavior}</#list>)
+<@util.require "RENDER_ATTRIBUTES_SET"/><@util.require "CREATE_ATTRIBUTES"/>
+<@util.constant "Attributes" "${fieldName}">${CREATE_ATTRIBUTES}()<#list attributes as attribute>
+ .${attribute.builderMethod}(${attribute.name},${attribute.componentAttribute}<#list attribute.behaviors as behavior>,${behavior}</#list>)
+ <#if attribute.defaultValue?exists >.defaultValue("${attribute.defaultValue}")</#if>
</#list></(a)util.constant>
-<@util.require "RENDER_ATTRIBUTES_SET"/>
-renderPassThroughAttributes(${facesContextVariable}, ${componentVariable},
+${RENDER_ATTRIBUTES_SET}(${facesContextVariable}, ${componentVariable},
${fieldName});
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-text.ftl
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-text.ftl 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-text.ftl 2010-07-09 00:18:37 UTC (rev 17776)
@@ -1,6 +1,10 @@
+<#if value.literal>
+ ${responseWriterVariable}.writeText(${value},null);
+<#else>
{
- Object text = ${modelItem.textExpression};
+ Object text = ${value};
if (text != null) {
${responseWriterVariable}.writeText(text, null);
}
-}
\ No newline at end of file
+}
+</#if>
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -69,9 +69,10 @@
protected Logger log;
@Mock
- @Output(Outputs.RESOURCES)
+ @Output(Outputs.JAVA_CLASSES)
protected FileManager output;
+
@Inject
@As(LibraryModelWrapper.class)
protected ObjectWrapper wrapper;
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatementTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatementTest.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatementTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -32,7 +32,6 @@
import javax.xml.namespace.QName;
-import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestBase;
Added: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -0,0 +1,67 @@
+package org.richfaces.cdk.templatecompiler.statements;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
+public class DefineObjectTest extends FreeMarkerTestBase {
+
+ @Mock
+ private TypesFactory typesFactory;
+
+ @Inject
+ private DefineObjectStatement statement;
+
+ @Test
+ public void testDefineVariable() throws Exception {
+ expect(typesFactory.getType("java.lang.String")).andReturn(TypesFactory.STRING_TYPE);
+ controller.replay();
+ statement.setObject("foo","java.lang.String",null);
+ String code = statement.getCode();
+ controller.verify();
+ verifyCode(code, "String"," foo","!=");
+ }
+
+ @Test
+ public void testDefineAndInitVariable() throws Exception {
+ expect(parser.parse(HTTP_EXAMPLE_COM, statement, TypesFactory.OBJECT_TYPE)).andReturn(parsedExpression);
+ expect(parsedExpression.getCode()).andStubReturn("get("+HTTP_EXAMPLE_COM+")");
+ expect(parsedExpression.isLiteral()).andStubReturn(false);
+ expect(parsedExpression.getType()).andStubReturn(TypesFactory.OBJECT_TYPE);
+ expect(parsedExpression.getRequiredMethods()).andStubReturn(Collections.<HelperMethod>emptySet());
+ expect(typesFactory.getType("java.lang.String")).andReturn(TypesFactory.STRING_TYPE);
+ parsedExpression.setParent(statement);expectLastCall();
+ controller.replay();
+ statement.setObject("foo","java.lang.String",HTTP_EXAMPLE_COM);
+ String code = statement.getCode();
+ verifyCode(code, HTTP_EXAMPLE_COM,"String","=");
+ controller.verify();
+ }
+ @Test
+ public void testDefineAndInitUnknownVariable() throws Exception {
+ expect(parser.parse(HTTP_EXAMPLE_COM, statement, TypesFactory.OBJECT_TYPE)).andReturn(parsedExpression);
+ expect(parsedExpression.getCode()).andStubReturn("get("+HTTP_EXAMPLE_COM+")");
+ expect(parsedExpression.isLiteral()).andStubReturn(false);
+ expect(parsedExpression.getType()).andStubReturn(TypesFactory.INTEGER_TYPE);
+ expect(parsedExpression.getRequiredMethods()).andStubReturn(Collections.<HelperMethod>emptySet());
+ parsedExpression.setParent(statement);expectLastCall();
+ controller.replay();
+ statement.setObject("foo",null,HTTP_EXAMPLE_COM);
+ String code = statement.getCode();
+ verifyCode(code, "Integer","foo","=");
+ controller.verify();
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -0,0 +1,43 @@
+package org.richfaces.cdk.templatecompiler.statements;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
+public class ForEachTest extends FreeMarkerTestBase {
+
+ @Mock
+ private TypesFactory typesFactory;
+
+ @Inject
+ private ForEachStatement statement;
+
+
+ @Test
+ public void testSetItemsExpression() throws Exception {
+ expect(parser.parse(HTTP_EXAMPLE_COM, statement, Iterable.class.getName())).andReturn(parsedExpression);
+ expect(parsedExpression.getCode()).andStubReturn("get("+HTTP_EXAMPLE_COM+")");
+ expect(parsedExpression.isLiteral()).andStubReturn(false);
+ expect(parsedExpression.getType()).andStubReturn(TypesFactory.OBJECT_TYPE);
+ expect(parsedExpression.getRequiredMethods()).andStubReturn(Collections.<HelperMethod>emptySet());
+ parsedExpression.setParent(statement);expectLastCall();
+ controller.replay();
+ statement.setItemsExpression(HTTP_EXAMPLE_COM,"foo");
+ String code = statement.getCode();
+ verifyCode(code, HTTP_EXAMPLE_COM,"for");
+ controller.verify();
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementTest1.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementTest1.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTemplateStatementTest1.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -5,14 +5,10 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.MockController;
-import org.richfaces.cdk.Stub;
import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
@RunWith(CdkTestRunner.class)
@@ -20,14 +16,6 @@
private static final String FOO_CODE = "private static final String foo;";
- @Stub
- private Logger log;
-
- @Inject
- private MockController controller;
-
-
-
public FreeMarkerTemplateStatementBase setUpStatement(String template) {
FreeMarkerTemplateStatementBase freeMarkerStatement = new FreeMarkerTemplateStatementBase(renderer, template);
return freeMarkerStatement;
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTestBase.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTestBase.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/FreeMarkerTestBase.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -31,13 +31,19 @@
import java.util.NoSuchElementException;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.MockController;
+import org.richfaces.cdk.Stub;
import org.richfaces.cdk.generate.freemarker.CdkConfiguration;
+import org.richfaces.cdk.generate.freemarker.ContextVariables;
import org.richfaces.cdk.generate.freemarker.DefaultImports;
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.generate.freemarker.TemplatesFolder;
+import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.JavaClassModelWrapper;
-import org.richfaces.cdk.templatecompiler.RendererClassVisitor;
import org.richfaces.cdk.templatecompiler.TemplateModel;
+import org.richfaces.cdk.templatecompiler.TemplateModule;
import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
import com.google.common.base.Predicate;
@@ -58,9 +64,18 @@
*/
public class FreeMarkerTestBase extends CdkTestBase {
+ protected static final String HTTP_EXAMPLE_COM = "http://example.com/";
@Inject
@TemplateModel
protected FreeMarkerRenderer renderer;
+ @Stub
+ protected Logger log;
+ @Mock
+ protected ELParser parser;
+ @Mock
+ protected TypedTemplateStatement parsedExpression;
+ @Inject
+ protected MockController controller;
@Override
public void configure(Binder binder) {
@@ -71,7 +86,7 @@
binder.bind(new TypeLiteral<Map<String, String>>() {
}).annotatedWith(DefaultImports.class).toInstance(ImmutableMap.of("util", "util.ftl"));
binder.bind(new TypeLiteral<Map<String, Object>>() {
- }).toInstance(RendererClassVisitor.ENCODE_METHOD_VARIABLES);
+ }).annotatedWith(ContextVariables.class).toInstance(TemplateModule.buildVariables());
}
protected void verifyImports(TemplateStatement statement, String... expected) {
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeTest.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -11,31 +11,13 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.MockController;
-import org.richfaces.cdk.Stub;
-import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
import com.google.inject.Inject;
@RunWith(CdkTestRunner.class)
public class WriteAttributeTest extends FreeMarkerTestBase {
- private static final String HTTP_EXAMPLE_COM = "http://example.com/";
-
- @Stub
- private Logger log;
-
- @Mock
- private ELParser parser;
- @Mock
- private TypedTemplateStatement parsedExpression;
-
@Inject
- private MockController controller;
-
- @Inject
private WriteAttributeStatement statement;
@Test
@@ -63,7 +45,7 @@
controller.replay();
statement.setAttribute(QName.valueOf("href"), HTTP_EXAMPLE_COM,null);
String code = statement.getCode();
- verifyCode(code, "!\""+HTTP_EXAMPLE_COM+"\"","writeAttribute","if(");
+ verifyCode(code, "!\""+HTTP_EXAMPLE_COM+"\"","writeAttribute","if(",HelperMethod.SHOULD_RENDER_ATTRIBUTE.getName());
verifyHelpers(statement, HelperMethod.SHOULD_RENDER_ATTRIBUTE);
controller.verify();
}
Added: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetTest.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -0,0 +1,73 @@
+/*
+ * $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.templatecompiler.statements;
+
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(CdkTestRunner.class)
+public class WriteAttributesSetTest extends FreeMarkerTestBase {
+
+ @Inject
+ private WriteAttributesSetStatement statement;
+
+ /**
+ * Test method for {@link org.richfaces.cdk.templatecompiler.statements.FreeMarkerTemplateStatementBase#getCode()}.
+ */
+ @Test
+ public void testGetCode() {
+ WriteAttributesSetStatement.PassThrough passThrough = new WriteAttributesSetStatement.PassThrough();
+ passThrough.name = QName.valueOf("foo");
+ passThrough.type = "String";
+ passThrough.componentAttribute = "bar";
+ passThrough.defaultValue = "deflt";
+ controller.replay();
+ statement.setAttributes(Collections.singleton(passThrough));
+ String code = statement.getCode();
+ controller.verify();
+ verifyCode(code, "!attributes()", "!defaultValue(", "!if(", "");
+ verifyHelpers(statement, HelperMethod.CREATE_ATTRIBUTES, HelperMethod.RENDER_ATTRIBUTES_SET);
+ JavaField javaField = Iterables.getOnlyElement(statement.getRequiredFields());
+ verifyCode(javaField.getValue().getCode(), "attributes()", "generic(", "defaultValue(");
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -0,0 +1,52 @@
+package org.richfaces.cdk.templatecompiler.statements;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
+public class WtiteTextTest extends FreeMarkerTestBase {
+
+ @Inject
+ private WriteTextStatement statement;
+
+ @Test
+ public void testWriteLiteral() throws Exception {
+ expect(parser.parse(HTTP_EXAMPLE_COM, statement, TypesFactory.OBJECT_TYPE)).andReturn(parsedExpression);
+ expect(parsedExpression.getCode()).andStubReturn("\""+HTTP_EXAMPLE_COM+"\"");
+ expect(parsedExpression.isLiteral()).andStubReturn(true);
+ expect(parsedExpression.getType()).andStubReturn(TypesFactory.STRING_TYPE);
+ parsedExpression.setParent(statement);expectLastCall();
+ controller.replay();
+ statement.setExpression(HTTP_EXAMPLE_COM);
+ String code = statement.getCode();
+ controller.verify();
+ verifyCode(code, "\""+HTTP_EXAMPLE_COM+"\"","writeText","!if");
+ }
+
+ @Test
+ public void testWriteExpression() throws Exception {
+ expect(parser.parse(HTTP_EXAMPLE_COM, statement, TypesFactory.OBJECT_TYPE)).andReturn(parsedExpression);
+ expect(parsedExpression.getCode()).andStubReturn("get("+HTTP_EXAMPLE_COM+")");
+ expect(parsedExpression.isLiteral()).andStubReturn(false);
+ expect(parsedExpression.getType()).andStubReturn(TypesFactory.OBJECT_TYPE);
+ expect(parsedExpression.getRequiredMethods()).andStubReturn(Collections.<HelperMethod>emptySet());
+ parsedExpression.setParent(statement);expectLastCall();
+ controller.replay();
+ statement.setExpression(HTTP_EXAMPLE_COM);
+ String code = statement.getCode();
+ verifyCode(code, "!\""+HTTP_EXAMPLE_COM+"\"","writeText","if");
+ controller.verify();
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
===================================================================
--- root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -31,7 +31,7 @@
public class ComponentAttribute implements Comparable<ComponentAttribute> {
public enum Kind {
- BOOLEAN,
+ BOOL,
GENERIC,
URI
}
@@ -40,6 +40,24 @@
private String componentAttributeName;
+ private Object dafaultValue;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the dafaultValue
+ */
+ public Object getDafaultValue() {
+ return this.dafaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param dafaultValue the dafaultValue to set
+ */
+ public void setDafaultValue(Object dafaultValue) {
+ this.dafaultValue = dafaultValue;
+ }
+
private String[] eventNames = {};
private Kind kind = Kind.GENERIC;
Modified: root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-07-08 15:35:39 UTC (rev 17775)
+++ root/commons/branches/RF8755/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-07-09 00:18:37 UTC (rev 17776)
@@ -406,6 +406,8 @@
@SuppressWarnings("serial")
public static final class Attributes extends TreeSet<ComponentAttribute> {
+
+ private ComponentAttribute last;
public void render(FacesContext context, UIComponent component) throws IOException {
renderPassThroughAttributes(context, component, this);
@@ -421,6 +423,8 @@
private ComponentAttribute createAttribute(String name, String componentAttribute) {
ComponentAttribute attribute = new ComponentAttribute(name);
attribute.setComponentAttributeName(componentAttribute);
+ add(attribute);
+ last = attribute;
return attribute;
}
@@ -432,9 +436,14 @@
public Attributes bool(String name, String componentAttribute) {
ComponentAttribute attribute = createAttribute(name, componentAttribute);
- attribute.setKind(Kind.BOOLEAN);
+ attribute.setKind(Kind.BOOL);
return this;
}
+
+ public Attributes defaultValue(Object value){
+ last.setDafaultValue(value);
+ return this;
+ }
}
14 years, 6 months