Author: alexsmirnov
Date: 2007-07-09 21:19:57 -0400 (Mon, 09 Jul 2007)
New Revision: 1561
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
Log:
packages and classes refactor in the "impl" project
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java 2007-07-10
01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,34 +0,0 @@
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-import java.util.EventObject;
-
-import org.ajax4jsf.event.PushEventListener;
-
-public class PushEventsCounter implements PushEventListener,Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 4060284352186710009L;
- private volatile boolean performed = false;
-
- public void onEvent(EventObject event) {
- performed = true;
- }
-
- /**
- * @return the performed
- */
- public boolean isPerformed() {
- return performed;
- }
-
- /**
- */
- public void processed() {
- this.performed = false;
- }
-
-
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10
01:10:15 UTC (rev 1560)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -39,8 +39,8 @@
import javax.faces.convert.Converter;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.Java2Dresource;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler (from rev 1558,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler)
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/AttributeElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,122 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-
-import org.ajax4jsf.Messages;
-import org.xml.sax.SAXException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
- *
- */
-public class AttributeElement extends ElementBase {
-
- private String name;
- private boolean mandatory = true;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(TemplateContext context) throws IOException {
- String attributeValue = getString(context);
- if(attributeValue.length()>0 || isMandatory()){
- context.getWriter().writeAttribute(getName(),attributeValue,null);
- }
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- throw new
FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_INSIDE_ATTRIBUTE_ERROR,
getName(), context.getComponent().getId()));
- }
-
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
- /**
- * @return Returns the notNull.
- */
- public boolean isMandatory() {
- return mandatory;
- }
- /**
- * Alias ( due to typo error ) for Mandatory property.
- * @param notNull The notNull to set.
- */
- public void setMantadory(boolean notNull) {
- this.mandatory = notNull;
- }
-
- /**
- * @param notNull The notNull to set.
- */
- public void setMandatory(boolean notNull) {
- this.mandatory = notNull;
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.ATTRIBUTE_TAG;
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- MethodCallElement.class,
- TextElement.class,
- ResourceElement.class,
- ClassElement.class
- };
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/AttributeElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.Messages;
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
+ *
+ */
+public class AttributeElement extends ElementBase {
+
+ private String name;
+ private boolean mandatory = true;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ String attributeValue = getString(context);
+ if(attributeValue.length()>0 || isMandatory()){
+ context.getWriter().writeAttribute(getName(),attributeValue,null);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ throw new
FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_INSIDE_ATTRIBUTE_ERROR,
getName(), context.getComponent().getId()));
+ }
+
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the notNull.
+ */
+ public boolean isMandatory() {
+ return mandatory;
+ }
+ /**
+ * Alias ( due to typo error ) for Mandatory property.
+ * @param notNull The notNull to set.
+ */
+ public void setMantadory(boolean notNull) {
+ this.mandatory = notNull;
+ }
+
+ /**
+ * @param notNull The notNull to set.
+ */
+ public void setMandatory(boolean notNull) {
+ this.mandatory = notNull;
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.ATTRIBUTE_TAG;
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ MethodCallElement.class,
+ TextElement.class,
+ ResourceElement.class,
+ ClassElement.class
+ };
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakException.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import javax.faces.FacesException;
-
-/**
- * Exception for process part of template.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:42 $
- *
- */
-public class BreakException extends FacesException {
-
- private String _name;
- /**
- * @param name
- *
- */
- public BreakException(String name) {
- super();
- _name=name;
- }
- /**
- * @return Returns the name.
- */
- public String getName() {
- return _name;
- }
-
-
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakException.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import javax.faces.FacesException;
+
+/**
+ * Exception for process part of template.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:42 $
+ *
+ */
+public class BreakException extends FacesException {
+
+ private String _name;
+ /**
+ * @param name
+ *
+ */
+ public BreakException(String name) {
+ super();
+ _name=name;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return _name;
+ }
+
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,138 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
- *
- */
-public class BreakPoint implements PreparedTemplate {
-
- private List childrens = new ArrayList();
-
- private PreparedTemplate _parent;
- private String name;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.RendererBase,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(RendererBase renderer, FacesContext context,
- UIComponent component) throws IOException {
- throw new BreakException(getName());
-
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- throw new BreakException(getName());
-
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint)
- throws IOException {
- if (!getName().equals(breakPoint)) {
- throw new BreakException(getName());
- } else if(getChildren().size()>0){
- // encode all childrens of this breakpoint.
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- PreparedTemplate element = (PreparedTemplate) iter.next();
- element.encode(context);
- }
- // after childrens, break encoding.
- throw new BreakException(getName());
- }
- // if no childrens - continue encoding.
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getChildren()
- */
- public List getChildren() {
- // breakpoint - empty element
- return childrens;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void addChild(PreparedTemplate child) throws SAXException {
- child.setParent(this);
- childrens.add(child);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
- }
- this._parent = parent;
- if (parent instanceof ElementBase) {
- ((ElementBase) parent).addBreakPoint(getName());
- }
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.BREAK_TAG;
- }
-
- public Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,138 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
+ *
+ */
+public class BreakPoint implements PreparedTemplate {
+
+ private List childrens = new ArrayList();
+
+ private PreparedTemplate _parent;
+ private String name;
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.RendererBase,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(RendererBase renderer, FacesContext context,
+ UIComponent component) throws IOException {
+ throw new BreakException(getName());
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ throw new BreakException(getName());
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint)
+ throws IOException {
+ if (!getName().equals(breakPoint)) {
+ throw new BreakException(getName());
+ } else if(getChildren().size()>0){
+ // encode all childrens of this breakpoint.
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ PreparedTemplate element = (PreparedTemplate) iter.next();
+ element.encode(context);
+ }
+ // after childrens, break encoding.
+ throw new BreakException(getName());
+ }
+ // if no childrens - continue encoding.
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getChildren()
+ */
+ public List getChildren() {
+ // breakpoint - empty element
+ return childrens;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void addChild(PreparedTemplate child) throws SAXException {
+ child.setParent(this);
+ childrens.add(child);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
+ }
+ this._parent = parent;
+ if (parent instanceof ElementBase) {
+ ((ElementBase) parent).addBreakPoint(getName());
+ }
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.BREAK_TAG;
+ }
+
+ public Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
- *
- */
-public class ChildElement extends ElementBase {
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- throw new
FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_3));
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- UIComponent child = (UIComponent)
context.getParameter(ChildrensElement.CURRENT_CHILD);
- if(null == child){
- child = (UIComponent) getValue(context);
- }
- if(null !=child && child.isRendered()){
- context.getRenderer().renderChild(context.getFacesContext(),child);
- }
- }
-
- public String getTag() {
- return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILD_TAG;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // child elements not allowed
- return new Class[]{};
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
+ *
+ */
+public class ChildElement extends ElementBase {
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ throw new
FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_3));
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ UIComponent child = (UIComponent)
context.getParameter(ChildrensElement.CURRENT_CHILD);
+ if(null == child){
+ child = (UIComponent) getValue(context);
+ }
+ if(null !=child && child.isRendered()){
+ context.getRenderer().renderChild(context.getFacesContext(),child);
+ }
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILD_TAG;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // child elements not allowed
+ return new Class[]{};
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildrensElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,154 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
- *
- */
-public class ChildrensElement extends ElementBase {
- public static final String CURRENT_CHILD = "child_to_render";
-
- private String iteratorName;
-
-
- public String getIteratorName() {
- return iteratorName;
- }
-
- public void setIteratorName(String iteratorVar) {
- this.iteratorName = iteratorVar;
-
- }
-
- public class IteratorWrapper implements Iterator{
- private Iterator iterator;
- private int index = -1;
-
- public IteratorWrapper(Iterator iterator) {
- this.iterator = iterator;
- }
- public Iterator getIterator() {
- return iterator;
- }
- public boolean hasNext() {
- return iterator.hasNext();
- }
- public Object next() {
- Object o = iterator.next();
- index++;
- return o;
- }
- public void remove() {
- iterator.remove();
- }
- public boolean isLast(){
- return !iterator.hasNext();
- }
- public int getIndex() {
- return index;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- UIComponent stored = (UIComponent) context.getParameter(CURRENT_CHILD);
-// Collection children = context.getComponent().getChildren();
- IteratorWrapper iter =new IteratorWrapper(Collections.EMPTY_LIST.iterator());
- Object value = getValue(context);
- if(value != null){
- if (value instanceof UIComponent) {
- UIComponent comp = (UIComponent) value;
- iter = new IteratorWrapper(comp.getChildren().iterator());
- } else if (value instanceof Collection) {
- iter = new IteratorWrapper( ((Collection) value).iterator() );
- } else if (value instanceof String) {
- String componentId = (String) value;
- UIComponent comp = context.getComponent().findComponent(componentId);
- if (null != comp) {
- iter = new IteratorWrapper(comp.getChildren().iterator());
- }
- } else if (value instanceof Iterator) {
- iter = new IteratorWrapper((Iterator) value);
- }
- } else {
- iter = new IteratorWrapper(context.getComponent().getChildren().iterator());
- }
- // For all childrens, iterate over template.
-// IteratorWrapper iter = new IteratorWrapper(children.iterator());
- if(iteratorName != null){
- context.putParameter(iteratorName, iter);
- }
- while (iter.hasNext()) {
- UIComponent child = (UIComponent) iter.next();
-
- if ( child.isRendered()) {
- if (getChildren().size()>0) {
- // Store facet to render in <u:child> element.
- // TODO - create new templatecontext with current iteration component ?
- context.putParameter(CURRENT_CHILD, child);
- // In fact, render all childrens.
- super.encode(context);
- } else {
- // empty element - render children as-is
- context.getRenderer().renderChild(context.getFacesContext(),child);
- }
- }
- }
- if(iteratorName != null){
- context.removeParameter(iteratorName);
- }
- if (null != stored) {
- context.putParameter(CURRENT_CHILD, stored);
- } else {
- context.removeParameter(CURRENT_CHILD);
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // TODO Auto-generated method stub
- throw new
FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_2));
- }
-
- public String getTag() {
- return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILDREN_TAG;
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildrensElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,154 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
+ *
+ */
+public class ChildrensElement extends ElementBase {
+ public static final String CURRENT_CHILD = "child_to_render";
+
+ private String iteratorName;
+
+
+ public String getIteratorName() {
+ return iteratorName;
+ }
+
+ public void setIteratorName(String iteratorVar) {
+ this.iteratorName = iteratorVar;
+
+ }
+
+ public class IteratorWrapper implements Iterator{
+ private Iterator iterator;
+ private int index = -1;
+
+ public IteratorWrapper(Iterator iterator) {
+ this.iterator = iterator;
+ }
+ public Iterator getIterator() {
+ return iterator;
+ }
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+ public Object next() {
+ Object o = iterator.next();
+ index++;
+ return o;
+ }
+ public void remove() {
+ iterator.remove();
+ }
+ public boolean isLast(){
+ return !iterator.hasNext();
+ }
+ public int getIndex() {
+ return index;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ UIComponent stored = (UIComponent) context.getParameter(CURRENT_CHILD);
+// Collection children = context.getComponent().getChildren();
+ IteratorWrapper iter =new IteratorWrapper(Collections.EMPTY_LIST.iterator());
+ Object value = getValue(context);
+ if(value != null){
+ if (value instanceof UIComponent) {
+ UIComponent comp = (UIComponent) value;
+ iter = new IteratorWrapper(comp.getChildren().iterator());
+ } else if (value instanceof Collection) {
+ iter = new IteratorWrapper( ((Collection) value).iterator() );
+ } else if (value instanceof String) {
+ String componentId = (String) value;
+ UIComponent comp = context.getComponent().findComponent(componentId);
+ if (null != comp) {
+ iter = new IteratorWrapper(comp.getChildren().iterator());
+ }
+ } else if (value instanceof Iterator) {
+ iter = new IteratorWrapper((Iterator) value);
+ }
+ } else {
+ iter = new IteratorWrapper(context.getComponent().getChildren().iterator());
+ }
+ // For all childrens, iterate over template.
+// IteratorWrapper iter = new IteratorWrapper(children.iterator());
+ if(iteratorName != null){
+ context.putParameter(iteratorName, iter);
+ }
+ while (iter.hasNext()) {
+ UIComponent child = (UIComponent) iter.next();
+
+ if ( child.isRendered()) {
+ if (getChildren().size()>0) {
+ // Store facet to render in <u:child> element.
+ // TODO - create new templatecontext with current iteration component ?
+ context.putParameter(CURRENT_CHILD, child);
+ // In fact, render all childrens.
+ super.encode(context);
+ } else {
+ // empty element - render children as-is
+ context.getRenderer().renderChild(context.getFacesContext(),child);
+ }
+ }
+ }
+ if(iteratorName != null){
+ context.removeParameter(iteratorName);
+ }
+ if (null != stored) {
+ context.putParameter(CURRENT_CHILD, stored);
+ } else {
+ context.removeParameter(CURRENT_CHILD);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // TODO Auto-generated method stub
+ throw new
FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_2));
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILDREN_TAG;
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ClassElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,148 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.faces.FacesException;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.style.CSSFormat;
-import org.xml.sax.SAXException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
- *
- */
-public class ClassElement extends ElementBase {
-
- private String _name;
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
- * java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint)
- throws IOException {
- encode(context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- context.getWriter().writeText(getString(context), null);
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return _name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- _name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public String getString(TemplateContext context) throws FacesException {
- if (null == getName()) {
- throw new FacesException(Messages
- .getMessage(Messages.STYLE_ATTRIBUTE_ERROR));
- }
- String stringOrDefault = valueGetter.getStringOrDefault(context);
- StringBuffer string = new StringBuffer();
- string.append(stringOrDefault);
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (element instanceof ElementBase) {
- ElementBase stringElement = (ElementBase) element;
- String str = stringElement.getString(context);
- if (str.length() > 0) {
- string.append(" ");
- boolean isUrl = element instanceof ResourceElement;
- if (isUrl) {
- string.append(CSSFormat.url(str));
- } else {
- string.append(str);
- }
- }
- }
- }
- if (string.length() > 0) {
- string.insert(0, ":").insert(0, getName()).append(";");
- return string.toString();
- } else {
- return "";
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX + HtmlCompiler.STYLE_TAG;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName() == null) {
- throw new SAXException(Messages.getMessage(
- Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[] { MethodCallElement.class, TextElement.class,
- ResourceElement.class };
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ClassElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,148 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.util.style.CSSFormat;
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
+ *
+ */
+public class ClassElement extends ElementBase {
+
+ private String _name;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
+ * java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint)
+ throws IOException {
+ encode(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ context.getWriter().writeText(getString(context), null);
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @param name
+ * The name to set.
+ */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+ if (null == getName()) {
+ throw new FacesException(Messages
+ .getMessage(Messages.STYLE_ATTRIBUTE_ERROR));
+ }
+ String stringOrDefault = valueGetter.getStringOrDefault(context);
+ StringBuffer string = new StringBuffer();
+ string.append(stringOrDefault);
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof ElementBase) {
+ ElementBase stringElement = (ElementBase) element;
+ String str = stringElement.getString(context);
+ if (str.length() > 0) {
+ string.append(" ");
+ boolean isUrl = element instanceof ResourceElement;
+ if (isUrl) {
+ string.append(CSSFormat.url(str));
+ } else {
+ string.append(str);
+ }
+ }
+ }
+ }
+ if (string.length() > 0) {
+ string.insert(0, ":").insert(0, getName()).append(";");
+ return string.toString();
+ } else {
+ return "";
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX + HtmlCompiler.STYLE_TAG;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName() == null) {
+ throw new SAXException(Messages.getMessage(
+ Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[] { MethodCallElement.class, TextElement.class,
+ ResourceElement.class };
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,438 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.apache.commons.beanutils.MethodUtils;
-import org.richfaces.skin.SkinFactory;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
- *
- */
-public abstract class ElementBase implements PreparedTemplate {
-
- private List childrens = new ArrayList();
- private Map breaks = new HashMap();
-
- protected ValueGetter valueGetter = new ValueGetter();
- private Object _value = null;
- private Object _default = null;
- private Object _context = null;
- private String _property = null;
- private String _skin ;
-// private String _skinConfiguration ;
- private String _call = null;
- private PreparedTemplate parent;
- private ValueBinding _valueBinding;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(RendererBase renderer, FacesContext context,
- UIComponent component) throws IOException {
- encode(new TemplateContext(renderer,context,component));
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- if (breaks.containsKey(breakPoint)) {
- // start after last breakpoint.
- int start = ((Integer)breaks.get(breakPoint)).intValue();
- Iterator iter = getChildren().listIterator(start);
- ((PreparedTemplate) iter.next()).encode(context,breakPoint);
- // perform childrens - other not contain this breakpoint !
- while ( iter.hasNext()) {
- PreparedTemplate element = (PreparedTemplate) iter.next();
- element.encode(context);
- }
- encodeEnd(context);
- } else {
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINT_NOT_REGISTERED_ERROR,
breakPoint));
- }
-
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- // perform childrens.
- encodeBegin(context);
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- PreparedTemplate element = (PreparedTemplate) iter.next();
- element.encode(context);
- }
- encodeEnd(context);
- }
-
- protected void encodeBegin(TemplateContext context) throws IOException {
-
- }
-
- protected void encodeEnd(TemplateContext context) throws IOException {
-
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#getChildren()
- */
- public List getChildren() {
- // TODO Auto-generated method stub
- return childrens;
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.CompiledXML#addChild(org.ajax4jsf.renderkit.compiler.CompiledXML)
- */
- public void addChild(PreparedTemplate child) throws SAXException {
- Class[] allowedClasses = getAllowedClasses();
- for (int i = 0; i < allowedClasses.length; i++) {
- if(allowedClasses[i].isInstance(child)){
- child.setParent(this);
- getChildren().add(child);
- return;
- }
- }
- // element don't allowed as child for this.
- throw new SAXException(Messages.getMessage(Messages.CHILD_NOT_ALLOWED_ERROR,
child.getTag(), getTag()));
- }
-
- /**
- *
- * @return array of classes, allowed as childs for this element.
- */
- protected Class[] getAllowedClasses(){
- return new Class[]{PreparedTemplate.class};
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- this.parent = parent;
- // Translate all registered breakpoints to parent
- if (parent instanceof ElementBase ) {
- for (Iterator iter = breaks.keySet().iterator(); iter.hasNext();) {
- ((ElementBase) parent).addBreakPoint((String) iter.next());
- }
- }
- }
-
- public void addBreakPoint(String name){
- Integer num = new Integer(getChildren().size());
- breaks.put(name,num);
-// if (null != parent && parent instanceof ElementBase) {
-// ((ElementBase) parent).addBreakPoint(name);
-// }
- }
-
-
-
- /* (non-Javadoc)
- * Build this class name with childrens.
- * @see java.lang.Object#toString()
- */
- public String toString() {
- //
- StringBuffer buf = new StringBuffer(this.getClass().getName());
- buf.append(" [\n");
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- Object child = (Object) iter.next();
- buf.append(" ").append(child.toString()).append(" ;\n");
- }
- buf.append("]\n");
- return buf.toString();
- }
-
- /**
- * @return Returns the value. If is EL expression valueBinding - evaluate in.
- */
- public Object getValue(TemplateContext context) {
- return valueGetter.getValue(context);
- }
-
- public String getString(TemplateContext context) throws FacesException {
- StringBuffer string = new StringBuffer();
- string.append(valueGetter.getStringOrDefault(context));
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (element instanceof ElementBase) {
- ElementBase stringElement = (ElementBase) element;
- string.append(stringElement.getString(context));
- }
- }
- return string.toString();
- }
- /**
- * @param value The value to set. if EL-expression ( #{...} ) - compile it.
- */
- public void setValue(Object value) {
- if (value instanceof String) {
- String stringValue = (String) value;
- if(isValueReference(stringValue)){
- _value = value;
- try {
- Application app =
((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
- _valueBinding = app.createValueBinding(stringValue);
- } catch (Exception e) {
- // Do nothing - create at first call
- }
- this.valueGetter = new ValueGetter(){
-
- public /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- if(null==_valueBinding) {
- Application app = context.getFacesContext().getApplication();
- _valueBinding = app.createValueBinding((String) _value);
- }
- return _valueBinding.getValue(context.getFacesContext());
- }
-
- };
- return;
- }
- }
- this._value = value;
- this.valueGetter = new ValueGetter(){
-
- public /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return _value;
- }
-
- };
- }
-
- /**
- * @return Returns the default.
- */
- public Object getDefault() {
- return _default;
- }
-
- /**
- * @param default1 The default to set.
- */
- public void setDefault(Object default1) {
- _default = default1;
- }
-
- /**
- * @param property The property to set.
- */
- public void setProperty(String property) {
- _property = property;
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- Object value = context.getComponent().getAttributes().get(_property);
- if (context.getRenderer().getUtils().isValidProperty(value)) {
- return value;
- } else {
- return null;
- }
- }
-
- };
- }
-
- /**
- * @param skin The skin to set.
- */
- public void setSkin(String skin) {
- _skin = skin;
-// if( null == _skinConfiguration ){
- // Only Skin parameter is used.
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- FacesContext facesContext = context.getFacesContext();
- Object parameter =
SkinFactory.getInstance().getSkin(facesContext).getParameter(facesContext,_skin,_default);
- return parameter;
- }
-
- };
-// } else {
-// valueGetter = new ConfigurationAndSkinValueGetter();
-// }
- }
-
- /**
- * Set name of skin parameter in "mandatory" list ( default value for
fine-tuning parameter ).
- * @param mandatorySkin
- */
-// public void setSkinConfiguration(String mandatorySkin) {
-// _skinConfiguration = mandatorySkin;
-// if(null == _skin){
-// valueGetter = new ConfigurationValueGetter();
-// } else {
-// valueGetter = new ConfigurationAndSkinValueGetter();
-// }
-// }
-
- /**
- * @param context The context to set.
- */
- public void setContext(Object context) {
- _context = context;
- //System.out.println("CTX:" + context);
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return context.getParameter(_context);
- }
-
- };
- }
-
- /**
- * @param call The call to set.
- */
- public void setCall(String call) {
- this._call = call;
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- try {
- return MethodUtils.invokeMethod(context
- .getRenderer(), _call, new Object[]{context});
- } catch (Exception e) {
- throw new FacesException(Messages.getMessage(Messages.INVOKE_RENDERER_METHOD_ERROR,
this.getClass().getName()), e);
- }
- }
-
- };
- }
-
- /**
- * Get EL-enabled value. Return same string, if not el-expression.
- * Otherthise, return parsed and evaluated expression.
- * @param context - current Faces Context.
- * @param value - string to parse.
- * @return - interpreted el or unmodified value.
- */
- protected boolean isValueReference( String value) {
- if (value == null)
- return false;
-
- int start = value.indexOf("#{");
- if (start >= 0) {
- int end = value.lastIndexOf('}');
- if (end >= 0 && start < end) {
- return true;
- }
- }
- return false;
- }
-
-// private final class ConfigurationValueGetter extends ValueGetter {
-// /* (non-Javadoc)
-// * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
-// */
-// Object getValue(TemplateContext context) {
-// FacesContext facesContext = context.getFacesContext();
-// Object parameter =
SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration);
-// if(null == parameter){
-// parameter = _default;
-// }
-// return parameter;
-// }
-// }
-//
-// private final class ConfigurationAndSkinValueGetter extends ValueGetter {
-// /* (non-Javadoc)
-// * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
-// */
-// Object getValue(TemplateContext context) {
-// FacesContext facesContext = context.getFacesContext();
-// return
SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration,_skin,_default);
-// }
-// }
-
-
- protected class ValueGetter {
- Object getValue(TemplateContext context) {
- return null;
- }
-
- Object getValueOrDefault(TemplateContext context){
- Object result = getValue(context);
- if (null == result) {
- result = getDefault();
- }
- return result;
- }
-
- String getStringOrDefault(TemplateContext context){
- Object result = getValue(context);
- if (null == result || result.toString().length()==0) {
- result = getDefault();
- if (null == result) {
- result = "";
- }
- }
- return result.toString();
-
- }
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,438 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.apache.commons.beanutils.MethodUtils;
+import org.richfaces.skin.SkinFactory;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
+ *
+ */
+public abstract class ElementBase implements PreparedTemplate {
+
+ private List childrens = new ArrayList();
+ private Map breaks = new HashMap();
+
+ protected ValueGetter valueGetter = new ValueGetter();
+ private Object _value = null;
+ private Object _default = null;
+ private Object _context = null;
+ private String _property = null;
+ private String _skin ;
+// private String _skinConfiguration ;
+ private String _call = null;
+ private PreparedTemplate parent;
+ private ValueBinding _valueBinding;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(RendererBase renderer, FacesContext context,
+ UIComponent component) throws IOException {
+ encode(new TemplateContext(renderer,context,component));
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ if (breaks.containsKey(breakPoint)) {
+ // start after last breakpoint.
+ int start = ((Integer)breaks.get(breakPoint)).intValue();
+ Iterator iter = getChildren().listIterator(start);
+ ((PreparedTemplate) iter.next()).encode(context,breakPoint);
+ // perform childrens - other not contain this breakpoint !
+ while ( iter.hasNext()) {
+ PreparedTemplate element = (PreparedTemplate) iter.next();
+ element.encode(context);
+ }
+ encodeEnd(context);
+ } else {
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINT_NOT_REGISTERED_ERROR,
breakPoint));
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // perform childrens.
+ encodeBegin(context);
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ PreparedTemplate element = (PreparedTemplate) iter.next();
+ element.encode(context);
+ }
+ encodeEnd(context);
+ }
+
+ protected void encodeBegin(TemplateContext context) throws IOException {
+
+ }
+
+ protected void encodeEnd(TemplateContext context) throws IOException {
+
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#getChildren()
+ */
+ public List getChildren() {
+ // TODO Auto-generated method stub
+ return childrens;
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.CompiledXML#addChild(org.ajax4jsf.renderkit.compiler.CompiledXML)
+ */
+ public void addChild(PreparedTemplate child) throws SAXException {
+ Class[] allowedClasses = getAllowedClasses();
+ for (int i = 0; i < allowedClasses.length; i++) {
+ if(allowedClasses[i].isInstance(child)){
+ child.setParent(this);
+ getChildren().add(child);
+ return;
+ }
+ }
+ // element don't allowed as child for this.
+ throw new SAXException(Messages.getMessage(Messages.CHILD_NOT_ALLOWED_ERROR,
child.getTag(), getTag()));
+ }
+
+ /**
+ *
+ * @return array of classes, allowed as childs for this element.
+ */
+ protected Class[] getAllowedClasses(){
+ return new Class[]{PreparedTemplate.class};
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ this.parent = parent;
+ // Translate all registered breakpoints to parent
+ if (parent instanceof ElementBase ) {
+ for (Iterator iter = breaks.keySet().iterator(); iter.hasNext();) {
+ ((ElementBase) parent).addBreakPoint((String) iter.next());
+ }
+ }
+ }
+
+ public void addBreakPoint(String name){
+ Integer num = new Integer(getChildren().size());
+ breaks.put(name,num);
+// if (null != parent && parent instanceof ElementBase) {
+// ((ElementBase) parent).addBreakPoint(name);
+// }
+ }
+
+
+
+ /* (non-Javadoc)
+ * Build this class name with childrens.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ //
+ StringBuffer buf = new StringBuffer(this.getClass().getName());
+ buf.append(" [\n");
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ Object child = (Object) iter.next();
+ buf.append(" ").append(child.toString()).append(" ;\n");
+ }
+ buf.append("]\n");
+ return buf.toString();
+ }
+
+ /**
+ * @return Returns the value. If is EL expression valueBinding - evaluate in.
+ */
+ public Object getValue(TemplateContext context) {
+ return valueGetter.getValue(context);
+ }
+
+ public String getString(TemplateContext context) throws FacesException {
+ StringBuffer string = new StringBuffer();
+ string.append(valueGetter.getStringOrDefault(context));
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof ElementBase) {
+ ElementBase stringElement = (ElementBase) element;
+ string.append(stringElement.getString(context));
+ }
+ }
+ return string.toString();
+ }
+ /**
+ * @param value The value to set. if EL-expression ( #{...} ) - compile it.
+ */
+ public void setValue(Object value) {
+ if (value instanceof String) {
+ String stringValue = (String) value;
+ if(isValueReference(stringValue)){
+ _value = value;
+ try {
+ Application app =
((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ _valueBinding = app.createValueBinding(stringValue);
+ } catch (Exception e) {
+ // Do nothing - create at first call
+ }
+ this.valueGetter = new ValueGetter(){
+
+ public /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ if(null==_valueBinding) {
+ Application app = context.getFacesContext().getApplication();
+ _valueBinding = app.createValueBinding((String) _value);
+ }
+ return _valueBinding.getValue(context.getFacesContext());
+ }
+
+ };
+ return;
+ }
+ }
+ this._value = value;
+ this.valueGetter = new ValueGetter(){
+
+ public /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return _value;
+ }
+
+ };
+ }
+
+ /**
+ * @return Returns the default.
+ */
+ public Object getDefault() {
+ return _default;
+ }
+
+ /**
+ * @param default1 The default to set.
+ */
+ public void setDefault(Object default1) {
+ _default = default1;
+ }
+
+ /**
+ * @param property The property to set.
+ */
+ public void setProperty(String property) {
+ _property = property;
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ Object value = context.getComponent().getAttributes().get(_property);
+ if (context.getRenderer().getUtils().isValidProperty(value)) {
+ return value;
+ } else {
+ return null;
+ }
+ }
+
+ };
+ }
+
+ /**
+ * @param skin The skin to set.
+ */
+ public void setSkin(String skin) {
+ _skin = skin;
+// if( null == _skinConfiguration ){
+ // Only Skin parameter is used.
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ FacesContext facesContext = context.getFacesContext();
+ Object parameter =
SkinFactory.getInstance().getSkin(facesContext).getParameter(facesContext,_skin,_default);
+ return parameter;
+ }
+
+ };
+// } else {
+// valueGetter = new ConfigurationAndSkinValueGetter();
+// }
+ }
+
+ /**
+ * Set name of skin parameter in "mandatory" list ( default value for
fine-tuning parameter ).
+ * @param mandatorySkin
+ */
+// public void setSkinConfiguration(String mandatorySkin) {
+// _skinConfiguration = mandatorySkin;
+// if(null == _skin){
+// valueGetter = new ConfigurationValueGetter();
+// } else {
+// valueGetter = new ConfigurationAndSkinValueGetter();
+// }
+// }
+
+ /**
+ * @param context The context to set.
+ */
+ public void setContext(Object context) {
+ _context = context;
+ //System.out.println("CTX:" + context);
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return context.getParameter(_context);
+ }
+
+ };
+ }
+
+ /**
+ * @param call The call to set.
+ */
+ public void setCall(String call) {
+ this._call = call;
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ try {
+ return MethodUtils.invokeMethod(context
+ .getRenderer(), _call, new Object[]{context});
+ } catch (Exception e) {
+ throw new FacesException(Messages.getMessage(Messages.INVOKE_RENDERER_METHOD_ERROR,
this.getClass().getName()), e);
+ }
+ }
+
+ };
+ }
+
+ /**
+ * Get EL-enabled value. Return same string, if not el-expression.
+ * Otherthise, return parsed and evaluated expression.
+ * @param context - current Faces Context.
+ * @param value - string to parse.
+ * @return - interpreted el or unmodified value.
+ */
+ protected boolean isValueReference( String value) {
+ if (value == null)
+ return false;
+
+ int start = value.indexOf("#{");
+ if (start >= 0) {
+ int end = value.lastIndexOf('}');
+ if (end >= 0 && start < end) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+// private final class ConfigurationValueGetter extends ValueGetter {
+// /* (non-Javadoc)
+// * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+// */
+// Object getValue(TemplateContext context) {
+// FacesContext facesContext = context.getFacesContext();
+// Object parameter =
SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration);
+// if(null == parameter){
+// parameter = _default;
+// }
+// return parameter;
+// }
+// }
+//
+// private final class ConfigurationAndSkinValueGetter extends ValueGetter {
+// /* (non-Javadoc)
+// * @see
org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+// */
+// Object getValue(TemplateContext context) {
+// FacesContext facesContext = context.getFacesContext();
+// return
SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration,_skin,_default);
+// }
+// }
+
+
+ protected class ValueGetter {
+ Object getValue(TemplateContext context) {
+ return null;
+ }
+
+ Object getValueOrDefault(TemplateContext context){
+ Object result = getValue(context);
+ if (null == result) {
+ result = getDefault();
+ }
+ return result;
+ }
+
+ String getStringOrDefault(TemplateContext context){
+ Object result = getValue(context);
+ if (null == result || result.toString().length()==0) {
+ result = getDefault();
+ if (null == result) {
+ result = "";
+ }
+ }
+ return result.toString();
+
+ }
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/FacetElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
-public class FacetElement extends ElementBase {
-
- public static final String CURRENT_FACET = "child_to_render";
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- String facetName = getValue(context).toString();
- if (null == facetName) {
- throw new FacesException(Messages.getMessage(Messages.NO_FACET_NAME_ATTRIBUTE,
getTag()));
- }
- UIComponent stored = (UIComponent) context
- .getParameter(CURRENT_FACET);
- // if inside childrens loop - render facet from current iteration component.
- // TODO - use cloned context
- UIComponent facet = null ==
stored?context.getComponent().getFacet(facetName):stored.getFacet(facetName);
- if (null != facet && facet.isRendered()) {
- if (getChildren().size()>0) {
- // Store facet to render in <u:child> element.
- // TODO - use cloned context.
- context.putParameter(CURRENT_FACET, facet);
- // In fact, render all childrens.
- super.encode(context);
- if (null != stored) {
- context.putParameter(CURRENT_FACET, stored);
- } else {
- context.removeParameter(CURRENT_FACET);
- }
- } else {
- // empty element - render facet as-is.
- context.getRenderer().renderChild(context.getFacesContext(),facet);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // TODO Auto-generated method stub
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR,
getValue(context)));
- }
-
- public void setName(Object name) {
- setValue(name);
- }
-
- public String getTag() {
- return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.FACET_TAG;
- }
-
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/FacetElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+public class FacetElement extends ElementBase {
+
+ public static final String CURRENT_FACET = "child_to_render";
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ String facetName = getValue(context).toString();
+ if (null == facetName) {
+ throw new FacesException(Messages.getMessage(Messages.NO_FACET_NAME_ATTRIBUTE,
getTag()));
+ }
+ UIComponent stored = (UIComponent) context
+ .getParameter(CURRENT_FACET);
+ // if inside childrens loop - render facet from current iteration component.
+ // TODO - use cloned context
+ UIComponent facet = null ==
stored?context.getComponent().getFacet(facetName):stored.getFacet(facetName);
+ if (null != facet && facet.isRendered()) {
+ if (getChildren().size()>0) {
+ // Store facet to render in <u:child> element.
+ // TODO - use cloned context.
+ context.putParameter(CURRENT_FACET, facet);
+ // In fact, render all childrens.
+ super.encode(context);
+ if (null != stored) {
+ context.putParameter(CURRENT_FACET, stored);
+ } else {
+ context.removeParameter(CURRENT_FACET);
+ }
+ } else {
+ // empty element - render facet as-is.
+ context.getRenderer().renderChild(context.getFacesContext(),facet);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // TODO Auto-generated method stub
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR,
getValue(context)));
+ }
+
+ public void setName(Object name) {
+ setValue(name);
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.FACET_TAG;
+ }
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,422 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.apache.commons.digester.RulesBase;
-import org.apache.commons.digester.SetNextRule;
-import org.apache.commons.digester.SetPropertiesRule;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.LocatorImpl;
-
-
-/**
- * Compiler for XML string or stream for creation of {@link javax.faces.render.Renderer}
internal
- * interpretator. Use Apache Digitester for parse .
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
-public class HtmlCompiler {
-
- public static final String NS_PREFIX = "f:";
- public static final String NS_UTIL_PREFIX = "u:";
- public static final String ROOT_TAG = "template";
- public static final String CALL_TAG = "call";
- public static final String VALUE_CALL_TAG = "valueCall";
- public static final String CALL_PARAM_TAG = "parameter";
- public static final String VERBATUM_TAG = "verbatim";
- public static final String BREAK_TAG = "break";
- public static final String FACET_TAG = "insertFacet";
- public static final String CHILDREN_TAG = "insertChildren";
- public static final String IF_TAG = "if";
- public static final String CHILD_TAG = "insertChild";
- public static final String STYLE_TAG = "style";
- public static final String CHILD_METHOD = "addChild";
- public static final String RESOURCE_TAG = "resource";
- public static final String ATTRIBUTE_TAG = "attribute";
- public static final String CHILD_PARAM_METHOD = "addParameter";
- public static final String ANY_PARENT = "*/";
- public static final String SELECTOR_TAG = "selector";
-
-
- private static final Log log = LogFactory.getLog(HtmlCompiler.class);
-
- private Digester digestr = new Digester();
-
-
- /**
- * Constructor with initialisation.
- */
- public HtmlCompiler(){
- WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new RulesBase());
- // Add default rules to process plain tags.
- rules.addDefault(new PlainElementCreateRule());
- rules.addDefault(new SetNextRule(CHILD_METHOD));
- digestr.setDocumentLocator(new LocatorImpl());
- digestr.setRules(rules);
- digestr.setValidating(false);
- digestr.setNamespaceAware(false);
- digestr.setUseContextClassLoader(true);
- // Concrete renderer method call rules.
- setCustomRules(digestr);
- }
-
- /**
- * Build custom rules for parse special tags and attributes.
- * For most tags, value can be in next forms ( for resource, preffixed with f: ):
- * <ul>
- * <li><b>value</b> as string or EL-expression</li>
- * <li><b>property</b> name for property of current
component</li>
- * <li><b>skin</b> name for property of current skin</li>
- * <li><b>context</b> name for property of {@link TemplateContext} for
trmplate encoding</li>
- * <li><b>default</b> use as value if main property
<code>null</code></li>
- * </ul>
- * Supported :
- * <ul>
- * <li>Call renderer or utils method <f:call name='xxx'
/></li>
- * <li>Call method parameter <f:parameter name='xxx'
(value='....' | property='style' | skin='paramName' |
context='propertyName ) /></li>
- * <li>Encode plain text <f:verbatim [value='....' |
property='style' | skin='paramName' | context='propertyName ]
>Some Text</f:text></li>
- * <li>Encode as text in HTML CSS parameter format <u:style
name='background' (value='....' | property='style' |
skin='paramName' | context='propertyName )/></li>
- * <li>Get and encode resource <f:resource
f:key='images/spacer.gif' [ ... any attributes ... ] /></li>
- * <li>Encode custom attribute <f:attribute name='style'
(value='....' | property='style' | skin='paramName' |
context='propertyName ) [endorsed='true'] /></li>
- * <li>Template breakpoint <f:break name='xxxxx'
/></li>
- * <li>Encode named facet <u:facet ( name='head |
property='style' | skin='paramName' | context='propertyName )'
/></li>
- * <li>Encode children components for current <u:children
/></li>
- * <li>Encode one child component for enclosed u:facet or u:children
<u:child /'></li>
- * </ul>
- * @param digestr
- */
- protected void setCustomRules( Digester digestr){
- // Root element. not instantiate - already set by compile method.
- String pattern = NS_PREFIX+ROOT_TAG;
- digestr.addSetProperties(pattern);
- // call renderer method <f:call methodName='xxx' [methodParam='yyy']
/>
- pattern = ANY_PARENT+NS_PREFIX+CALL_TAG;
- digestr.addObjectCreate(pattern,MethodCallElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- // for value of parent call renderer method <f:valueCall methodName='xxx'
[methodParam='yyy'] />
- pattern = ANY_PARENT+NS_PREFIX+VALUE_CALL_TAG;
- digestr.addObjectCreate(pattern,ValueMethodCallElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- // call parameter <f:parapeter methodName='xxx' [methodParam='yyy']
/>
-// pattern = ANY_PARENT+NS_PREFIX+CALL_TAG+"/"+NS_PREFIX+CALL_PARAM_TAG;
- pattern = ANY_PARENT+NS_PREFIX+CALL_PARAM_TAG;
- digestr.addObjectCreate(pattern,MethodParameterElement.class);
- digestr.addSetNext(pattern,CHILD_PARAM_METHOD);
- digestr.addSetProperties(pattern);
- // Encode plain text <f:text>Some Text</f:text>
- pattern = ANY_PARENT+NS_PREFIX+VERBATUM_TAG;
- digestr.addObjectCreate(pattern,TextElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- digestr.addBeanPropertySetter(pattern,"text");
- // resource <f:resource f:key='images/spacer.gif' [f:data='...'] [
... any attributes ... ] />
- pattern =ANY_PARENT+NS_PREFIX+RESOURCE_TAG;
- digestr.addObjectCreate(pattern,ResourceElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- {
- Rule rule = new PutAttributesRule(digestr,new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
- digestr.addRule(pattern,rule);
- }
- {
- SetPropertiesRule rule = new SetPropertiesRule(new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new
String[]{"value","property","skin","context"});
- digestr.addRule(pattern,rule);
- }
- // custom attribute <f:attribute name='style' (value='....' |
property='style' | skin='paramName' | call='methodName' |
utilCall='methodName') [notNull='true'] />
- pattern = ANY_PARENT+NS_PREFIX+ATTRIBUTE_TAG;
- digestr.addObjectCreate(pattern,AttributeElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- // component clientId <f:id [f:required='true'] />
- // breakpoint <f:break name="name">
- pattern = ANY_PARENT+NS_PREFIX+BREAK_TAG;
- digestr.addObjectCreate(pattern,BreakPoint.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- // conditional rendering <f:if then="true">
- pattern = ANY_PARENT+NS_PREFIX+IF_TAG;
- digestr.addObjectCreate(pattern,IfElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- // facet <u:insertFacet name="name">
- pattern = ANY_PARENT+NS_UTIL_PREFIX+FACET_TAG;
- digestr.addObjectCreate(pattern,FacetElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
-
- // childrens <u:insertChildren>
- pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILDREN_TAG;
- digestr.addObjectCreate(pattern,ChildrensElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
-// {
-// Rule rule = new PutAttributesRule(digestr,new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
-// digestr.addRule(pattern,rule);
-// }
- {
- SetPropertiesRule rule = new SetPropertiesRule(new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new
String[]{"value","property","skin","context"});
- digestr.addRule(pattern,rule);
- }
-
-
-
- // style(sheet) property <u:style>
- pattern = ANY_PARENT+NS_UTIL_PREFIX+STYLE_TAG;
- digestr.addObjectCreate(pattern,ClassElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- // breakpoint <f:break name="name">
- pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILD_TAG;
- digestr.addObjectCreate(pattern,ChildElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
-
- //Selector element <u:selector></u:selector>
- pattern = ANY_PARENT+NS_UTIL_PREFIX+SELECTOR_TAG;
- digestr.addObjectCreate(pattern,SelectorElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- }
-
-
- /**
- * Compile template for XML from simple string.
- * @param xml - String with template code
- * @return compiled template, ready for rendering.
- */
- public PreparedTemplate compile(String xml){
- Reader input = new StringReader(xml);
- return compile(input);
- }
-
- /**
- * Compile set of templates at time. Templates gets from resources in
- * classpath relative to base class. Used for initialisation set of templates in {@link
RendererBase} subclasses constructor
- * @param base - base class for resources paths
- * @param templates - array with templates names.
- * @return {@link Map } , with keys - templates name, value - compiled template.
- */
- public Map compileResources(Class base,String[] templates) {
- Map result = new HashMap(templates.length);
- for (int i = 0; i < templates.length; i++) {
- String template = templates[i];
- result.put(template,compileResource(base,template));
- }
- return result;
- }
- /**
- * Compile XML from resource in classpath. Resource always readed
- * as UTF-8 text , to avoid xml declarations.
- * @param base - class of base object.
- * @param resource - path to resource ( if not start with / , relative to base object )
- * @return compiled XML, or Exception-generated stub, if parsing error occurs.
- */
- public static PreparedTemplate compileResource(Class base, String resource) {
- String path;
- if (resource.startsWith("/")) {
- path = base.getPackage().getName().replace('.','/')+resource;
- } else {
- path =
base.getPackage().getName().replace('.','/')+"/"+resource;
- }
- return compileResource(path);
- }
-
-
- /**
- * Compile XML from resource in classpath. Resource always readed
- * as UTF-8 text , to avoid xml declarations.
- * @param resource - absolute path to resource
- * @return compiled XML, or Exception-generated stub, if parsing error occurs.
- */
- public static PreparedTemplate compileResource(String resource) {
- HtmlCompiler compiler = new HtmlCompiler();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InputStream input = loader.getResourceAsStream(resource);
- // Since parsing exceptions handled by compiler, we can not check parameter.
- PreparedTemplate compile = compiler.compile(input, resource);
- if(null != input){
- try {
- input.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- return compile;
- }
-
- public PreparedTemplate compile(Reader input){
- // By default - empty result. we not throw any exceptions in compile phase -
- // since it can be in static class initialization.
- PreparedTemplate result = null;
- try {
- digestr.clear();
- digestr.push(new RootElement());
- result = (PreparedTemplate) digestr.parse(input);
- } catch (SAXParseException e) {
-// TODO - locate compilation error. How get name ?
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR, new
Object[]{"" + e.getLineNumber(), "" + e.getColumnNumber(),
e.toString()});
-// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and
position ").append(digestr.getDocumentLocator().getColumnNumber());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (IOException e) {
- String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR, e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (SAXException e) {
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2,
e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- }
- return result;
- }
-
- /**
- * Compile input {@link InputStream} to {@link PreparedTemplate} - set of Java classes
to encode as JSF output.
- * @param input stream with template XML text.
- * @param sourcename ( optional ) name of resource, for debug purposes.
- * @return compiled template.
- */
- public PreparedTemplate compile(InputStream input, String sourcename){
- // By default - empty result. we not throw any exceptions in compile phase -
- // since it can be in static class initialization.
- PreparedTemplate result = null;
- try {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.START_COMPILE_TEMPLATE_INFO, sourcename));
- }
- digestr.clear();
- RootElement root = new RootElement();
- root.setTemplateName(sourcename);
- digestr.push(root);
- result = (PreparedTemplate) digestr.parse(input);
- } catch (SAXParseException e) {
-// TODO - locate compilation error. How get name ?
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_a, new
Object[]{sourcename, "" + e.getLineNumber(), "" + e.getColumnNumber(),
e.toString()});
-// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and
position ").append(digestr.getDocumentLocator().getColumnNumber());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (IOException e) {
- String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR_a, sourcename,
e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (SAXException e) {
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2a, sourcename,
e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.FINISH_COMPILE_TEMPLATE_INFO, sourcename));
- }
- return result;
- }
-
- /**
- * Incapsulate parsing - compilation errors to throw at encoding.
- * Allow static / constructor initialisation, all errors will be
- * see in page at request time. For debugging purposes.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
- private static class CompiledError implements PreparedTemplate {
- private Exception cause = null;
- private String message = Messages.getMessage(Messages.TEMPLATE_NOT_COMPILED_ERROR);
-
- /**
- * @param cause
- * @param message
- */
- public CompiledError(String message,Exception cause) {
- super();
- this.cause = cause;
- this.message = message;
- }
-
- /**
- * @param cause
- */
- CompiledError(Exception cause) {
- this.cause = cause;
- }
-
- public void encode(RendererBase renderer, FacesContext context, UIComponent component)
throws IOException {
- // TODO - concrete compilation error.
- throw new FacesException(message,cause);
- }
-
- public List getChildren() {
- return Collections.EMPTY_LIST;
- }
-
- public void addChild(PreparedTemplate child) throws SAXException {
- // DO Nothing.
- throw new SAXException(Messages.getMessage(Messages.NO_CHILD_ALLOWED));
- }
-
- public void encode(TemplateContext context) throws IOException {
- throw new FacesException(message,cause);
-
- }
-
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- throw new FacesException(message,cause);
-
- }
-
- public void setParent(PreparedTemplate parent) {
- // DO Nothing.
- }
-
- public String getTag() {
- // TODO Auto-generated method stub
- return "f:error";
- }
-
- public Object getValue(TemplateContext context) {
- // error don't have value
- return null;
- }
-
- };
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,422 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.apache.commons.digester.RulesBase;
+import org.apache.commons.digester.SetNextRule;
+import org.apache.commons.digester.SetPropertiesRule;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.LocatorImpl;
+
+
+/**
+ * Compiler for XML string or stream for creation of {@link javax.faces.render.Renderer}
internal
+ * interpretator. Use Apache Digitester for parse .
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+public class HtmlCompiler {
+
+ public static final String NS_PREFIX = "f:";
+ public static final String NS_UTIL_PREFIX = "u:";
+ public static final String ROOT_TAG = "template";
+ public static final String CALL_TAG = "call";
+ public static final String VALUE_CALL_TAG = "valueCall";
+ public static final String CALL_PARAM_TAG = "parameter";
+ public static final String VERBATUM_TAG = "verbatim";
+ public static final String BREAK_TAG = "break";
+ public static final String FACET_TAG = "insertFacet";
+ public static final String CHILDREN_TAG = "insertChildren";
+ public static final String IF_TAG = "if";
+ public static final String CHILD_TAG = "insertChild";
+ public static final String STYLE_TAG = "style";
+ public static final String CHILD_METHOD = "addChild";
+ public static final String RESOURCE_TAG = "resource";
+ public static final String ATTRIBUTE_TAG = "attribute";
+ public static final String CHILD_PARAM_METHOD = "addParameter";
+ public static final String ANY_PARENT = "*/";
+ public static final String SELECTOR_TAG = "selector";
+
+
+ private static final Log log = LogFactory.getLog(HtmlCompiler.class);
+
+ private Digester digestr = new Digester();
+
+
+ /**
+ * Constructor with initialisation.
+ */
+ public HtmlCompiler(){
+ WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new RulesBase());
+ // Add default rules to process plain tags.
+ rules.addDefault(new PlainElementCreateRule());
+ rules.addDefault(new SetNextRule(CHILD_METHOD));
+ digestr.setDocumentLocator(new LocatorImpl());
+ digestr.setRules(rules);
+ digestr.setValidating(false);
+ digestr.setNamespaceAware(false);
+ digestr.setUseContextClassLoader(true);
+ // Concrete renderer method call rules.
+ setCustomRules(digestr);
+ }
+
+ /**
+ * Build custom rules for parse special tags and attributes.
+ * For most tags, value can be in next forms ( for resource, preffixed with f: ):
+ * <ul>
+ * <li><b>value</b> as string or EL-expression</li>
+ * <li><b>property</b> name for property of current
component</li>
+ * <li><b>skin</b> name for property of current skin</li>
+ * <li><b>context</b> name for property of {@link TemplateContext} for
trmplate encoding</li>
+ * <li><b>default</b> use as value if main property
<code>null</code></li>
+ * </ul>
+ * Supported :
+ * <ul>
+ * <li>Call renderer or utils method <f:call name='xxx'
/></li>
+ * <li>Call method parameter <f:parameter name='xxx'
(value='....' | property='style' | skin='paramName' |
context='propertyName ) /></li>
+ * <li>Encode plain text <f:verbatim [value='....' |
property='style' | skin='paramName' | context='propertyName ]
>Some Text</f:text></li>
+ * <li>Encode as text in HTML CSS parameter format <u:style
name='background' (value='....' | property='style' |
skin='paramName' | context='propertyName )/></li>
+ * <li>Get and encode resource <f:resource
f:key='images/spacer.gif' [ ... any attributes ... ] /></li>
+ * <li>Encode custom attribute <f:attribute name='style'
(value='....' | property='style' | skin='paramName' |
context='propertyName ) [endorsed='true'] /></li>
+ * <li>Template breakpoint <f:break name='xxxxx'
/></li>
+ * <li>Encode named facet <u:facet ( name='head |
property='style' | skin='paramName' | context='propertyName )'
/></li>
+ * <li>Encode children components for current <u:children
/></li>
+ * <li>Encode one child component for enclosed u:facet or u:children
<u:child /'></li>
+ * </ul>
+ * @param digestr
+ */
+ protected void setCustomRules( Digester digestr){
+ // Root element. not instantiate - already set by compile method.
+ String pattern = NS_PREFIX+ROOT_TAG;
+ digestr.addSetProperties(pattern);
+ // call renderer method <f:call methodName='xxx' [methodParam='yyy']
/>
+ pattern = ANY_PARENT+NS_PREFIX+CALL_TAG;
+ digestr.addObjectCreate(pattern,MethodCallElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ // for value of parent call renderer method <f:valueCall methodName='xxx'
[methodParam='yyy'] />
+ pattern = ANY_PARENT+NS_PREFIX+VALUE_CALL_TAG;
+ digestr.addObjectCreate(pattern,ValueMethodCallElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ // call parameter <f:parapeter methodName='xxx' [methodParam='yyy']
/>
+// pattern = ANY_PARENT+NS_PREFIX+CALL_TAG+"/"+NS_PREFIX+CALL_PARAM_TAG;
+ pattern = ANY_PARENT+NS_PREFIX+CALL_PARAM_TAG;
+ digestr.addObjectCreate(pattern,MethodParameterElement.class);
+ digestr.addSetNext(pattern,CHILD_PARAM_METHOD);
+ digestr.addSetProperties(pattern);
+ // Encode plain text <f:text>Some Text</f:text>
+ pattern = ANY_PARENT+NS_PREFIX+VERBATUM_TAG;
+ digestr.addObjectCreate(pattern,TextElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ digestr.addBeanPropertySetter(pattern,"text");
+ // resource <f:resource f:key='images/spacer.gif' [f:data='...'] [
... any attributes ... ] />
+ pattern =ANY_PARENT+NS_PREFIX+RESOURCE_TAG;
+ digestr.addObjectCreate(pattern,ResourceElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ {
+ Rule rule = new PutAttributesRule(digestr,new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
+ digestr.addRule(pattern,rule);
+ }
+ {
+ SetPropertiesRule rule = new SetPropertiesRule(new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new
String[]{"value","property","skin","context"});
+ digestr.addRule(pattern,rule);
+ }
+ // custom attribute <f:attribute name='style' (value='....' |
property='style' | skin='paramName' | call='methodName' |
utilCall='methodName') [notNull='true'] />
+ pattern = ANY_PARENT+NS_PREFIX+ATTRIBUTE_TAG;
+ digestr.addObjectCreate(pattern,AttributeElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ // component clientId <f:id [f:required='true'] />
+ // breakpoint <f:break name="name">
+ pattern = ANY_PARENT+NS_PREFIX+BREAK_TAG;
+ digestr.addObjectCreate(pattern,BreakPoint.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ // conditional rendering <f:if then="true">
+ pattern = ANY_PARENT+NS_PREFIX+IF_TAG;
+ digestr.addObjectCreate(pattern,IfElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ // facet <u:insertFacet name="name">
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+FACET_TAG;
+ digestr.addObjectCreate(pattern,FacetElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+
+ // childrens <u:insertChildren>
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILDREN_TAG;
+ digestr.addObjectCreate(pattern,ChildrensElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+// {
+// Rule rule = new PutAttributesRule(digestr,new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
+// digestr.addRule(pattern,rule);
+// }
+ {
+ SetPropertiesRule rule = new SetPropertiesRule(new
String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new
String[]{"value","property","skin","context"});
+ digestr.addRule(pattern,rule);
+ }
+
+
+
+ // style(sheet) property <u:style>
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+STYLE_TAG;
+ digestr.addObjectCreate(pattern,ClassElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ // breakpoint <f:break name="name">
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILD_TAG;
+ digestr.addObjectCreate(pattern,ChildElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+
+ //Selector element <u:selector></u:selector>
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+SELECTOR_TAG;
+ digestr.addObjectCreate(pattern,SelectorElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ }
+
+
+ /**
+ * Compile template for XML from simple string.
+ * @param xml - String with template code
+ * @return compiled template, ready for rendering.
+ */
+ public PreparedTemplate compile(String xml){
+ Reader input = new StringReader(xml);
+ return compile(input);
+ }
+
+ /**
+ * Compile set of templates at time. Templates gets from resources in
+ * classpath relative to base class. Used for initialisation set of templates in {@link
RendererBase} subclasses constructor
+ * @param base - base class for resources paths
+ * @param templates - array with templates names.
+ * @return {@link Map } , with keys - templates name, value - compiled template.
+ */
+ public Map compileResources(Class base,String[] templates) {
+ Map result = new HashMap(templates.length);
+ for (int i = 0; i < templates.length; i++) {
+ String template = templates[i];
+ result.put(template,compileResource(base,template));
+ }
+ return result;
+ }
+ /**
+ * Compile XML from resource in classpath. Resource always readed
+ * as UTF-8 text , to avoid xml declarations.
+ * @param base - class of base object.
+ * @param resource - path to resource ( if not start with / , relative to base object )
+ * @return compiled XML, or Exception-generated stub, if parsing error occurs.
+ */
+ public static PreparedTemplate compileResource(Class base, String resource) {
+ String path;
+ if (resource.startsWith("/")) {
+ path = base.getPackage().getName().replace('.','/')+resource;
+ } else {
+ path =
base.getPackage().getName().replace('.','/')+"/"+resource;
+ }
+ return compileResource(path);
+ }
+
+
+ /**
+ * Compile XML from resource in classpath. Resource always readed
+ * as UTF-8 text , to avoid xml declarations.
+ * @param resource - absolute path to resource
+ * @return compiled XML, or Exception-generated stub, if parsing error occurs.
+ */
+ public static PreparedTemplate compileResource(String resource) {
+ HtmlCompiler compiler = new HtmlCompiler();
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream input = loader.getResourceAsStream(resource);
+ // Since parsing exceptions handled by compiler, we can not check parameter.
+ PreparedTemplate compile = compiler.compile(input, resource);
+ if(null != input){
+ try {
+ input.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ return compile;
+ }
+
+ public PreparedTemplate compile(Reader input){
+ // By default - empty result. we not throw any exceptions in compile phase -
+ // since it can be in static class initialization.
+ PreparedTemplate result = null;
+ try {
+ digestr.clear();
+ digestr.push(new RootElement());
+ result = (PreparedTemplate) digestr.parse(input);
+ } catch (SAXParseException e) {
+// TODO - locate compilation error. How get name ?
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR, new
Object[]{"" + e.getLineNumber(), "" + e.getColumnNumber(),
e.toString()});
+// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and
position ").append(digestr.getDocumentLocator().getColumnNumber());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (IOException e) {
+ String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR, e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (SAXException e) {
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2,
e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ }
+ return result;
+ }
+
+ /**
+ * Compile input {@link InputStream} to {@link PreparedTemplate} - set of Java classes
to encode as JSF output.
+ * @param input stream with template XML text.
+ * @param sourcename ( optional ) name of resource, for debug purposes.
+ * @return compiled template.
+ */
+ public PreparedTemplate compile(InputStream input, String sourcename){
+ // By default - empty result. we not throw any exceptions in compile phase -
+ // since it can be in static class initialization.
+ PreparedTemplate result = null;
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.START_COMPILE_TEMPLATE_INFO, sourcename));
+ }
+ digestr.clear();
+ RootElement root = new RootElement();
+ root.setTemplateName(sourcename);
+ digestr.push(root);
+ result = (PreparedTemplate) digestr.parse(input);
+ } catch (SAXParseException e) {
+// TODO - locate compilation error. How get name ?
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_a, new
Object[]{sourcename, "" + e.getLineNumber(), "" + e.getColumnNumber(),
e.toString()});
+// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and
position ").append(digestr.getDocumentLocator().getColumnNumber());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (IOException e) {
+ String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR_a, sourcename,
e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (SAXException e) {
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2a, sourcename,
e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.FINISH_COMPILE_TEMPLATE_INFO, sourcename));
+ }
+ return result;
+ }
+
+ /**
+ * Incapsulate parsing - compilation errors to throw at encoding.
+ * Allow static / constructor initialisation, all errors will be
+ * see in page at request time. For debugging purposes.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+ private static class CompiledError implements PreparedTemplate {
+ private Exception cause = null;
+ private String message = Messages.getMessage(Messages.TEMPLATE_NOT_COMPILED_ERROR);
+
+ /**
+ * @param cause
+ * @param message
+ */
+ public CompiledError(String message,Exception cause) {
+ super();
+ this.cause = cause;
+ this.message = message;
+ }
+
+ /**
+ * @param cause
+ */
+ CompiledError(Exception cause) {
+ this.cause = cause;
+ }
+
+ public void encode(RendererBase renderer, FacesContext context, UIComponent component)
throws IOException {
+ // TODO - concrete compilation error.
+ throw new FacesException(message,cause);
+ }
+
+ public List getChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public void addChild(PreparedTemplate child) throws SAXException {
+ // DO Nothing.
+ throw new SAXException(Messages.getMessage(Messages.NO_CHILD_ALLOWED));
+ }
+
+ public void encode(TemplateContext context) throws IOException {
+ throw new FacesException(message,cause);
+
+ }
+
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ throw new FacesException(message,cause);
+
+ }
+
+ public void setParent(PreparedTemplate parent) {
+ // DO Nothing.
+ }
+
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return "f:error";
+ }
+
+ public Object getValue(TemplateContext context) {
+ // error don't have value
+ return null;
+ }
+
+ };
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/IfElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
- *
- */
-public class IfElement extends ElementBase {
-
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // Condition will not contain breakpoints.
- encode(context);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- Object condition = getValue(context);
- if (null != condition) {
- if ( (!(condition instanceof Boolean)) || ((Boolean)condition).booleanValue()) {
- super.encode(context);
- }
- }
- }
-
- public void setWhen(String condition){
- setValue(condition);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.IF_TAG;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/IfElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
+ *
+ */
+public class IfElement extends ElementBase {
+
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // Condition will not contain breakpoints.
+ encode(context);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ Object condition = getValue(context);
+ if (null != condition) {
+ if ( (!(condition instanceof Boolean)) || ((Boolean)condition).booleanValue()) {
+ super.encode(context);
+ }
+ }
+ }
+
+ public void setWhen(String condition){
+ setValue(condition);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.IF_TAG;
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodCallElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,505 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.el.MethodNotFoundException;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
- *
- */
-public class MethodCallElement extends ElementBase {
-
- public static final String UTILS_PREFIX = "utils.";
-
- static final Log _log = LogFactory.getLog(MethodCallElement.class);
-
- private String _name = null;
-
- private List parameters = new ArrayList();
-
- private Invoker invoker = new Invoker();
-
- private MethodCacheState state = new MethodCacheState();
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(TemplateContext context ) throws IOException {
- getValue(context);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // Text not contain breakpoints.
- encode(context);
- }
-
-
- public Object getValue(TemplateContext context) throws FacesException {
- // prepare method params. we attempt to call 3 signatures :
- // a) name(FacesContext,UIComponent [, param0...])
- // b) name(TempalateContext [,param0...])
- // c) name([param0...])
- state.init(parameters);
- Object[] values = state.computeParameterValues(context);
-
- InvokeData data = null;
- synchronized (state) {
- state.update(context, values, invoker);
- data = invoker.invokeMethod(context, state);
- }
- return invoker.invokeMethod(data);
- // perform childrens.
- // super.encode(renderer,context,component);
- }
-
-
-
- public void addParameter(MethodParameterElement parameter){
- parameters.add(parameter);
- }
- /**
- * @return Returns the methodName.
- */
- public String getName() {
- return _name;
- }
-
- /**
- * @param methodName The methodName to set.
- */
- public void setName(String methodName) {
- if(methodName.startsWith(UTILS_PREFIX)){
- this._name = methodName.substring(UTILS_PREFIX.length());
- this.invoker = getRendererUtilsInvoker(_name);
- } else if(methodName.indexOf('.') >= 0) {
- this._name = methodName;
- this.invoker = getStaticInvoker(_name);
- } else {
- this._name = methodName;
- this.invoker = getRendererInvoker(_name);
- }
- }
-
- static Map staticInvokers = new HashMap();
-
- public StaticInvoker getStaticInvoker(String methodName) {
- StaticInvoker invoker = (StaticInvoker)staticInvokers.get(methodName);
- if(invoker == null) {
- invoker = new StaticInvoker(methodName);
- staticInvokers.put(methodName, invoker);
- }
- return invoker;
- }
-
- static Map rendererInvokers = new HashMap();
-
- public RendererInvoker getRendererInvoker(String methodName) {
- RendererInvoker invoker = (RendererInvoker)rendererInvokers.get(methodName);
- if(invoker == null) {
- invoker = new RendererInvoker(false, methodName);
- rendererInvokers.put(methodName, invoker);
- }
- return invoker;
- }
-
- static Map utilsInvokers = new HashMap();
-
- public RendererInvoker getRendererUtilsInvoker(String methodName) {
- RendererInvoker invoker = (RendererInvoker)utilsInvokers.get(methodName);
- if(invoker == null) {
- invoker = new RendererInvoker(true, methodName);
- utilsInvokers.put(methodName, invoker);
- }
- return invoker;
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_TAG;
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
- }
- }
-
-
-/* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public String getString(TemplateContext context) throws FacesException {
- Object result = getValue(context);
- if (null == result || result.toString().length()==0) {
- result = "";
- }
- return result.toString();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- MethodParameterElement.class,
- ResourceElement.class
- };
- }
-
-}
-
-class InvokeData {
- TemplateContext context;
- Method method;
- Object object;
- Object[] arguments;
- InvokeData(TemplateContext context, Method method, Object object, Object[] arguments) {
- this.context = context;
- this.method = method;
- this.object = object;
- this.arguments = (Object[]) arguments.clone();
- }
-}
-
-class Invoker {
- String methodName;
-
- InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
- throw new FacesException(Messages.getMessage(Messages.RENDERER_METHOD_NOT_SET_ERROR));
- }
-
- void handleInvocationTargetException(TemplateContext context, InvocationTargetException
e) {}
- void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {}
- void handleMethodNotFoundException(TemplateContext context) throws
MethodNotFoundException {}
-
- InvokeData invokeMethod(TemplateContext context, Map methods, Class cls, Object object,
MethodCacheState state) {
- Method method = provideMethod(methods, cls, object, state);
- return new InvokeData(context, method, object, state.current.arguments);
- }
-
- Object invokeMethod(InvokeData data) {
- if(data.method != null) {
- try {
- return data.method.invoke(data.object, data.arguments);
- } catch (InvocationTargetException e) {
- handleInvocationTargetException(data.context, e);
- } catch (IllegalAccessException e) {
- handleIllegalAccessException(data.context, e);
- }
- }
- handleMethodNotFoundException(data.context);
- return null;
- }
-
- public Class getInvokedClass(TemplateContext context) {
- return null;
- }
-
- private Method provideMethod(Map methods, Class cls, Object object, MethodCacheState
state) {
- if(state.method != null) return state.method;
-
- if(methods.size() > 0) {
- for (int i = 0; i < state.signatures.length; i++) {
- state.method = (Method)methods.get(getClassesKey(state.signatures[i].arguments));
- if(state.method != null) {
- state.current = state.signatures[i];
- return state.method;
- }
- }
- }
-
- if(cls == null && object != null) cls = object.getClass();
- Method[] ms = cls.getMethods();
- for (int m = 0; m < ms.length; m++) {
- if(!ms[m].getName().equals(methodName)) continue;
- if(object == null && !Modifier.isStatic(ms[m].getModifiers())) continue;
- Class[] cs = ms[m].getParameterTypes();
- Signature s = getMatchingArguments(cs, state.signatures);
- if(s == null) continue;
- state.current = s;
- state.method = ms[m];
- methods.put(getClassesKey(s.arguments), ms[m]);
- return state.method;
- }
-
- return null;
- }
-
- private String getClassesKey(Object[] args) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; i++) {
- String dk = args[i] == null ? "null" : args[i].getClass().getName();
- sb.append(";").append(dk);
- }
- return sb.toString();
- }
-
- private Signature getMatchingArguments(Class[] cs, Signature[] sgs) {
- for (int i = 0; i < sgs.length; i++) {
- if(isMatching(cs, sgs[i].arguments)) return sgs[i];
- }
- return null;
- }
-
- static boolean isMatching(Class[] cs, Object[] args) {
- if(cs.length != args.length) return false;
- for (int i = 0; i < cs.length; i++) {
- if(args[i] != null && !cs[i].isAssignableFrom(args[i].getClass())) return
false;
- }
- return true;
- }
-}
-
-class RendererInvoker extends Invoker {
- boolean utils = false;
- Map renderers = new HashMap();
-
- public RendererInvoker(boolean utils, String methodName) {
- this.utils = utils;
- this.methodName = methodName;
- }
-
- public Class getInvokedClass(TemplateContext context) {
- Object object = getInvokedObject(context);
- return (object != null) ? object.getClass() : null;
- }
-
- private Object getInvokedObject(TemplateContext context) {
- if(utils) {
- return context.getRenderer().getUtils();
- } else {
- return context.getRenderer();
- }
- }
-
- InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
- Object object = getInvokedObject(context);
- Map methods = getMethods(object);
- return invokeMethod(context, methods, null, object, state);
- }
-
- private Map getMethods(Object object) {
- if(object == null) return null;
- Map methods = (Map)renderers.get(object);
- if(methods == null) {
- methods = new HashMap();
- renderers.put(object, methods);
- }
- return methods;
- }
-
- void handleInvocationTargetException(TemplateContext context, InvocationTargetException
e) {
- String logMessage = (utils)
- ? Messages.getMessage(Messages.METHOD_CALL_ERROR_1, methodName,
context.getComponent().getId())
- : Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName,
context.getComponent().getId());
- String excMessage = (utils)
- ? Messages.getMessage(Messages.METHOD_CALL_ERROR_2, new Object[]{methodName,
context.getComponent().getId(), e.getCause().getMessage()})
- : Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[]{methodName,
context.getComponent().getId(), e.getCause().getMessage()});
- MethodCallElement._log.error(logMessage, e);
- throw new FacesException(excMessage, e);
- }
- void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
- String logMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3, methodName,
context.getComponent().getId()))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName,
context.getComponent().getId()));
- String excMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}));
- MethodCallElement._log.error(logMessage, e);
- throw new FacesException(excMessage, e);
- }
-
- void handleMethodNotFoundException(TemplateContext context) throws
MethodNotFoundException {
- String logMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5, methodName,
context.getComponent().getId()))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a, methodName,
context.getComponent().getId()));
- String excMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6, methodName))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a,
methodName));
- MethodCallElement._log.error(logMessage);
- throw new FacesException(excMessage);
- }
-}
-
-class StaticInvoker extends Invoker {
- String className;
- Class cls;
- Map methods = new HashMap();
-
- StaticInvoker(String methodName) {
- this.methodName = methodName;
- int i = methodName.lastIndexOf('.');
- className = methodName.substring(0, i);
- this.methodName = methodName.substring(i + 1);
- try {
- cls = Thread.currentThread().getContextClassLoader().loadClass(className);
- } catch (ClassNotFoundException e) {
- //ignore, throw exception when invoking
- }
- }
-
- InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
- if(cls == null) throw new FacesException(className, new
ClassNotFoundException(className));
- return invokeMethod(context, methods, cls, null, state);
- }
-
- void handleInvocationTargetException(TemplateContext context, InvocationTargetException
e) {
- MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_1a,
methodName, context.getComponent().getId()), e);
- throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
- }
- void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
- MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a,
methodName, context.getComponent().getId()), e);
- throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
- }
- void handleMethodNotFoundException(TemplateContext context) throws
MethodNotFoundException {
- MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a,
methodName, context.getComponent().getId()));
- throw new MethodNotFoundException(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a,
methodName));
- }
-}
-
-class MethodCacheState {
- private MethodParameterElement[] elements;
- private Class[] parameterClasses;
- private Object[] parameterValues;
- private Class lastCallingClass = null;
- public Method method;
- public Signature current;
- public Signature[] signatures;
-
- public void init(List parameters) {
- if(elements != null) return;
- synchronized (this) {
- if(elements != null) return;
- int size = parameters.size();
- parameterClasses = new Class[size];
- parameterValues = new Object[size];
- signatures = new Signature[3];
- signatures[0] = new Signature2(size);
- signatures[1] = new Signature1(size);
- signatures[2] = new Signature0(size);
- elements = (MethodParameterElement[])parameters.toArray(new
MethodParameterElement[0]);
- }
- }
-
- public Object[] computeParameterValues(TemplateContext context) {
- Object[] ps = new Object[elements.length];
- for (int i = 0; i < elements.length; i++) {
- ps[i] = elements[i].valueGetter.getValueOrDefault(context);
- }
- return ps;
- }
-
- public void update(TemplateContext context, Object[] values, Invoker invoker) {
- boolean changed = false;
- for (int i = 0; i < elements.length; i++) {
- Object parametr = values[i];
- Class c = (parametr == null) ? null : parametr.getClass();
- if(c != parameterClasses[i]) {
- parameterClasses[i] = c;
- changed = true;
- }
- parameterValues[i] = parametr;
- }
- if(method != null && !changed && lastCallingClass !=
invoker.getInvokedClass(context)) {
- lastCallingClass = invoker.getInvokedClass(context);
- changed = true;
- }
- if(changed || current == null) {
- for (int i = 0; i < signatures.length; i++) {
- signatures[i].update(context, parameterValues);
- }
- method = null;
- current = null;
- } else {
- current.update(context, parameterValues);
- }
- }
-
-}
-
-abstract class Signature {
- Object[] arguments;
-
- Signature() {}
-
- void update(TemplateContext context, Object[] parameters) {}
-}
-
-class Signature0 extends Signature {
- Signature0(int size) {
- arguments = new Object[size];
- }
-
- void update(TemplateContext context, Object[] parameters) {
- System.arraycopy(parameters, 0, arguments, 0, parameters.length);
- }
-
-}
-
-class Signature1 extends Signature {
- Signature1(int size) {
- arguments = new Object[size + 1];
- }
- void update(TemplateContext context, Object[] parameters) {
- arguments[0] = context;
- System.arraycopy(parameters, 0, arguments, 1, parameters.length);
- }
-
-}
-
-class Signature2 extends Signature {
- Signature2(int size) {
- arguments = new Object[size + 2];
- }
- void update(TemplateContext context, Object[] parameters) {
- arguments[0] = context.getFacesContext();
- arguments[1] = context.getComponent();
- System.arraycopy(parameters, 0, arguments, 2, parameters.length);
- }
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodCallElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,505 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.el.MethodNotFoundException;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
+ *
+ */
+public class MethodCallElement extends ElementBase {
+
+ public static final String UTILS_PREFIX = "utils.";
+
+ static final Log _log = LogFactory.getLog(MethodCallElement.class);
+
+ private String _name = null;
+
+ private List parameters = new ArrayList();
+
+ private Invoker invoker = new Invoker();
+
+ private MethodCacheState state = new MethodCacheState();
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(TemplateContext context ) throws IOException {
+ getValue(context);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // Text not contain breakpoints.
+ encode(context);
+ }
+
+
+ public Object getValue(TemplateContext context) throws FacesException {
+ // prepare method params. we attempt to call 3 signatures :
+ // a) name(FacesContext,UIComponent [, param0...])
+ // b) name(TempalateContext [,param0...])
+ // c) name([param0...])
+ state.init(parameters);
+ Object[] values = state.computeParameterValues(context);
+
+ InvokeData data = null;
+ synchronized (state) {
+ state.update(context, values, invoker);
+ data = invoker.invokeMethod(context, state);
+ }
+ return invoker.invokeMethod(data);
+ // perform childrens.
+ // super.encode(renderer,context,component);
+ }
+
+
+
+ public void addParameter(MethodParameterElement parameter){
+ parameters.add(parameter);
+ }
+ /**
+ * @return Returns the methodName.
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @param methodName The methodName to set.
+ */
+ public void setName(String methodName) {
+ if(methodName.startsWith(UTILS_PREFIX)){
+ this._name = methodName.substring(UTILS_PREFIX.length());
+ this.invoker = getRendererUtilsInvoker(_name);
+ } else if(methodName.indexOf('.') >= 0) {
+ this._name = methodName;
+ this.invoker = getStaticInvoker(_name);
+ } else {
+ this._name = methodName;
+ this.invoker = getRendererInvoker(_name);
+ }
+ }
+
+ static Map staticInvokers = new HashMap();
+
+ public StaticInvoker getStaticInvoker(String methodName) {
+ StaticInvoker invoker = (StaticInvoker)staticInvokers.get(methodName);
+ if(invoker == null) {
+ invoker = new StaticInvoker(methodName);
+ staticInvokers.put(methodName, invoker);
+ }
+ return invoker;
+ }
+
+ static Map rendererInvokers = new HashMap();
+
+ public RendererInvoker getRendererInvoker(String methodName) {
+ RendererInvoker invoker = (RendererInvoker)rendererInvokers.get(methodName);
+ if(invoker == null) {
+ invoker = new RendererInvoker(false, methodName);
+ rendererInvokers.put(methodName, invoker);
+ }
+ return invoker;
+ }
+
+ static Map utilsInvokers = new HashMap();
+
+ public RendererInvoker getRendererUtilsInvoker(String methodName) {
+ RendererInvoker invoker = (RendererInvoker)utilsInvokers.get(methodName);
+ if(invoker == null) {
+ invoker = new RendererInvoker(true, methodName);
+ utilsInvokers.put(methodName, invoker);
+ }
+ return invoker;
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_TAG;
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
+ }
+ }
+
+
+/* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+ Object result = getValue(context);
+ if (null == result || result.toString().length()==0) {
+ result = "";
+ }
+ return result.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ MethodParameterElement.class,
+ ResourceElement.class
+ };
+ }
+
+}
+
+class InvokeData {
+ TemplateContext context;
+ Method method;
+ Object object;
+ Object[] arguments;
+ InvokeData(TemplateContext context, Method method, Object object, Object[] arguments) {
+ this.context = context;
+ this.method = method;
+ this.object = object;
+ this.arguments = (Object[]) arguments.clone();
+ }
+}
+
+class Invoker {
+ String methodName;
+
+ InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
+ throw new FacesException(Messages.getMessage(Messages.RENDERER_METHOD_NOT_SET_ERROR));
+ }
+
+ void handleInvocationTargetException(TemplateContext context, InvocationTargetException
e) {}
+ void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {}
+ void handleMethodNotFoundException(TemplateContext context) throws
MethodNotFoundException {}
+
+ InvokeData invokeMethod(TemplateContext context, Map methods, Class cls, Object object,
MethodCacheState state) {
+ Method method = provideMethod(methods, cls, object, state);
+ return new InvokeData(context, method, object, state.current.arguments);
+ }
+
+ Object invokeMethod(InvokeData data) {
+ if(data.method != null) {
+ try {
+ return data.method.invoke(data.object, data.arguments);
+ } catch (InvocationTargetException e) {
+ handleInvocationTargetException(data.context, e);
+ } catch (IllegalAccessException e) {
+ handleIllegalAccessException(data.context, e);
+ }
+ }
+ handleMethodNotFoundException(data.context);
+ return null;
+ }
+
+ public Class getInvokedClass(TemplateContext context) {
+ return null;
+ }
+
+ private Method provideMethod(Map methods, Class cls, Object object, MethodCacheState
state) {
+ if(state.method != null) return state.method;
+
+ if(methods.size() > 0) {
+ for (int i = 0; i < state.signatures.length; i++) {
+ state.method = (Method)methods.get(getClassesKey(state.signatures[i].arguments));
+ if(state.method != null) {
+ state.current = state.signatures[i];
+ return state.method;
+ }
+ }
+ }
+
+ if(cls == null && object != null) cls = object.getClass();
+ Method[] ms = cls.getMethods();
+ for (int m = 0; m < ms.length; m++) {
+ if(!ms[m].getName().equals(methodName)) continue;
+ if(object == null && !Modifier.isStatic(ms[m].getModifiers())) continue;
+ Class[] cs = ms[m].getParameterTypes();
+ Signature s = getMatchingArguments(cs, state.signatures);
+ if(s == null) continue;
+ state.current = s;
+ state.method = ms[m];
+ methods.put(getClassesKey(s.arguments), ms[m]);
+ return state.method;
+ }
+
+ return null;
+ }
+
+ private String getClassesKey(Object[] args) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < args.length; i++) {
+ String dk = args[i] == null ? "null" : args[i].getClass().getName();
+ sb.append(";").append(dk);
+ }
+ return sb.toString();
+ }
+
+ private Signature getMatchingArguments(Class[] cs, Signature[] sgs) {
+ for (int i = 0; i < sgs.length; i++) {
+ if(isMatching(cs, sgs[i].arguments)) return sgs[i];
+ }
+ return null;
+ }
+
+ static boolean isMatching(Class[] cs, Object[] args) {
+ if(cs.length != args.length) return false;
+ for (int i = 0; i < cs.length; i++) {
+ if(args[i] != null && !cs[i].isAssignableFrom(args[i].getClass())) return
false;
+ }
+ return true;
+ }
+}
+
+class RendererInvoker extends Invoker {
+ boolean utils = false;
+ Map renderers = new HashMap();
+
+ public RendererInvoker(boolean utils, String methodName) {
+ this.utils = utils;
+ this.methodName = methodName;
+ }
+
+ public Class getInvokedClass(TemplateContext context) {
+ Object object = getInvokedObject(context);
+ return (object != null) ? object.getClass() : null;
+ }
+
+ private Object getInvokedObject(TemplateContext context) {
+ if(utils) {
+ return context.getRenderer().getUtils();
+ } else {
+ return context.getRenderer();
+ }
+ }
+
+ InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
+ Object object = getInvokedObject(context);
+ Map methods = getMethods(object);
+ return invokeMethod(context, methods, null, object, state);
+ }
+
+ private Map getMethods(Object object) {
+ if(object == null) return null;
+ Map methods = (Map)renderers.get(object);
+ if(methods == null) {
+ methods = new HashMap();
+ renderers.put(object, methods);
+ }
+ return methods;
+ }
+
+ void handleInvocationTargetException(TemplateContext context, InvocationTargetException
e) {
+ String logMessage = (utils)
+ ? Messages.getMessage(Messages.METHOD_CALL_ERROR_1, methodName,
context.getComponent().getId())
+ : Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName,
context.getComponent().getId());
+ String excMessage = (utils)
+ ? Messages.getMessage(Messages.METHOD_CALL_ERROR_2, new Object[]{methodName,
context.getComponent().getId(), e.getCause().getMessage()})
+ : Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[]{methodName,
context.getComponent().getId(), e.getCause().getMessage()});
+ MethodCallElement._log.error(logMessage, e);
+ throw new FacesException(excMessage, e);
+ }
+ void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
+ String logMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3, methodName,
context.getComponent().getId()))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName,
context.getComponent().getId()));
+ String excMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}));
+ MethodCallElement._log.error(logMessage, e);
+ throw new FacesException(excMessage, e);
+ }
+
+ void handleMethodNotFoundException(TemplateContext context) throws
MethodNotFoundException {
+ String logMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5, methodName,
context.getComponent().getId()))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a, methodName,
context.getComponent().getId()));
+ String excMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6, methodName))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a,
methodName));
+ MethodCallElement._log.error(logMessage);
+ throw new FacesException(excMessage);
+ }
+}
+
+class StaticInvoker extends Invoker {
+ String className;
+ Class cls;
+ Map methods = new HashMap();
+
+ StaticInvoker(String methodName) {
+ this.methodName = methodName;
+ int i = methodName.lastIndexOf('.');
+ className = methodName.substring(0, i);
+ this.methodName = methodName.substring(i + 1);
+ try {
+ cls = Thread.currentThread().getContextClassLoader().loadClass(className);
+ } catch (ClassNotFoundException e) {
+ //ignore, throw exception when invoking
+ }
+ }
+
+ InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
+ if(cls == null) throw new FacesException(className, new
ClassNotFoundException(className));
+ return invokeMethod(context, methods, cls, null, state);
+ }
+
+ void handleInvocationTargetException(TemplateContext context, InvocationTargetException
e) {
+ MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_1a,
methodName, context.getComponent().getId()), e);
+ throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
+ }
+ void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
+ MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a,
methodName, context.getComponent().getId()), e);
+ throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new
Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
+ }
+ void handleMethodNotFoundException(TemplateContext context) throws
MethodNotFoundException {
+ MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a,
methodName, context.getComponent().getId()));
+ throw new MethodNotFoundException(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a,
methodName));
+ }
+}
+
+class MethodCacheState {
+ private MethodParameterElement[] elements;
+ private Class[] parameterClasses;
+ private Object[] parameterValues;
+ private Class lastCallingClass = null;
+ public Method method;
+ public Signature current;
+ public Signature[] signatures;
+
+ public void init(List parameters) {
+ if(elements != null) return;
+ synchronized (this) {
+ if(elements != null) return;
+ int size = parameters.size();
+ parameterClasses = new Class[size];
+ parameterValues = new Object[size];
+ signatures = new Signature[3];
+ signatures[0] = new Signature2(size);
+ signatures[1] = new Signature1(size);
+ signatures[2] = new Signature0(size);
+ elements = (MethodParameterElement[])parameters.toArray(new
MethodParameterElement[0]);
+ }
+ }
+
+ public Object[] computeParameterValues(TemplateContext context) {
+ Object[] ps = new Object[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ ps[i] = elements[i].valueGetter.getValueOrDefault(context);
+ }
+ return ps;
+ }
+
+ public void update(TemplateContext context, Object[] values, Invoker invoker) {
+ boolean changed = false;
+ for (int i = 0; i < elements.length; i++) {
+ Object parametr = values[i];
+ Class c = (parametr == null) ? null : parametr.getClass();
+ if(c != parameterClasses[i]) {
+ parameterClasses[i] = c;
+ changed = true;
+ }
+ parameterValues[i] = parametr;
+ }
+ if(method != null && !changed && lastCallingClass !=
invoker.getInvokedClass(context)) {
+ lastCallingClass = invoker.getInvokedClass(context);
+ changed = true;
+ }
+ if(changed || current == null) {
+ for (int i = 0; i < signatures.length; i++) {
+ signatures[i].update(context, parameterValues);
+ }
+ method = null;
+ current = null;
+ } else {
+ current.update(context, parameterValues);
+ }
+ }
+
+}
+
+abstract class Signature {
+ Object[] arguments;
+
+ Signature() {}
+
+ void update(TemplateContext context, Object[] parameters) {}
+}
+
+class Signature0 extends Signature {
+ Signature0(int size) {
+ arguments = new Object[size];
+ }
+
+ void update(TemplateContext context, Object[] parameters) {
+ System.arraycopy(parameters, 0, arguments, 0, parameters.length);
+ }
+
+}
+
+class Signature1 extends Signature {
+ Signature1(int size) {
+ arguments = new Object[size + 1];
+ }
+ void update(TemplateContext context, Object[] parameters) {
+ arguments[0] = context;
+ System.arraycopy(parameters, 0, arguments, 1, parameters.length);
+ }
+
+}
+
+class Signature2 extends Signature {
+ Signature2(int size) {
+ arguments = new Object[size + 2];
+ }
+ void update(TemplateContext context, Object[] parameters) {
+ arguments[0] = context.getFacesContext();
+ arguments[1] = context.getComponent();
+ System.arraycopy(parameters, 0, arguments, 2, parameters.length);
+ }
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,99 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.xml.sax.SAXException;
-
-
-public class MethodParameterElement extends ElementBase {
-
- /**
- *
- */
- public MethodParameterElement() {
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(RendererBase renderer, FacesContext context, UIComponent component)
throws IOException {
- // DO Nothing !
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // DO Nothing !
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- // DO Nothing !
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void addChild(PreparedTemplate child) throws SAXException {
- // TODO Auto-generated method stub
- super.addChild(child);
- if (child instanceof ResourceElement) {
- final ResourceElement res = (ResourceElement) child;
- this.valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- Object getValue(TemplateContext context) {
- return context.getRenderer().getResource(res.getValue(context).toString());
- }
-
- };
- }
- }
-
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_PARAM_TAG;
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- ResourceElement.class
- };
- }
-
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,99 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.xml.sax.SAXException;
+
+
+public class MethodParameterElement extends ElementBase {
+
+ /**
+ *
+ */
+ public MethodParameterElement() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(RendererBase renderer, FacesContext context, UIComponent component)
throws IOException {
+ // DO Nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // DO Nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // DO Nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void addChild(PreparedTemplate child) throws SAXException {
+ // TODO Auto-generated method stub
+ super.addChild(child);
+ if (child instanceof ResourceElement) {
+ final ResourceElement res = (ResourceElement) child;
+ this.valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ Object getValue(TemplateContext context) {
+ return context.getRenderer().getResource(res.getValue(context).toString());
+ }
+
+ };
+ }
+ }
+
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_PARAM_TAG;
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ ResourceElement.class
+ };
+ }
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,157 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.context.ResponseWriter;
-
-import org.xml.sax.Attributes;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
- *
- */
-public class PlainElement extends ElementBase {
-
-
- private String namespace = "";
- private String tag = null;
-
- private String[][] attrs = null;
-
- private boolean encodeStart = true;
-
- private boolean encodeEnd = true;
- /**
- * @param attrs
- */
- public PlainElement(String namespace, String tag, Attributes attrs) {
- // Set modifable attributes implementation to ability of
- // modifications.
- this.attrs = new String[attrs.getLength()][2];
- this.namespace = namespace;
- this.tag = tag;
- int currentAttribute = 0;
- // remove non-passed attributes, parse special.
- for (int i = 0; i < attrs.getLength(); i++) {
- String qName = attrs.getQName(i);
- String value = attrs.getValue(i);
- if (qName.equals(HtmlCompiler.NS_PREFIX+"start")) {
- this.encodeStart = "true".equals(value);
- } else if (qName.equals(HtmlCompiler.NS_PREFIX+"end")) {
- this.encodeEnd = "true".equals(value);
- } else {
- this.attrs[currentAttribute][0]=qName;
- this.attrs[currentAttribute++][1]=value;
- }
-
- }
- // squize array if nessesary.
- if (currentAttribute < attrs.getLength()) {
- String[][] newattrs = new String[currentAttribute][2];
- System.arraycopy(this.attrs,0,newattrs,0,currentAttribute);
- this.attrs = newattrs;
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeBegin(TemplateContext context) throws IOException {
- ResponseWriter writer = context.getWriter();
- if (this.encodeStart) {
- writer.startElement(getTag(), context.getComponent());
- // write attributes
- for (int i = 0; i < attrs.length; i++) {
- writer.writeAttribute(attrs[i][0], attrs[i][1], null);
- }
- }
- }
-
- public void encodeEnd(TemplateContext context) throws IOException {
- ResponseWriter writer = context.getWriter();
-
- if (this.encodeEnd) {
- writer.endElement(getTag());
- }
-
- }
-
- /**
- * @return Returns the tag.
- */
- public String getTag() {
- return tag;
- }
-
- /**
- * @param tag The tag to set.
- */
- public void setTag(String tag) {
- this.tag = tag;
- }
-
- /**
- * @return Returns the attrs.
- */
- public String[][] getAttrs() {
- return attrs;
- }
-
- /**
- * @return Returns the encodeEnd.
- */
- public boolean isEncodeEnd() {
- return encodeEnd;
- }
-
- /**
- * @param encodeEnd The encodeEnd to set.
- */
- public void setEncodeEnd(boolean encodeEnd) {
- this.encodeEnd = encodeEnd;
- }
-
- /**
- * @return Returns the encodeStart.
- */
- public boolean isEncodeStart() {
- return encodeStart;
- }
-
- /**
- * @param encodeStart The encodeStart to set.
- */
- public void setEncodeStart(boolean encodeStart) {
- this.encodeStart = encodeStart;
- }
-
- /**
- * @return Returns the namespace.
- */
- public String getNamespace() {
- return namespace;
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,157 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.context.ResponseWriter;
+
+import org.xml.sax.Attributes;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
+ *
+ */
+public class PlainElement extends ElementBase {
+
+
+ private String namespace = "";
+ private String tag = null;
+
+ private String[][] attrs = null;
+
+ private boolean encodeStart = true;
+
+ private boolean encodeEnd = true;
+ /**
+ * @param attrs
+ */
+ public PlainElement(String namespace, String tag, Attributes attrs) {
+ // Set modifable attributes implementation to ability of
+ // modifications.
+ this.attrs = new String[attrs.getLength()][2];
+ this.namespace = namespace;
+ this.tag = tag;
+ int currentAttribute = 0;
+ // remove non-passed attributes, parse special.
+ for (int i = 0; i < attrs.getLength(); i++) {
+ String qName = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ if (qName.equals(HtmlCompiler.NS_PREFIX+"start")) {
+ this.encodeStart = "true".equals(value);
+ } else if (qName.equals(HtmlCompiler.NS_PREFIX+"end")) {
+ this.encodeEnd = "true".equals(value);
+ } else {
+ this.attrs[currentAttribute][0]=qName;
+ this.attrs[currentAttribute++][1]=value;
+ }
+
+ }
+ // squize array if nessesary.
+ if (currentAttribute < attrs.getLength()) {
+ String[][] newattrs = new String[currentAttribute][2];
+ System.arraycopy(this.attrs,0,newattrs,0,currentAttribute);
+ this.attrs = newattrs;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeBegin(TemplateContext context) throws IOException {
+ ResponseWriter writer = context.getWriter();
+ if (this.encodeStart) {
+ writer.startElement(getTag(), context.getComponent());
+ // write attributes
+ for (int i = 0; i < attrs.length; i++) {
+ writer.writeAttribute(attrs[i][0], attrs[i][1], null);
+ }
+ }
+ }
+
+ public void encodeEnd(TemplateContext context) throws IOException {
+ ResponseWriter writer = context.getWriter();
+
+ if (this.encodeEnd) {
+ writer.endElement(getTag());
+ }
+
+ }
+
+ /**
+ * @return Returns the tag.
+ */
+ public String getTag() {
+ return tag;
+ }
+
+ /**
+ * @param tag The tag to set.
+ */
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ /**
+ * @return Returns the attrs.
+ */
+ public String[][] getAttrs() {
+ return attrs;
+ }
+
+ /**
+ * @return Returns the encodeEnd.
+ */
+ public boolean isEncodeEnd() {
+ return encodeEnd;
+ }
+
+ /**
+ * @param encodeEnd The encodeEnd to set.
+ */
+ public void setEncodeEnd(boolean encodeEnd) {
+ this.encodeEnd = encodeEnd;
+ }
+
+ /**
+ * @return Returns the encodeStart.
+ */
+ public boolean isEncodeStart() {
+ return encodeStart;
+ }
+
+ /**
+ * @param encodeStart The encodeStart to set.
+ */
+ public void setEncodeStart(boolean encodeStart) {
+ this.encodeStart = encodeStart;
+ }
+
+ /**
+ * @return Returns the namespace.
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElementCreateRule.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,64 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.digester.Rule;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
- *
- */
-public class PlainElementCreateRule extends Rule {
-
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String,
org.xml.sax.Attributes)
- */
- public void begin(String namespace, String name, Attributes attrs) throws Exception {
- if (name.startsWith(HtmlCompiler.NS_PREFIX)) {
- throw new SAXException(Messages.getMessage(Messages.NAMESPACE_NOT_RECOGNIZED_ERROR,
name));
- }
- digester.push(new PlainElement(namespace,name,attrs));
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#body(java.lang.String, java.lang.String,
java.lang.String)
- */
- public void body(String arg0, String arg1, String arg2) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#end(java.lang.String, java.lang.String)
- */
- public void end(String arg0, String arg1) throws Exception {
- // TODO Auto-generated method stub
- digester.pop();
- }
-
-
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElementCreateRule.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,64 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.digester.Rule;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
+ *
+ */
+public class PlainElementCreateRule extends Rule {
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String,
org.xml.sax.Attributes)
+ */
+ public void begin(String namespace, String name, Attributes attrs) throws Exception {
+ if (name.startsWith(HtmlCompiler.NS_PREFIX)) {
+ throw new SAXException(Messages.getMessage(Messages.NAMESPACE_NOT_RECOGNIZED_ERROR,
name));
+ }
+ digester.push(new PlainElement(namespace,name,attrs));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#body(java.lang.String, java.lang.String,
java.lang.String)
+ */
+ public void body(String arg0, String arg1, String arg2) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#end(java.lang.String, java.lang.String)
+ */
+ public void end(String arg0, String arg1) throws Exception {
+ // TODO Auto-generated method stub
+ digester.pop();
+ }
+
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,87 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.xml.sax.SAXException;
-
-
-/**
- * Public interface for compiled XML rendered template.
- * {@link javax.faces.render.Renderer} must simple call
xml.encode(this,context,component);
- * for produce {@link javax.faces.context.ResponseWriter} events.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
- *
- */
-public interface PreparedTemplate {
-
- /**
- * Encode this XML component. May be simple send element and attributes,
- * call specified Renderer or RendererUtils method etc. Can encode children
- * elements ( if exist ).
- * @param renderer
- * @param context
- * @param component
- * @throws IOException
- */
- public void encode(RendererBase renderer, FacesContext context, UIComponent component)
throws IOException;
-
- public void encode(TemplateContext context) throws IOException;
-
- public void encode(TemplateContext context,String breakPoint) throws IOException;
- /**
- * @return List of childrens of this component.
- */
- public List getChildren();
-
- /**
- * Append child element to current.
- * @param child
- * @throws SAXException
- */
- public void addChild(PreparedTemplate child) throws SAXException;
-
- /**
- * Set parent element in compiled tree for template.
- * @param parent
- * @throws SAXException
- */
- public void setParent(PreparedTemplate parent) throws SAXException;
-
- /**
- * @return tag name for element.
- */
- public String getTag();
-
- /**
- * @return Returns the value. If is EL expression valueBinding - evaluate in.
- */
- public Object getValue(TemplateContext context);
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Public interface for compiled XML rendered template.
+ * {@link javax.faces.render.Renderer} must simple call
xml.encode(this,context,component);
+ * for produce {@link javax.faces.context.ResponseWriter} events.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
+ *
+ */
+public interface PreparedTemplate {
+
+ /**
+ * Encode this XML component. May be simple send element and attributes,
+ * call specified Renderer or RendererUtils method etc. Can encode children
+ * elements ( if exist ).
+ * @param renderer
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encode(RendererBase renderer, FacesContext context, UIComponent component)
throws IOException;
+
+ public void encode(TemplateContext context) throws IOException;
+
+ public void encode(TemplateContext context,String breakPoint) throws IOException;
+ /**
+ * @return List of childrens of this component.
+ */
+ public List getChildren();
+
+ /**
+ * Append child element to current.
+ * @param child
+ * @throws SAXException
+ */
+ public void addChild(PreparedTemplate child) throws SAXException;
+
+ /**
+ * Set parent element in compiled tree for template.
+ * @param parent
+ * @throws SAXException
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException;
+
+ /**
+ * @return tag name for element.
+ */
+ public String getTag();
+
+ /**
+ * @return Returns the value. If is EL expression valueBinding - evaluate in.
+ */
+ public Object getValue(TemplateContext context);
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PutAttributesRule.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,92 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.xml.sax.Attributes;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
- *
- */
-public class PutAttributesRule extends Rule {
-
- private List toSkip = Collections.EMPTY_LIST;
- private String methodName = "put";
- /**
- * @param digestr
- * @param toSkip
- */
- public PutAttributesRule(Digester digestr, String[] toSkip) {
- // TODO Auto-generated constructor stub
- this.digester = digestr;
-// Arrays.asList(toSkip);
- this.toSkip = Arrays.asList(toSkip);
- }
-
- /**
- * @param digestr
- * @param methodName
- */
- public PutAttributesRule(Digester digestr, String methodName) {
- // TODO Auto-generated constructor stub
- this.digester = digestr;
-// Arrays.asList(toSkip);
- this.methodName = methodName;
- }
-
- /**
- * @param digestr
- * @param methodName
- * @param toSkip
- */
- public PutAttributesRule(Digester digestr, String methodName, String[] toSkip) {
- // TODO Auto-generated constructor stub
- this.digester = digestr;
- this.methodName = methodName;
- this.toSkip = Arrays.asList(toSkip);
- }
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String,
org.xml.sax.Attributes)
- */
- public void begin(String namespace, String element, Attributes attrs) throws Exception
{
- Object top = digester.peek();
- if(null != top){
- Method put = top.getClass().getDeclaredMethod(methodName,new
Class[]{Object.class,Object.class});
- for (int i = 0; i < attrs.getLength(); i++) {
- String qName = attrs.getQName(i);
- String value = attrs.getValue(i);
- if (!toSkip.contains(qName)) {
- put.invoke(top,new Object[]{qName,value});
- }
- }
- }
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PutAttributesRule.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.xml.sax.Attributes;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
+ *
+ */
+public class PutAttributesRule extends Rule {
+
+ private List toSkip = Collections.EMPTY_LIST;
+ private String methodName = "put";
+ /**
+ * @param digestr
+ * @param toSkip
+ */
+ public PutAttributesRule(Digester digestr, String[] toSkip) {
+ // TODO Auto-generated constructor stub
+ this.digester = digestr;
+// Arrays.asList(toSkip);
+ this.toSkip = Arrays.asList(toSkip);
+ }
+
+ /**
+ * @param digestr
+ * @param methodName
+ */
+ public PutAttributesRule(Digester digestr, String methodName) {
+ // TODO Auto-generated constructor stub
+ this.digester = digestr;
+// Arrays.asList(toSkip);
+ this.methodName = methodName;
+ }
+
+ /**
+ * @param digestr
+ * @param methodName
+ * @param toSkip
+ */
+ public PutAttributesRule(Digester digestr, String methodName, String[] toSkip) {
+ // TODO Auto-generated constructor stub
+ this.digester = digestr;
+ this.methodName = methodName;
+ this.toSkip = Arrays.asList(toSkip);
+ }
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String,
org.xml.sax.Attributes)
+ */
+ public void begin(String namespace, String element, Attributes attrs) throws Exception
{
+ Object top = digester.peek();
+ if(null != top){
+ Method put = top.getClass().getDeclaredMethod(methodName,new
Class[]{Object.class,Object.class});
+ for (int i = 0; i < attrs.getLength(); i++) {
+ String qName = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ if (!toSkip.contains(qName)) {
+ put.invoke(top,new Object[]{qName,value});
+ }
+ }
+ }
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,105 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
- *
- */
-public class ResourceElement extends ElementBase {
-
- private Map attrs = new HashMap();
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- public Object put(Object key, Object value) {
- return attrs.put(key, value);
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#get(java.lang.Object)
- */
- public Object get(Object key) {
- return attrs.get(key);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeBegin(TemplateContext context) throws IOException {
- InternetResource resource = findResource(context);
- if(null !=resource){
- resource.encodeBegin(context.getFacesContext(),context.getComponent(),attrs);
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeEnd(TemplateContext context) throws IOException {
- InternetResource resource = findResource(context);
- if(null !=resource){
- resource.encodeEnd(context.getFacesContext(),context.getComponent());
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.RootElement#getString(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public String getString(TemplateContext context) throws FacesException {
- InternetResource resource = findResource(context);
- if(null !=resource){
- return resource.getUri(context.getFacesContext(),context.getComponent());
- }
- return "";
- }
-
- private InternetResource findResource(TemplateContext context) {
- InternetResource resource;
- String path = (String) getValue(context);
- RendererBase renderer = context.getRenderer();
- if (renderer != null) {
- resource = renderer.getResource(path);
- } else {
- resource = InternetResourceBuilder.getInstance().createResource(null, path);
- }
-
- return resource;
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.RESOURCE_TAG;
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,105 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
+ *
+ */
+public class ResourceElement extends ElementBase {
+
+ private Map attrs = new HashMap();
+ /* (non-Javadoc)
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(Object key, Object value) {
+ return attrs.put(key, value);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ return attrs.get(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeBegin(TemplateContext context) throws IOException {
+ InternetResource resource = findResource(context);
+ if(null !=resource){
+ resource.encodeBegin(context.getFacesContext(),context.getComponent(),attrs);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeEnd(TemplateContext context) throws IOException {
+ InternetResource resource = findResource(context);
+ if(null !=resource){
+ resource.encodeEnd(context.getFacesContext(),context.getComponent());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.RootElement#getString(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+ InternetResource resource = findResource(context);
+ if(null !=resource){
+ return resource.getUri(context.getFacesContext(),context.getComponent());
+ }
+ return "";
+ }
+
+ private InternetResource findResource(TemplateContext context) {
+ InternetResource resource;
+ String path = (String) getValue(context);
+ RendererBase renderer = context.getRenderer();
+ if (renderer != null) {
+ resource = renderer.getResource(path);
+ } else {
+ resource = InternetResourceBuilder.getInstance().createResource(null, path);
+ }
+
+ return resource;
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.RESOURCE_TAG;
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/RootElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,92 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
- *
- */
-public class RootElement extends ElementBase {
- private static final Log log = LogFactory.getLog(RootElement.class);
-
- private String templateName="unset";
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO,
getTemplateName(), breakPoint));
- }
- try {
- super.encode(context, breakPoint);
- } catch (BreakException e) {
- // encoding terminated by break
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO,
getTemplateName(), e.getName()));
- }
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO2,
getTemplateName()));
- }
- try {
- super.encode(context);
- } catch (BreakException e) {
- // encoding terminated by break
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO,
getTemplateName(), e.getName()));
- }
- }
- }
-
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.ROOT_TAG;
- }
-
- /**
- * @return Returns the templateName.
- */
- public String getTemplateName() {
- return templateName;
- }
-
- /**
- * @param templateName The templateName to set.
- */
- public void setTemplateName(String templateName) {
- this.templateName = templateName;
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/RootElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
+ *
+ */
+public class RootElement extends ElementBase {
+ private static final Log log = LogFactory.getLog(RootElement.class);
+
+ private String templateName="unset";
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO,
getTemplateName(), breakPoint));
+ }
+ try {
+ super.encode(context, breakPoint);
+ } catch (BreakException e) {
+ // encoding terminated by break
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO,
getTemplateName(), e.getName()));
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO2,
getTemplateName()));
+ }
+ try {
+ super.encode(context);
+ } catch (BreakException e) {
+ // encoding terminated by break
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO,
getTemplateName(), e.getName()));
+ }
+ }
+ }
+
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.ROOT_TAG;
+ }
+
+ /**
+ * @return Returns the templateName.
+ */
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ /**
+ * @param templateName The templateName to set.
+ */
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/SelectorElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,87 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import org.ajax4jsf.Messages;
-import org.xml.sax.SAXException;
-
-/**
- * @author Maksim Kaszynski (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
- * CSS selector tag.
- * Works this way
- * <code>
- * <u:selector name=".X">
- * a bunch of <u:style>
- * </u:selector>
- * </code>
- * renders like this
- * <code>
- * .X{
- * styles...
- * }
- * </code>
- *
- */
-public class SelectorElement extends ElementBase {
-
- private String name ;
-
- protected void encodeBegin(TemplateContext context) throws IOException {
- context.getWriter().write("\n" + getName() + "{\n");
- }
-
- protected void encodeEnd(TemplateContext context) throws IOException {
- context.getWriter().write("}");
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.SELECTOR_TAG;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
- }
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/SelectorElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import org.ajax4jsf.Messages;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Maksim Kaszynski (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
+ * CSS selector tag.
+ * Works this way
+ * <code>
+ * <u:selector name=".X">
+ * a bunch of <u:style>
+ * </u:selector>
+ * </code>
+ * renders like this
+ * <code>
+ * .X{
+ * styles...
+ * }
+ * </code>
+ *
+ */
+public class SelectorElement extends ElementBase {
+
+ private String name ;
+
+ protected void encodeBegin(TemplateContext context) throws IOException {
+ context.getWriter().write("\n" + getName() + "{\n");
+ }
+
+ protected void encodeEnd(TemplateContext context) throws IOException {
+ context.getWriter().write("}");
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.SELECTOR_TAG;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR,
getTag()));
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-
-
-/**
- * Incapsulate all current parameters for encoding template.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
-public class TemplateContext {
- FacesContext facesContext;
- RendererBase renderer;
- UIComponent component;
- Map parameters = new HashMap();
- /**
- * @param renderer
- * @param facesContext
- * @param component
- */
- public TemplateContext(RendererBase renderer, FacesContext facesContext, UIComponent
component) {
- // TODO Auto-generated constructor stub
- this.facesContext = facesContext;
- this.renderer = renderer;
- this.component = component;
- }
- /**
- * @return Returns the component.
- */
- public UIComponent getComponent() {
- return component;
- }
- /**
- * @return Returns the facesContext.
- */
- public FacesContext getFacesContext() {
- return facesContext;
- }
- /**
- * @return Returns the renderer.
- */
- public RendererBase getRenderer() {
- return renderer;
- }
-
- public void putParameter(Object key,Object value) {
- parameters.put(key,value);
- }
-
- public Object getParameter(Object key) {
- return parameters.get(key);
- }
- public void removeParameter(Object key) {
- parameters.remove(key);
-
- }
- public ResponseWriter getWriter() {
- return facesContext.getResponseWriter();
- }
-
- /**
- * Create copy of this context for other child component.
- * Used in iterations and facets for render template on current child
- * @param child - component for template
- * @return - new copy of component, with same parameters.
- */
- public TemplateContext clone(UIComponent child){
- TemplateContext cloned = new TemplateContext(this.renderer,this.facesContext,child);
- cloned.parameters.putAll(this.parameters);
- return cloned;
- }
-
- /**
- * Return a mutable Map representing the parameters associated wth this TemplateContext
- */
- public Map getParameters() {
- return parameters;
- }
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererBase;
+
+
+/**
+ * Incapsulate all current parameters for encoding template.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+public class TemplateContext {
+ FacesContext facesContext;
+ RendererBase renderer;
+ UIComponent component;
+ Map parameters = new HashMap();
+ /**
+ * @param renderer
+ * @param facesContext
+ * @param component
+ */
+ public TemplateContext(RendererBase renderer, FacesContext facesContext, UIComponent
component) {
+ // TODO Auto-generated constructor stub
+ this.facesContext = facesContext;
+ this.renderer = renderer;
+ this.component = component;
+ }
+ /**
+ * @return Returns the component.
+ */
+ public UIComponent getComponent() {
+ return component;
+ }
+ /**
+ * @return Returns the facesContext.
+ */
+ public FacesContext getFacesContext() {
+ return facesContext;
+ }
+ /**
+ * @return Returns the renderer.
+ */
+ public RendererBase getRenderer() {
+ return renderer;
+ }
+
+ public void putParameter(Object key,Object value) {
+ parameters.put(key,value);
+ }
+
+ public Object getParameter(Object key) {
+ return parameters.get(key);
+ }
+ public void removeParameter(Object key) {
+ parameters.remove(key);
+
+ }
+ public ResponseWriter getWriter() {
+ return facesContext.getResponseWriter();
+ }
+
+ /**
+ * Create copy of this context for other child component.
+ * Used in iterations and facets for render template on current child
+ * @param child - component for template
+ * @return - new copy of component, with same parameters.
+ */
+ public TemplateContext clone(UIComponent child){
+ TemplateContext cloned = new TemplateContext(this.renderer,this.facesContext,child);
+ cloned.parameters.putAll(this.parameters);
+ return cloned;
+ }
+
+ /**
+ * Return a mutable Map representing the parameters associated wth this TemplateContext
+ */
+ public Map getParameters() {
+ return parameters;
+ }
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TextElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,123 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
- *
- */
-public class TextElement extends ElementBase {
-
- private String text = null;
-
- private boolean escape = false;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(TemplateContext context) throws IOException {
- // TODO Auto-generated method stub
- String textValue = getString(context);
-
- if (isEscape()) {
- context.getWriter().writeText(textValue, null);
- } else {
- context.getWriter().write(textValue.toString());
- }
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // Text not contain breakpoints.
- encode(context);
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public String getString(TemplateContext context) throws FacesException {
-
- String textValue = super.getString(context);
- // If value not set - return element body.
- if (textValue.length()==0 && null != getText()) {
- textValue = getText();
- }
- return textValue;
- }
-
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-
- /**
- * @return Returns the escape.
- */
- public boolean isEscape() {
- return escape;
- }
-
- /**
- * @param escape The escape to set.
- */
- public void setEscape(boolean escape) {
- this.escape = escape;
- }
-
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.VERBATUM_TAG;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- MethodCallElement.class,
- ResourceElement.class,
- ClassElement.class
- };
- }
-
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java (from
rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TextElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,123 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
+ *
+ */
+public class TextElement extends ElementBase {
+
+ private String text = null;
+
+ private boolean escape = false;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // TODO Auto-generated method stub
+ String textValue = getString(context);
+
+ if (isEscape()) {
+ context.getWriter().writeText(textValue, null);
+ } else {
+ context.getWriter().write(textValue.toString());
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // Text not contain breakpoints.
+ encode(context);
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+
+ String textValue = super.getString(context);
+ // If value not set - return element body.
+ if (textValue.length()==0 && null != getText()) {
+ textValue = getText();
+ }
+ return textValue;
+ }
+
+
+ /**
+ * @return Returns the text.
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text The text to set.
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return Returns the escape.
+ */
+ public boolean isEscape() {
+ return escape;
+ }
+
+ /**
+ * @param escape The escape to set.
+ */
+ public void setEscape(boolean escape) {
+ this.escape = escape;
+ }
+
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.VERBATUM_TAG;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ MethodCallElement.class,
+ ResourceElement.class,
+ ClassElement.class
+ };
+ }
+
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ValueMethodCallElement.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,68 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import org.xml.sax.SAXException;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
- *
- */
-public class ValueMethodCallElement extends MethodCallElement {
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.MethodCallElement#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- // do nothing
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.MethodCallElement#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- // TODO Auto-generated method stub
- super.setParent(parent);
- if (parent instanceof ElementBase) {
- ElementBase base = (ElementBase) parent;
- base.valueGetter = new ElementBase.ValueGetter(){
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return ValueMethodCallElement.this.getValue(context);
- }
- };
- }
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.VALUE_CALL_TAG;
- }
-
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ValueMethodCallElement.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,68 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
+ *
+ */
+public class ValueMethodCallElement extends MethodCallElement {
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.MethodCallElement#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.MethodCallElement#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ // TODO Auto-generated method stub
+ super.setParent(parent);
+ if (parent instanceof ElementBase) {
+ ElementBase base = (ElementBase) parent;
+ base.valueGetter = new ElementBase.ValueGetter(){
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return ValueMethodCallElement.this.getValue(context);
+ }
+ };
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.VALUE_CALL_TAG;
+ }
+
+}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/WithDefaultsRulesWrapper.java 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,190 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - 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
- */
-
-/* $Id: WithDefaultsRulesWrapper.java,v 1.1.2.1 2007/01/09 18:57:42 alexsmirnov Exp $
- *
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.apache.commons.digester.Rules;
-
-/**
- * <h2>Imported from digitester 1.7 , since JSF RI used version 1.5 by
default.</h2>
- * <p><code>Rules</code> <em>Decorator</em> that returns
default rules
- * when no matches are returned by the wrapped implementation.</p>
- *
- * <p>This allows default <code>Rule</code> instances to be added to
any
- * existing <code>Rules</code> implementation. These default
<code>Rule</code>
- * instances will be returned for any match for which the wrapped
- * implementation does not return any matches.</p>
- * <p> For example,
- * <pre>
- * Rule alpha;
- * ...
- * WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new BaseRules());
- * rules.addDefault(alpha);
- * ...
- * digester.setRules(rules);
- * ...
- * </pre>
- * when a pattern does not match any other rule, then rule alpha will be called.
- * </p>
- * <p><code>WithDefaultsRulesWrapper</code> follows the
<em>Decorator</em> pattern.</p>
- *
- * @since 1.6
- */
-
-public class WithDefaultsRulesWrapper implements Rules {
-
- // --------------------------------------------------------- Fields
-
- /** The Rules implementation that this class wraps. */
- private Rules wrappedRules;
- /** Rules to be fired when the wrapped implementations returns none. */
- private List defaultRules = new ArrayList();
- /** All rules (preserves order in which they were originally added) */
- private List allRules = new ArrayList();
-
- // --------------------------------------------------------- Constructor
-
- /**
- * Base constructor.
- *
- * @param wrappedRules the wrapped <code>Rules</code> implementation, not
null
- * @throws IllegalArgumentException when <code>wrappedRules</code> is
null
- */
- public WithDefaultsRulesWrapper(Rules wrappedRules) {
- if (wrappedRules == null) {
- throw new
IllegalArgumentException(Messages.getMessage(Messages.WRAPPED_RULES_NULL_ERROR));
- }
- this.wrappedRules = wrappedRules;
- }
-
- // --------------------------------------------------------- Properties
-
- /** Gets digester using these Rules */
- public Digester getDigester() {
- return wrappedRules.getDigester();
- }
-
- /** Sets digeseter using these Rules */
- public void setDigester(Digester digester) {
- wrappedRules.setDigester(digester);
- Iterator it = defaultRules.iterator();
- while (it.hasNext()) {
- Rule rule = (Rule) it.next();
- rule.setDigester(digester);
- }
- }
-
- /** Gets namespace to apply to Rule's added */
- public String getNamespaceURI() {
- return wrappedRules.getNamespaceURI();
- }
-
- /** Sets namespace to apply to Rule's added subsequently */
- public void setNamespaceURI(String namespaceURI) {
- wrappedRules.setNamespaceURI(namespaceURI);
- }
-
- /** Gets Rule's which will be fired when the wrapped implementation returns no
matches */
- public List getDefaults() {
- return defaultRules;
- }
-
- // --------------------------------------------------------- Public Methods
-
- public List match(String pattern) {
- return match("", pattern);
- }
-
- /**
- * Return list of rules matching given pattern.
- * If wrapped implementation returns any matches return those.
- * Otherwise, return default matches.
- */
- public List match(String namespaceURI, String pattern) {
- List matches = wrappedRules.match(namespaceURI, pattern);
- if (matches == null || matches.isEmpty()) {
- // a little bit of defensive programming
- return new ArrayList(defaultRules);
- }
- // otherwise
- return matches;
- }
-
- /** Adds a rule to be fired when wrapped implementation returns no matches */
- public void addDefault(Rule rule) {
- // set up rule
- if (wrappedRules.getDigester() != null) {
- rule.setDigester(wrappedRules.getDigester());
- }
-
- if (wrappedRules.getNamespaceURI() != null) {
- rule.setNamespaceURI(wrappedRules.getNamespaceURI());
- }
-
- defaultRules.add(rule);
- allRules.add(rule);
- }
-
- /** Gets all rules */
- public List rules() {
- return allRules;
- }
-
- /** Clears all Rule's */
- public void clear() {
- wrappedRules.clear();
- allRules.clear();
- defaultRules.clear();
- }
-
- /**
- * Adds a Rule to be fired on given pattern.
- * Pattern matching is delegated to wrapped implementation.
- */
- public void add(String pattern, Rule rule) {
- wrappedRules.add(pattern, rule);
- allRules.add(rule);
- }
-}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/WithDefaultsRulesWrapper.java)
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,190 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - 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
+ */
+
+/* $Id: WithDefaultsRulesWrapper.java,v 1.1.2.1 2007/01/09 18:57:42 alexsmirnov Exp $
+ *
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.apache.commons.digester.Rules;
+
+/**
+ * <h2>Imported from digitester 1.7 , since JSF RI used version 1.5 by
default.</h2>
+ * <p><code>Rules</code> <em>Decorator</em> that returns
default rules
+ * when no matches are returned by the wrapped implementation.</p>
+ *
+ * <p>This allows default <code>Rule</code> instances to be added to
any
+ * existing <code>Rules</code> implementation. These default
<code>Rule</code>
+ * instances will be returned for any match for which the wrapped
+ * implementation does not return any matches.</p>
+ * <p> For example,
+ * <pre>
+ * Rule alpha;
+ * ...
+ * WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new BaseRules());
+ * rules.addDefault(alpha);
+ * ...
+ * digester.setRules(rules);
+ * ...
+ * </pre>
+ * when a pattern does not match any other rule, then rule alpha will be called.
+ * </p>
+ * <p><code>WithDefaultsRulesWrapper</code> follows the
<em>Decorator</em> pattern.</p>
+ *
+ * @since 1.6
+ */
+
+public class WithDefaultsRulesWrapper implements Rules {
+
+ // --------------------------------------------------------- Fields
+
+ /** The Rules implementation that this class wraps. */
+ private Rules wrappedRules;
+ /** Rules to be fired when the wrapped implementations returns none. */
+ private List defaultRules = new ArrayList();
+ /** All rules (preserves order in which they were originally added) */
+ private List allRules = new ArrayList();
+
+ // --------------------------------------------------------- Constructor
+
+ /**
+ * Base constructor.
+ *
+ * @param wrappedRules the wrapped <code>Rules</code> implementation, not
null
+ * @throws IllegalArgumentException when <code>wrappedRules</code> is
null
+ */
+ public WithDefaultsRulesWrapper(Rules wrappedRules) {
+ if (wrappedRules == null) {
+ throw new
IllegalArgumentException(Messages.getMessage(Messages.WRAPPED_RULES_NULL_ERROR));
+ }
+ this.wrappedRules = wrappedRules;
+ }
+
+ // --------------------------------------------------------- Properties
+
+ /** Gets digester using these Rules */
+ public Digester getDigester() {
+ return wrappedRules.getDigester();
+ }
+
+ /** Sets digeseter using these Rules */
+ public void setDigester(Digester digester) {
+ wrappedRules.setDigester(digester);
+ Iterator it = defaultRules.iterator();
+ while (it.hasNext()) {
+ Rule rule = (Rule) it.next();
+ rule.setDigester(digester);
+ }
+ }
+
+ /** Gets namespace to apply to Rule's added */
+ public String getNamespaceURI() {
+ return wrappedRules.getNamespaceURI();
+ }
+
+ /** Sets namespace to apply to Rule's added subsequently */
+ public void setNamespaceURI(String namespaceURI) {
+ wrappedRules.setNamespaceURI(namespaceURI);
+ }
+
+ /** Gets Rule's which will be fired when the wrapped implementation returns no
matches */
+ public List getDefaults() {
+ return defaultRules;
+ }
+
+ // --------------------------------------------------------- Public Methods
+
+ public List match(String pattern) {
+ return match("", pattern);
+ }
+
+ /**
+ * Return list of rules matching given pattern.
+ * If wrapped implementation returns any matches return those.
+ * Otherwise, return default matches.
+ */
+ public List match(String namespaceURI, String pattern) {
+ List matches = wrappedRules.match(namespaceURI, pattern);
+ if (matches == null || matches.isEmpty()) {
+ // a little bit of defensive programming
+ return new ArrayList(defaultRules);
+ }
+ // otherwise
+ return matches;
+ }
+
+ /** Adds a rule to be fired when wrapped implementation returns no matches */
+ public void addDefault(Rule rule) {
+ // set up rule
+ if (wrappedRules.getDigester() != null) {
+ rule.setDigester(wrappedRules.getDigester());
+ }
+
+ if (wrappedRules.getNamespaceURI() != null) {
+ rule.setNamespaceURI(wrappedRules.getNamespaceURI());
+ }
+
+ defaultRules.add(rule);
+ allRules.add(rule);
+ }
+
+ /** Gets all rules */
+ public List rules() {
+ return allRules;
+ }
+
+ /** Clears all Rule's */
+ public void clear() {
+ wrappedRules.clear();
+ allRules.clear();
+ defaultRules.clear();
+ }
+
+ /**
+ * Adds a Rule to be fired on given pattern.
+ * Pattern matching is delegated to wrapped implementation.
+ */
+ public void add(String pattern, Rule rule) {
+ wrappedRules.add(pattern, rule);
+ allRules.add(rule);
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/package.html 2007-07-10
00:39:15 UTC (rev 1558)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html 2007-07-10
01:19:57 UTC (rev 1561)
@@ -1,10 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
-<title>Insert title here</title>
-</head>
-<body>
-
-</body>
-</html>
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
(from rev 1560,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/package.html)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+
+</body>
+</html>
\ No newline at end of file
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-10
01:10:15 UTC (rev 1560)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -33,10 +33,10 @@
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.compiler.HtmlCompiler;
+import org.ajax4jsf.renderkit.compiler.PreparedTemplate;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.SkinFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10
01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -39,7 +39,6 @@
import javax.servlet.http.HttpSession;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.ajax4jsf.resource.InternetResourceService;
import org.apache.commons.logging.Log;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2007-07-10
01:10:15 UTC (rev 1560)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -10,7 +10,6 @@
import javax.faces.FacesException;
import javax.servlet.ServletContext;
-import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.cache.CacheConfigurationLoader;
import org.ajax4jsf.cache.CacheException;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java
(from rev 1558,
trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -0,0 +1,34 @@
+package org.ajax4jsf.webapp;
+
+import java.io.Serializable;
+import java.util.EventObject;
+
+import org.ajax4jsf.event.PushEventListener;
+
+public class PushEventsCounter implements PushEventListener,Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4060284352186710009L;
+ private volatile boolean performed = false;
+
+ public void onEvent(EventObject event) {
+ performed = true;
+ }
+
+ /**
+ * @return the performed
+ */
+ public boolean isPerformed() {
+ return performed;
+ }
+
+ /**
+ */
+ public void processed() {
+ this.performed = false;
+ }
+
+
+}
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10
01:10:15 UTC (rev 1560)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -24,8 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java 2007-07-10 01:10:15 UTC
(rev 1560)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java 2007-07-10 01:19:57 UTC
(rev 1561)
@@ -28,8 +28,8 @@
import javax.faces.el.MethodBinding;
import javax.servlet.http.HttpSession;
-import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.webapp.PollEventsManager;
+import org.ajax4jsf.webapp.PushEventsCounter;
/**
* Component for periodically call AJAX events on server ( poll actions )
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10
01:10:15 UTC (rev 1560)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10
01:19:57 UTC (rev 1561)
@@ -22,15 +22,15 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.compiler.HtmlCompiler;
+import org.ajax4jsf.renderkit.compiler.PreparedTemplate;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.TemplateCSSResource;
import org.richfaces.component.AjaxSuggestionEvent;