You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/04/02 21:37:18 UTC
svn commit: r644014 [9/10] - in /myfaces/tobago/trunk: ./ core/
core/src/main/faces-config/
core/src/main/java/org/apache/myfaces/tobago/ajax/api/
core/src/main/java/org/apache/myfaces/tobago/application/
core/src/main/java/org/apache/myfaces/tobago/co...
Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java Wed Apr 2 12:36:26 2008
@@ -26,9 +26,9 @@
import org.apache.commons.logging.LogFactory;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_BODY;
import org.apache.myfaces.tobago.component.UITab;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
+import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SeparatorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SeparatorRenderer.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SeparatorRenderer.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SeparatorRenderer.java Wed Apr 2 12:36:26 2008
@@ -22,7 +22,7 @@
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.apache.myfaces.tobago.context.ClientProperties;
Copied: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java?p2=myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/CommandRendererHelper.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java Wed Apr 2 12:36:26 2008
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.renderkit.html;
+package org.apache.myfaces.tobago.renderkit.html.util;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,7 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.apache.myfaces.tobago.TobagoConstants.*;
-import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.util.ComponentUtil;
import org.apache.myfaces.tobago.component.UIPopup;
import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.event.PopupActionListener;
@@ -36,8 +36,7 @@
import java.util.Arrays;
import java.util.List;
-/**
- * User: lofwyr
+/*
* Date: 19.03.2007 17:54:59
*/
public class CommandRendererHelper {
Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java?p2=myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java Wed Apr 2 12:36:26 2008
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.renderkit.html;
+package org.apache.myfaces.tobago.renderkit.html.util;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -32,7 +32,11 @@
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
import static org.apache.myfaces.tobago.TobagoConstants.FACET_LAYOUT;
import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_OUT;
-import org.apache.myfaces.tobago.component.ComponentUtil;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ONCLICK;
+import org.apache.myfaces.tobago.util.ComponentUtil;
+import org.apache.myfaces.tobago.component.AbstractUIPage;
import org.apache.myfaces.tobago.component.SupportsMarkup;
import org.apache.myfaces.tobago.component.UICommand;
import org.apache.myfaces.tobago.component.UIData;
@@ -40,9 +44,13 @@
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
+import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
import org.apache.myfaces.tobago.renderkit.RendererBaseWrapper;
import org.apache.myfaces.tobago.renderkit.LayoutableRenderer;
+import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
+import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.util.LayoutUtil;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriterWrapper;
@@ -77,7 +85,7 @@
throws IOException {
if (ComponentUtil.getBooleanAttribute(component, ATTR_FOCUS)) {
- UIPage page = ComponentUtil.findPage(facesContext, component);
+ UIPage page = (UIPage) ComponentUtil.findPage(facesContext, component);
String id = component.getClientId(facesContext);
if (!StringUtils.isBlank(page.getFocusId()) && !page.getFocusId().equals(id)) {
LOG.warn("page focusId = \"" + page.getFocusId() + "\" ignoring new value \""
@@ -726,7 +734,7 @@
throws IOException {
Object objDojoType = component.getAttributes().get("dojoType");
if (null != objDojoType && (objDojoType.equals("dojo.dnd.Source") || objDojoType.equals("dojo.dnd.Target"))) {
- ComponentUtil.addOnloadCommands(component, createDojoDndType(component, clientId, String.valueOf(objDojoType)));
+ addOnloadCommands(component, createDojoDndType(component, clientId, String.valueOf(objDojoType)));
}
}
@@ -797,5 +805,76 @@
}
strBuilder.append(");");
return new String[]{strBuilder.toString()};
+ }
+
+ public static void checkForCommandFacet(UIComponent component, FacesContext facesContext, TobagoResponseWriter writer)
+ throws IOException {
+ checkForCommandFacet(component, Arrays.asList(component.getClientId(facesContext)), facesContext, writer);
+ }
+
+ public static void checkForCommandFacet(UIComponent component, List<String> clientIds, FacesContext facesContext,
+ TobagoResponseWriter writer) throws IOException {
+ if (ComponentUtil.getBooleanAttribute(component, ATTR_READONLY)
+ || ComponentUtil.getBooleanAttribute(component, ATTR_DISABLED)) {
+ return;
+ }
+ Map<String, UIComponent> facets = component.getFacets();
+ for (Map.Entry<String, UIComponent> entry : facets.entrySet()) {
+ if (entry.getValue() instanceof UICommand) {
+ addCommandFacet(clientIds, entry, facesContext, writer);
+ }
+ }
+ }
+
+ private static void addCommandFacet(List<String> clientIds, Map.Entry<String, UIComponent> facetEntry,
+ FacesContext facesContext, TobagoResponseWriter writer) throws
+ IOException {
+ for (String clientId : clientIds) {
+ writeScriptForClientId(clientId, facetEntry, facesContext, writer);
+ }
+ }
+
+ private static void writeScriptForClientId(String clientId, Map.Entry<String, UIComponent> facetEntry,
+ FacesContext facesContext, TobagoResponseWriter writer) throws IOException {
+ if (facetEntry.getValue() instanceof UICommand
+ && ((UICommand) facetEntry.getValue()).getRenderedPartially().length > 0) {
+ String script =
+ "var element = Tobago.element(\"" + clientId + "\");\n"
+ + "if (element) {\n"
+ + " Tobago.addEventListener(element, \"" + facetEntry.getKey()
+ + "\", function(){Tobago.reloadComponent('"
+ + HtmlRendererUtil.getComponentIds(facesContext, facetEntry.getValue(),
+ ((UICommand) facetEntry.getValue()).getRenderedPartially()) + "','"
+ + facetEntry.getValue().getClientId(facesContext) + "', {})});\n"
+ + "}";
+ writer.writeJavascript(script);
+ } else {
+ UIComponent facetComponent = facetEntry.getValue();
+ String facetAction = (String) facetComponent.getAttributes().get(ATTR_ONCLICK);
+ if (facetAction == null) {
+ facetAction = "Tobago.submitAction('" + facetComponent.getClientId(facesContext) + "')";
+ }
+ String script =
+ "var element = Tobago.element(\"" + clientId + "\");\n"
+ + "if (element) {\n"
+ + " Tobago.addEventListener(element, \"" + facetEntry.getKey() + "\", function(){"
+ + facetAction + "});\n}";
+ writer.writeJavascript(script);
+ }
+ }
+
+ public static void addStyles(UIComponent component, String[] styles) {
+ AbstractUIPage uiPage = ComponentUtil.findPage(component);
+ uiPage.getStyleFiles().addAll(Arrays.asList(styles));
+ }
+
+ public static void addScripts(UIComponent component, String[] scripts) {
+ AbstractUIPage uiPage = ComponentUtil.findPage(component);
+ uiPage.getScriptFiles().addAll(Arrays.asList(scripts));
+ }
+
+ public static void addOnloadCommands(UIComponent component, String[] cmds) {
+ AbstractUIPage uiPage = ComponentUtil.findPage(component);
+ uiPage.getOnloadScripts().addAll(Arrays.asList(cmds));
}
}
Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/RenderUtil.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java?p2=myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/RenderUtil.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/RenderUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java Wed Apr 2 12:36:26 2008
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.renderkit;
+package org.apache.myfaces.tobago.renderkit.util;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,17 +19,28 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.util.ComponentUtil;
import org.apache.myfaces.tobago.component.UILayout;
import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
+import org.apache.myfaces.tobago.renderkit.LayoutRenderer;
+import org.apache.myfaces.tobago.util.RangeParser;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UISelectItems;
+import javax.faces.component.UISelectItem;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
+import javax.faces.model.SelectItem;
import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
public class RenderUtil {
@@ -112,6 +123,7 @@
return getFormattedValue(facesContext, component, value);
}
+ // Copy from RendererBase
public static String getFormattedValue(
FacesContext context, UIComponent component, Object currentValue)
throws ConverterException {
@@ -165,4 +177,149 @@
return width;
}
+
+ public static List<SelectItem> getItemsToRender(javax.faces.component.UISelectOne component) {
+ return getItems(component);
+ }
+
+ public static List<SelectItem> getItemsToRender(javax.faces.component.UISelectMany component) {
+ return getItems(component);
+ }
+
+ public static List<SelectItem> getItems(javax.faces.component.UIInput component) {
+
+ List<SelectItem> selectItems = getSelectItems(component);
+
+ String renderRange = (String)
+ component.getAttributes().get(org.apache.myfaces.tobago.TobagoConstants.ATTR_RENDER_RANGE_EXTERN);
+ if (renderRange == null) {
+ renderRange = (String)
+ component.getAttributes().get(org.apache.myfaces.tobago.TobagoConstants.ATTR_RENDER_RANGE);
+ }
+ if (renderRange == null) {
+ return selectItems;
+ }
+
+ int[] indices = RangeParser.getIndices(renderRange);
+ List<SelectItem> items = new ArrayList<SelectItem>(indices.length);
+
+ if (selectItems.size() != 0) {
+ for (int indice : indices) {
+ items.add(selectItems.get(indice));
+ }
+ } else {
+ LOG.warn("No items found! rendering dummys instead!");
+ for (int i = 0; i < indices.length; i++) {
+ items.add(new SelectItem(Integer.toString(i), "Item " + i, ""));
+ }
+ }
+ return items;
+ }
+
+ public static String currentValue(UIComponent component) {
+ String currentValue = null;
+ if (component instanceof ValueHolder) {
+ Object value;
+ if (component instanceof EditableValueHolder) {
+ value = ((EditableValueHolder) component).getSubmittedValue();
+ if (value != null) {
+ return (String) value;
+ }
+ }
+
+ value = ((ValueHolder) component).getValue();
+ if (value != null) {
+ Converter converter = ((ValueHolder) component).getConverter();
+ if (converter == null) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ converter = context.getApplication().createConverter(value.getClass());
+ }
+ if (converter != null) {
+ currentValue =
+ converter.getAsString(FacesContext.getCurrentInstance(),
+ component, value);
+ } else {
+ currentValue = value.toString();
+ }
+ }
+ }
+ return currentValue;
+ }
+
+ public static List<SelectItem> getSelectItems(UIComponent component) {
+
+ ArrayList<SelectItem> list = new ArrayList<SelectItem>();
+
+ for (Object o1 : component.getChildren()) {
+ UIComponent kid = (UIComponent) o1;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("kid " + kid);
+ LOG.debug("kid " + kid.getClass().getName());
+ }
+ if (kid instanceof UISelectItem) {
+ Object value = ((UISelectItem) kid).getValue();
+ if (value == null) {
+ UISelectItem item = (UISelectItem) kid;
+ if (kid instanceof org.apache.myfaces.tobago.component.UISelectItem) {
+ list.add(getSelectItem(
+ (org.apache.myfaces.tobago.component.UISelectItem) kid));
+ } else {
+ list.add(new SelectItem(item.getItemValue() == null ? "" : item.getItemValue(),
+ item.getItemLabel() != null ? item.getItemLabel() : item.getItemValue().toString(),
+ item.getItemDescription()));
+ }
+ } else if (value instanceof SelectItem) {
+ list.add((SelectItem) value);
+ } else {
+ throw new IllegalArgumentException("TYPE ERROR: value NOT instanceof SelectItem. type="
+ + value.getClass().getName());
+ }
+ } else if (kid instanceof UISelectItems) {
+ Object value = ((UISelectItems) kid).getValue();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("value " + value);
+ if (value != null) {
+ LOG.debug("value " + value.getClass().getName());
+ }
+ }
+ if (value == null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("value is null");
+ }
+ } else if (value instanceof SelectItem) {
+ list.add((SelectItem) value);
+ } else if (value instanceof SelectItem[]) {
+ SelectItem[] items = (SelectItem[]) value;
+ list.addAll(Arrays.asList(items));
+ } else if (value instanceof Collection) {
+ for (Object o : ((Collection) value)) {
+ list.add((SelectItem) o);
+ }
+ } else if (value instanceof Map) {
+ for (Object key : ((Map) value).keySet()) {
+ if (key != null) {
+ Object val = ((Map) value).get(key);
+ if (val != null) {
+ list.add(new SelectItem(val.toString(), key.toString(), null));
+ }
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("TYPE ERROR: value NOT instanceof "
+ + "SelectItem, SelectItem[], Collection, Map. type="
+ + value.getClass().getName());
+ }
+ }
+ }
+
+ return list;
+ }
+
+ private static SelectItem getSelectItem(org.apache.myfaces.tobago.component.UISelectItem component) {
+ return
+ new org.apache.myfaces.tobago.model.SelectItem(component.getItemValue() == null ? "" : component.getItemValue(),
+ component.getItemLabel(), component.getItemDescription(),
+ component.isItemDisabled(), component.getItemImage(), component.getMarkup());
+ }
+
}
Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java Wed Apr 2 12:36:26 2008
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.component.AbstractUIPage;
import org.apache.myfaces.tobago.renderkit.PageRendererBase;
import javax.faces.component.UIComponent;
@@ -44,7 +44,7 @@
public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException {
- UIPage page = (UIPage) component;
+ AbstractUIPage page = (AbstractUIPage) component;
ResponseWriter writer = facesContext.getResponseWriter();
Modified: myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/pom.xml?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/pom.xml Wed Apr 2 12:36:26 2008
@@ -39,6 +39,10 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
Copied: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/OnComponentCreated.java (from r638966, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/OnComponentCreated.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/OnComponentCreated.java?p2=myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/OnComponentCreated.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/OnComponentCreated.java&r1=638966&r2=644014&rev=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/OnComponentCreated.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/OnComponentCreated.java Wed Apr 2 12:36:26 2008
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.component;
+package org.apache.myfaces.tobago;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/OnComponentCreated.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/OnComponentCreated.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/internal/taglib12/TobagoELTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/internal/taglib12/TobagoELTag.java?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/internal/taglib12/TobagoELTag.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/internal/taglib12/TobagoELTag.java Wed Apr 2 12:36:26 2008
@@ -0,0 +1,47 @@
+package org.apache.myfaces.tobago.internal.taglib12;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.OnComponentCreated;
+
+import javax.faces.webapp.UIComponentELTag;
+import javax.faces.component.UIComponent;
+import javax.servlet.jsp.JspException;
+
+
+public abstract class TobagoELTag extends UIComponentELTag {
+
+ private static final Log LOG = LogFactory.getLog(TobagoELTag.class);
+
+ public int doEndTag() throws JspException {
+ UIComponent component = getComponentInstance();
+ if (component instanceof OnComponentCreated
+ && component.getAttributes().get("org.apache.myfaces.tobago.CREATION_MARKER") == null) {
+ component.getAttributes().put("org.apache.myfaces.tobago.CREATION_MARKER", Boolean.TRUE);
+ ((OnComponentCreated) component).onComponentCreated();
+ }
+ return super.doEndTag();
+ }
+
+ public String[] splitList(String renderers) {
+ return StringUtils.split(renderers, ", ");
+ }
+}
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/internal/taglib12/TobagoELTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/internal/taglib12/TobagoELTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/pom.xml?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/pom.xml Wed Apr 2 12:36:26 2008
@@ -29,7 +29,7 @@
<dependencies>
<dependency>
- <groupId>javax.servlet</groupId>
+ <groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</dependency>
<dependency>
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContent.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContent.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContent.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContent.java Wed Apr 2 12:36:26 2008
@@ -19,7 +19,6 @@
/*
* Created: Apr 20, 2005 5:08:01 PM
- * User: bommel
* $Id$
*/
public enum BodyContent {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContentDescription.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContentDescription.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContentDescription.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/BodyContentDescription.java Wed Apr 2 12:36:26 2008
@@ -19,7 +19,6 @@
/*
* Created: Apr 20, 2005 4:02:24 PM
- * User: bommel
* $Id$
*/
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Category.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Category.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Category.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Category.java Wed Apr 2 12:36:26 2008
@@ -18,9 +18,7 @@
*/
/*
- * User: bommel
- * Date: Jan 19, 2007
- * Time: 12:25:53 PM
+ * $Id$
*/
public enum Category {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/DynamicExpression.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/DynamicExpression.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/DynamicExpression.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/DynamicExpression.java Wed Apr 2 12:36:26 2008
@@ -19,21 +19,22 @@
/*
* Created: Apr 27, 2005 5:08:45 PM
- * User: bommel
* $Id$
*/
public enum DynamicExpression {
- VALUE_BINDING(false, true), VALUE_BINDING_REQUIRED(true, true),
- METHOD_BINDING(false, false), METHOD_BINDING_REQUIRED(true, false),
- PROHIBITED(false, false);
+ VALUE_BINDING(false, true, false), VALUE_BINDING_REQUIRED(true, true, false),
+ METHOD_BINDING(false, false, true), METHOD_BINDING_REQUIRED(true, false, true),
+ PROHIBITED(false, false, false);
private boolean required;
private boolean valueExpression;
+ private boolean methodExpression;
- DynamicExpression(boolean required, boolean valueExpression) {
+ DynamicExpression(boolean required, boolean valueExpression, boolean methodExpression) {
this.required = required;
this.valueExpression = valueExpression;
+ this.methodExpression = methodExpression;
}
public boolean isRequired() {
@@ -42,6 +43,10 @@
public boolean isValueExpression() {
return valueExpression;
+ }
+
+ public boolean isMethodExpression() {
+ return methodExpression;
}
public String toMetaDataString() {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Facet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Facet.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Facet.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Facet.java Wed Apr 2 12:36:26 2008
@@ -23,7 +23,6 @@
import java.lang.annotation.ElementType;
/*
- * User: bommel
* Date: Sep 30, 2006
* Time: 5:49:10 PM
*/
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Preliminary.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Preliminary.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Preliminary.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Preliminary.java Wed Apr 2 12:36:26 2008
@@ -17,11 +17,18 @@
* limitations under the License.
*/
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
/**
* Mark the code as 'Preliminary'.
* The interface maybe subject to changed in a future version.
*
*/
+@Retention(value = RetentionPolicy.SOURCE)
+@Target(value = ElementType.TYPE)
public @interface Preliminary {
String value() default "";
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Tag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Tag.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Tag.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Tag.java Wed Apr 2 12:36:26 2008
@@ -24,7 +24,6 @@
/*
* Created: Mar 8, 2005 5:40:59 PM
- * User: bommel
* $Id$
*/
@Retention(value = RetentionPolicy.SOURCE)
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/TagAttribute.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/TagAttribute.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/TagAttribute.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/TagAttribute.java Wed Apr 2 12:36:26 2008
@@ -24,7 +24,6 @@
/*
* Created: Mar 8, 2005 5:37:08 PM
- * User: bommel
* $Id$
*/
@Retention(value = RetentionPolicy.SOURCE)
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Taglib.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Taglib.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Taglib.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/Taglib.java Wed Apr 2 12:36:26 2008
@@ -24,7 +24,6 @@
/*
* Created: Apr 20, 2005 6:55:06 PM
- * User: bommel
* $Id$
*/
@Retention(value = RetentionPolicy.SOURCE)
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTag.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTag.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTag.java Wed Apr 2 12:36:26 2008
@@ -24,7 +24,6 @@
/*
* Created: Aug 5, 2005 3:11:18 PM
- * User: bommel
* $Id$
*/
@@ -47,9 +46,7 @@
boolean isLayout() default false;
- boolean isAjaxEnabled() default false;
-
- boolean namingContainer() default false;
+ String[] interfaces() default {};
Facet[] facets() default {};
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java Wed Apr 2 12:36:26 2008
@@ -44,6 +44,8 @@
String defaultValue() default "";
+ String defaultCode() default "";
+
String displayName() default "";
/**
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/pom.xml?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/pom.xml Wed Apr 2 12:36:26 2008
@@ -49,7 +49,7 @@
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
+ <groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</dependency>
<dependency>
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java Wed Apr 2 12:36:26 2008
@@ -27,8 +27,8 @@
import org.apache.myfaces.tobago.apt.generate.ComponentInfo;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
import org.apache.myfaces.tobago.apt.annotation.Tag;
-import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
import org.apache.commons.io.IOUtils;
import java.io.InputStream;
@@ -44,6 +44,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.Filer;
@@ -101,11 +103,17 @@
+ tag.name().substring(0, 1).toUpperCase(Locale.ENGLISH) + tag.name().substring(1) + "Tag";
TagInfo tagInfo = new TagInfo(className, componentTag.rendererType());
if (tag.isBodyTag()) {
- tagInfo.setSuperClass("org.apache.myfaces.tobago.taglib.component.TobagoBodyTag");
+ tagInfo.setSuperClass("org.apache.myfaces.tobago.internal.taglib.TobagoBodyTag");
} else {
- tagInfo.setSuperClass("org.apache.myfaces.tobago.taglib.component.TobagoTag");
+ tagInfo.setSuperClass("org.apache.myfaces.tobago.internal.taglib.TobagoTag");
}
tagInfo.setComponentClassName(componentTag.uiComponent());
+ tagInfo.addImport("org.apache.commons.logging.Log");
+ tagInfo.addImport("org.apache.commons.logging.LogFactory");
+ tagInfo.addImport("javax.faces.application.Application");
+ tagInfo.addImport("javax.faces.component.UIComponent");
+ tagInfo.addImport("javax.faces.context.FacesContext");
+
StringTemplate stringTemplate = tagStringTemplateGroup.getInstanceOf("tag");
stringTemplate.setAttribute("tagInfo", tagInfo);
tagInfo.getProperties().addAll(properties);
@@ -117,13 +125,8 @@
ComponentInfo componentInfo = new ComponentInfo(componentTag.uiComponent(), componentTag.rendererType());
componentInfo.setSuperClass(componentTag.uiComponentBaseClass());
componentInfo.setComponentFamily(componentTag.componentFamily());
- componentInfo.setNamingContainer(componentTag.namingContainer());
- componentInfo.setAjaxComponent(componentTag.isAjaxEnabled());
- if (componentInfo.isAjaxComponent()) {
- componentInfo.addInterface("org.apache.myfaces.tobago.ajax.api.AjaxComponent");
- }
- if (componentInfo.isNamingContainer()) {
- componentInfo.addInterface("javax.faces.component.NamingContainer");
+ for (String interfaces:componentTag.interfaces()) {
+ componentInfo.addInterface(interfaces);
}
if (componentTag.componentType().length() > 0) {
componentInfo.setComponentType(componentTag.componentType());
@@ -131,28 +134,23 @@
componentInfo.setComponentType(componentTag.uiComponent().replace(".component.UI", "."));
}
try {
- Class compenentClass = Class.forName(componentTag.uiComponentBaseClass());
+ Class componentClass = Class.forName(componentTag.uiComponentBaseClass());
int index = 0;
for (PropertyInfo info:properties) {
try {
String methodName = (info.getType().equals("java.lang.Boolean")?"is":"get") + info.getUpperCamelCaseName();
- compenentClass.getMethod(methodName);
+ Method method = componentClass.getMethod(methodName);
+ if (Modifier.isAbstract(method.getModifiers())) {
+ addPropertyToComponent(componentInfo, info, index);
+ index++;
+ }
} catch (NoSuchMethodException e) {
- ComponentPropertyInfo componentPropertyInfo =
- (ComponentPropertyInfo) info.fill(new ComponentPropertyInfo());
- componentPropertyInfo.setIndex(index);
- componentInfo.getProperties().add(componentPropertyInfo);
- if ("suggestMethod".equals(info.getName())) {
- componentInfo.addInterface("org.apache.myfaces.tobago.component.InputSuggest");
- }
- if ("markup".equals(info.getName())) {
- componentInfo.setMarkup(true);
- }
+ addPropertyToComponent(componentInfo, info, index);
index++;
}
}
try {
- compenentClass.getMethod("invokeOnComponent");
+ componentClass.getMethod("invokeOnComponent");
} catch (NoSuchMethodException e) {
componentInfo.setInvokeOnComponent(true);
componentInfo.addImport("javax.faces.context.FacesContext");
@@ -163,10 +161,14 @@
}
} catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- if (componentInfo.hasMarkup()) {
- componentInfo.addInterface("org.apache.myfaces.tobago.component.SupportsMarkup");
+ List<PropertyInfo> baseClassProperties = getBaseClassProperties(componentTag.uiComponentBaseClass());
+ int index = 0;
+ for (PropertyInfo info:properties) {
+ if (!baseClassProperties.contains(info)) {
+ addPropertyToComponent(componentInfo, info, index);
+ index++;
+ }
+ }
}
componentStringTemplate.setAttribute("componentInfo", componentInfo);
@@ -175,6 +177,35 @@
}
+ private List<PropertyInfo> getBaseClassProperties(String baseClass) {
+ for (InterfaceDeclaration decl: getCollectedInterfaceDeclarations()) {
+ if (decl.getAnnotation(UIComponentTag.class)!= null) {
+ if (decl.getAnnotation(UIComponentTag.class).uiComponent().equals(baseClass)
+ && decl.getAnnotation(UIComponentTag.class).generate()) {
+ List<PropertyInfo> properties = new ArrayList<PropertyInfo>();
+ addProperties(decl, properties);
+ return properties;
+ }
+ }
+ }
+ throw new IllegalStateException("No UIComponentTag found for componentClass " + baseClass);
+ }
+
+ private void addPropertyToComponent(ComponentInfo componentInfo, PropertyInfo info, int index) {
+ ComponentPropertyInfo componentPropertyInfo =
+ (ComponentPropertyInfo) info.fill(new ComponentPropertyInfo());
+ componentPropertyInfo.setIndex(index);
+ componentInfo.addImport(info.getUnmodifiedType());
+ componentInfo.addImport("javax.faces.context.FacesContext");
+ componentInfo.getProperties().add(componentPropertyInfo);
+ if ("suggestMethod".equals(info.getName())) {
+ componentInfo.addInterface("org.apache.myfaces.tobago.component.InputSuggest");
+ }
+ if ("markup".equals(info.getName())) {
+ componentInfo.addInterface("org.apache.myfaces.tobago.component.SupportsMarkup");
+ }
+ }
+
private void createRenderer(TypeDeclaration decl) {
UIComponentTag componentTag = decl.getAnnotation(UIComponentTag.class);
@@ -188,14 +219,16 @@
}
renderer.add(className);
RendererInfo info = new RendererInfo(className, rendererType);
+ boolean ajaxEnabled =
+ Arrays.asList(componentTag.interfaces()).contains("org.apache.myfaces.tobago.ajax.api.AjaxComponent");
if (componentTag.isLayout()) {
info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractLayoutRendererWrapper");
- } else if (componentTag.isAjaxEnabled()) {
+ } else if (ajaxEnabled) {
info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractAjaxRendererBaseWrapper");
} else {
info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractLayoutableRendererBaseWrapper");
}
- if (componentTag.isAjaxEnabled()) {
+ if (ajaxEnabled) {
info.addInterface("org.apache.myfaces.tobago.ajax.api.AjaxRenderer");
}
StringTemplate stringTemplate = rendererStringTemplateGroup.getInstanceOf("renderer");
@@ -220,7 +253,7 @@
}
protected void addProperty(MethodDeclaration decl, List<PropertyInfo> properties) {
- TagAttribute tagAttribute = decl.getAnnotation(TagAttribute.class);
+ //TagAttribute tagAttribute = decl.getAnnotation(TagAttribute.class);
UIComponentTagAttribute uiComponentTagAttribute = decl.getAnnotation(UIComponentTagAttribute.class);
if (uiComponentTagAttribute != null) {
String simpleName = decl.getSimpleName();
@@ -232,12 +265,16 @@
PropertyInfo propertyInfo = new PropertyInfo(attributeStr);
propertyInfo.setAllowdValues(uiComponentTagAttribute.allowedValues());
String type;
- if (uiComponentTagAttribute.expression().isRequired()) {
- if (uiComponentTagAttribute.expression().isValueExpression()) {
- type = "javax.faces.el.ValueBinding";
+ if (uiComponentTagAttribute.expression().isMethodExpression()) {
+ type = "javax.faces.el.MethodBinding";
+ } else if (uiComponentTagAttribute.expression() == DynamicExpression.VALUE_BINDING_REQUIRED) {
+ propertyInfo.setValueExpressionRequired(true);
+ if (uiComponentTagAttribute.type().length > 1) {
+ type = "java.lang.Object";
} else {
- type = "javax.faces.el.MethodBinding";
+ type = uiComponentTagAttribute.type()[0];
}
+
} else if (uiComponentTagAttribute.type().length == 1) {
type = uiComponentTagAttribute.type()[0];
} else {
@@ -247,6 +284,8 @@
propertyInfo.setType(type);
propertyInfo.setDefaultValue(uiComponentTagAttribute.defaultValue().length() > 0
?uiComponentTagAttribute.defaultValue():null);
+ propertyInfo.setDefaultCode(uiComponentTagAttribute.defaultCode().length() > 0
+ ?uiComponentTagAttribute.defaultCode():null);
propertyInfo.setMethodSignature(uiComponentTagAttribute.methodSignature());
propertyInfo.setDeprecated(decl.getAnnotation(Deprecated.class) != null);
properties.add(propertyInfo);
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/FacesConfigAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/FacesConfigAnnotationVisitor.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/FacesConfigAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/FacesConfigAnnotationVisitor.java Wed Apr 2 12:36:26 2008
@@ -472,7 +472,7 @@
private void addClass(UIComponentTagAttribute componentAttribute, Element attributeClass) {
if (componentAttribute.type().length > 1) {
attributeClass.setText(Object.class.getName());
- } else {
+ } else if (componentAttribute.type().length == 1) {
String className = componentAttribute.type()[0];
attributeClass.setText(className.equals(Boolean.class.getName()) ? "boolean" : className);
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java Wed Apr 2 12:36:26 2008
@@ -21,15 +21,15 @@
private int index;
public String getPropertyTemplate() {
- return getShortType() + "Property";
+ return getShortTypeProperty() + "Property";
}
public String getPropertySaveStateTemplate() {
- return getShortType() + "SaveStateProperty";
+ return getShortTypeProperty() + "SaveStateProperty";
}
public String getPropertyRestoreStateTemplate() {
- return getShortType() + "RestoreStateProperty";
+ return getShortTypeProperty() + "RestoreStateProperty";
}
public int getIndex() {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/Imports.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/Imports.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/Imports.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/Imports.java Wed Apr 2 12:36:26 2008
@@ -37,6 +37,10 @@
public void addImport(String qualifiedName) {
if (!ClassUtils.isSystemClass(qualifiedName) && !ClassUtils.isPrimitive(qualifiedName)) {
if (!(packageName != null && packageName.equals(ClassUtils.getPackageName(qualifiedName)))) {
+ int index = qualifiedName.lastIndexOf('$');
+ if (index != -1) {
+ qualifiedName = qualifiedName.substring(0, index);
+ }
if (!imports.contains(qualifiedName)) {
imports.add(qualifiedName);
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java Wed Apr 2 12:36:26 2008
@@ -25,6 +25,9 @@
private String[] allowdValues;
private String[] methodSignature;
private String defaultValue;
+ private String defaultCode;
+ private boolean valueExpressionRequired;
+ private boolean literal;
private boolean deprecated;
public PropertyInfo() {
@@ -34,6 +37,24 @@
this.name = name;
}
+ public boolean isLiteral() {
+ return literal;
+ }
+
+ public void setLiteral(boolean literal) {
+ this.literal = literal;
+ }
+
+ public String getTemplate() {
+ if (valueExpressionRequired) {
+ return "ValueExpression";
+ }
+ if (isMethodBinding()) {
+ return getUpperCamelCaseName();
+ }
+ return getShortTypeProperty();
+ }
+
public String getName() {
return name;
}
@@ -43,9 +64,17 @@
}
public String getType() {
+ return type.replace("$", ".");
+ }
+
+ public String getUnmodifiedType() {
return type;
}
+ public boolean isWidthOrHeight() {
+ return "width".equals(name) || "height".equals(name);
+ }
+
public void setType(String type) {
this.type = type;
}
@@ -56,7 +85,16 @@
public String getShortType() {
String shortType = type.substring(type.lastIndexOf('.')+1, type.length());
- return shortType.replace("[]", "Array");
+ return shortType.replace("[]", "Array").replace("$", ".");
+ }
+
+ public String getShortTypeProperty() {
+ String type = getShortType();
+ int index = type.lastIndexOf('.');
+ if (index != -1) {
+ return type.substring(type.lastIndexOf('.')+1, type.length());
+ }
+ return type;
}
public String getUpperCamelCaseName() {
@@ -102,6 +140,31 @@
return deprecated;
}
+ public String getDefaultCode() {
+ if (defaultCode == null && defaultValue != null) {
+ if (String.class.getName().equals(type)) {
+ return "\"" + defaultValue + "\"";
+ } else if (Character.class.getName().equals(type)) {
+ return "'" + defaultValue + "'";
+ } else {
+ return defaultValue;
+ }
+ }
+ return defaultCode;
+ }
+
+ public void setDefaultCode(String defaultCode) {
+ this.defaultCode = defaultCode;
+ }
+
+ public boolean isValueExpressionRequired() {
+ return valueExpressionRequired;
+ }
+
+ public void setValueExpressionRequired(boolean valueExpressionRequired) {
+ this.valueExpressionRequired = valueExpressionRequired;
+ }
+
public PropertyInfo fill(PropertyInfo info) {
info.setName(name);
info.setType(type);
@@ -109,6 +172,27 @@
info.setDefaultValue(defaultValue);
info.setDeprecated(deprecated);
info.setMethodSignature(methodSignature);
+ info.setDefaultCode(defaultCode);
+ info.setValueExpressionRequired(valueExpressionRequired);
+ info.setLiteral(literal);
return info;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof PropertyInfo)) {
+ return false;
+ }
+
+ PropertyInfo that = (PropertyInfo) o;
+
+ return name.equals(that.name);
+
+ }
+
+ public int hashCode() {
+ return name.hashCode();
}
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java Wed Apr 2 12:36:26 2008
@@ -26,9 +26,6 @@
private String componentClassName;
private String componentType;
private String componentFamily;
- private boolean ajaxComponent;
- private boolean namingContainer;
- private boolean markup;
public TagInfo(String qualifiedName, String rendererName) {
super(qualifiedName, rendererName);
@@ -41,6 +38,7 @@
public int getPropertiesSize() {
return properties.size();
}
+
public int getPropertiesSizePlusOne() {
return properties.size() + 1;
}
@@ -72,29 +70,5 @@
if (componentFamily != null && componentFamily.length() > 0) {
this.componentFamily = componentFamily;
}
- }
-
- public boolean isAjaxComponent() {
- return ajaxComponent;
- }
-
- public void setAjaxComponent(boolean ajaxComponent) {
- this.ajaxComponent = ajaxComponent;
- }
-
- public boolean isNamingContainer() {
- return namingContainer;
- }
-
- public void setNamingContainer(boolean namingContainer) {
- this.namingContainer = namingContainer;
- }
-
- public boolean hasMarkup() {
- return markup;
- }
-
- public void setMarkup(boolean markup) {
- this.markup = markup;
}
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg Wed Apr 2 12:36:26 2008
@@ -18,13 +18,27 @@
*/
component(componentInfo) ::= <<
+//------------------ GENERATED CODE (do not modify!) --------------------
+
package <componentInfo.packageName>;
-<if(componentInfo.properties)>
-import javax.faces.el.ValueBinding;
-import javax.faces.context.FacesContext;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-<endif>
<componentInfo.imports:import(); separator="\n">
public class <componentInfo.className>
@@ -38,15 +52,14 @@
public static final String COMPONENT_FAMILY = "<componentInfo.componentFamily>";
<endif>
-
<componentInfo.properties:field(); separator="\n">
<if(componentInfo.componentFamily)>
public String getFamily() {
return COMPONENT_FAMILY;
}
- <endif>
+ <endif>
<componentInfo.properties:{ p | <p:(p.propertyTemplate)()>}; separator="\n">
<if(componentInfo.properties)>
@@ -63,6 +76,7 @@
return values;
}
<endif>
+
<if(componentInfo.invokeOnComponent)>
<invokeOnComponent()>
<endif>
@@ -82,54 +96,43 @@
IntegerProperty(property) ::= <<
-public Integer get<property.upperCamelCaseName>() {
+public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
}
- ValueBinding vb = getValueBinding("<property.name>");
+ <getValueExpression(property)>
if (vb != null) {
- Number number = (Number) vb.getValue(getFacesContext());
+ Number number = (Number) <getValue(property)>
if (number != null) {
return number.intValue();
}
}
- <if(property.defaultValue)>
- return <property.defaultValue>;
+ <if(property.defaultCode)>
+ return <property.defaultCode>;
<else>
return null;
<endif>
}
-public void set<property.upperCamelCaseName>(Integer <property.propertyName>) {
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
>>
-StringProperty(property) ::= <<
+ObjectProperty(property) ::= <<
-public String get<property.upperCamelCaseName>() {
+public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
}
- ValueBinding vb = getValueBinding("<property.name>");
+ <getValueExpression(property)>
if (vb != null) {
- <if(property.defaultValue)>
- String str = (String) vb.getValue(getFacesContext());
- if (str != null) {
- return str;
- }
- <else>
- return (String) vb.getValue(getFacesContext());
- <endif>
+ return (<property.type>) <getValue(property)>
}
- <if(property.defaultValue)>
- return "<property.defaultValue>";
- <else>
return null;
- <endif>
}
-public void set<property.upperCamelCaseName>(String <property.propertyName>) {
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
>>
@@ -140,9 +143,9 @@
if (<property.propertyName> != null) {
return <property.propertyName>;
}
- ValueBinding vb = getValueBinding("<property.name>");
+ <getValueExpression(property)>
if (vb != null) {
- Object strArray = vb.getValue(getFacesContext());
+ Object strArray = <getValue(property)>
if (strArray instanceof String[]) {
return (String[]) strArray;
} else if (strArray instanceof String) {
@@ -174,17 +177,15 @@
if (<property.propertyName> != null) {
return <property.propertyName>;
}
- ValueBinding vb = getValueBinding("<property.name>");
+ <getValueExpression(property)>
if (vb != null) {
- <if(property.defaultValue)>
- Boolean bool = (Boolean) vb.getValue(getFacesContext());
+ Boolean bool = (Boolean) <getValue(property)>
if (bool != null) {
return bool;
}
- <endif>
}
- <if(property.defaultValue)>
- return <property.defaultValue>;
+ <if(property.defaultCode)>
+ return <property.defaultCode>;
<else>
return false;
<endif>
@@ -195,45 +196,66 @@
}
>>
+SeverityProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+OrderByProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+WizardProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+StringProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
CharacterProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+MethodBindingProperty(property) ::= <<
-public Character get<property.upperCamelCaseName>() {
+public <property.type> get<property.upperCamelCaseName>() {
+ return <property.propertyName>;
+}
+
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+NormalProperty(property) ::= <<
+
+public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
}
- ValueBinding vb = getValueBinding("<property.name>");
+ <getValueExpression(property)>
if (vb != null) {
- <if(property.defaultValue)>
- Character str = (Character) vb.getValue(getFacesContext());
- if (str != null) {
- return str;
+ <if(property.defaultCode)>
+ <property.type> <property.propertyName> = (<property.type>) <getValue(property)>
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
}
<else>
- return (Character) vb.getValue(getFacesContext());
+ return (<property.type>) <getValue(property)>
<endif>
}
- <if(property.defaultValue)>
- return '<property.defaultValue>';
+ <if(property.defaultCode)>
+ return <property.defaultCode>;
<else>
return null;
<endif>
}
-public void set<property.upperCamelCaseName>(Character <property.propertyName>) {
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
>>
-MethodBindingProperty(property) ::= <<
-
-public MethodBinding get<property.upperCamelCaseName>() {
- return <property.propertyName>;
-}
-
-public void set<property.upperCamelCaseName>(Character <property.propertyName>) {
- this.<property.propertyName> = <property.propertyName>;
-
->>
field() ::= <<
private <it.type> <it.propertyName>;
@@ -247,6 +269,14 @@
values[<it.indexPlusOne>] = <it.propertyName>;
>>
+WizardSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+ObjectSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
IntegerSaveStateProperty() ::= <<
values[<it.indexPlusOne>] = <it.propertyName>;
>>
@@ -267,10 +297,27 @@
values[<it.indexPlusOne>] = <it.propertyName>;
>>
+SeveritySaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+OrderBySaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
MethodBindingSaveStateProperty() ::= <<
values[<it.indexPlusOne>] = saveAttachedState(context, <it.propertyName>);
>>
+
+WizardRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+ObjectRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
IntegerRestoreStateProperty() ::= <<
<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
>>
@@ -291,6 +338,24 @@
<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
>>
+SeverityRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+OrderByRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
MethodBindingRestoreStateProperty() ::= <<
<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.indexPlusOne>]);
+>>
+
+
+
+getValueExpression(property) ::= <<
+javax.faces.el.ValueBinding vb = getValueBinding("<property.name>");
+>>
+
+getValue(property) ::= <<
+vb.getValue(getFacesContext());
>>
Added: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component12.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component12.stg?rev=644014&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component12.stg (added)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component12.stg Wed Apr 2 12:36:26 2008
@@ -0,0 +1,381 @@
+group components;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+component(componentInfo) ::= <<
+//------------------ GENERATED CODE (do not modify!) --------------------
+
+package <componentInfo.packageName>;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+<componentInfo.imports:import(); separator="\n">
+
+public class <componentInfo.className>
+ extends <componentInfo.superClassName> <first(componentInfo.interfaces):{ n | implements <n>}><rest(componentInfo.interfaces):{ n | , <n> }> {
+
+ <if(componentInfo.componentType)>
+ public static final String COMPONENT_TYPE = "<componentInfo.componentType>";
+
+ <endif>
+ <if(componentInfo.componentFamily)>
+ public static final String COMPONENT_FAMILY = "<componentInfo.componentFamily>";
+
+ <endif>
+ <componentInfo.properties:field(); separator="\n">
+
+ <if(componentInfo.componentFamily)>
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ <endif>
+ <componentInfo.properties:{ p | <p:(p.propertyTemplate)()>}; separator="\n">
+
+ <if(componentInfo.properties)>
+ public void restoreState(FacesContext context, Object state) {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ <componentInfo.properties:{ p | <p:(p.propertyRestoreStateTemplate)()>}; separator="\n">
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] values = new Object[<componentInfo.propertiesSizePlusOne>];
+ values[0] = super.saveState(context);
+ <componentInfo.properties:{ p | <p:(p.propertySaveStateTemplate)()>}; separator="\n">
+ return values;
+ }
+ <endif>
+
+ <if(componentInfo.invokeOnComponent)>
+ <invokeOnComponent()>
+ <endif>
+
+}
+>>
+
+import() ::= <<
+import <it>;
+>>
+invokeOnComponent() ::= <<
+public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+ return FacesUtils.invokeOnComponent(context, this, clientId, callback);
+}
+>>
+
+IntegerProperty(property) ::= <<
+
+public <property.type> get<property.upperCamelCaseName>() {
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
+ }
+ <getValueExpression(property)>
+ if (ve != null) {
+ try {
+ Number number = (Number) <getValue(property)>
+ if (number != null) {
+ return number.intValue();
+ }
+ } catch (javax.el.ELException e) {
+ throw new javax.faces.FacesException(e);
+ }
+ }
+ <if(property.defaultCode)>
+ return <property.defaultCode>;
+ <else>
+ return null;
+ <endif>
+}
+
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+ObjectProperty(property) ::= <<
+
+public <property.type> get<property.upperCamelCaseName>() {
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
+ }
+ <getValueExpression(property)>
+ if (ve != null) {
+ try {
+ return (<property.type>) <getValue(property)>
+ } catch (javax.el.ELException e) {
+ throw new javax.faces.FacesException(e);
+ }
+ }
+ return null;
+}
+
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+StringArrayProperty(property) ::= <<
+
+public String[] get<property.upperCamelCaseName>() {
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
+ }
+ <getValueExpression(property)>
+ if (ve != null) {
+ try {
+ Object strArray = <getValue(property)>
+ if (strArray instanceof String[]) {
+ return (String[]) strArray;
+ } else if (strArray instanceof String) {
+ String[] strings = ((String) strArray).split("[, ]");
+ java.util.List\<String\> result = new java.util.ArrayList\<String\>(strings.length);
+ for (String string : strings) {
+ if (string.trim().length() != 0) {
+ result.add(string.trim());
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ } else if (strArray == null) {
+ return new String[0];
+ } else {
+ return new String[]{strArray.toString()};
+ }
+ } catch (javax.el.ELException e) {
+ throw new javax.faces.FacesException(e);
+ }
+ }
+ return new String[0];
+}
+
+public void set<property.upperCamelCaseName>(String[] <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+BooleanProperty(property) ::= <<
+
+public boolean is<property.upperCamelCaseName>() {
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
+ }
+ <getValueExpression(property)>
+ if (ve != null) {
+ try {
+ Boolean bool = (Boolean) <getValue(property)>
+ if (bool != null) {
+ return bool;
+ }
+ } catch (javax.el.ELException e) {
+ throw new javax.faces.FacesException(e);
+ }
+ }
+ <if(property.defaultCode)>
+ return <property.defaultCode>;
+ <else>
+ return false;
+ <endif>
+}
+
+public void set<property.upperCamelCaseName>(boolean <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+SeverityProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+OrderByProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+WizardProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+StringProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+CharacterProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+MethodBindingProperty(property) ::= <<
+
+public <property.type> get<property.upperCamelCaseName>() {
+ return <property.propertyName>;
+}
+
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+NormalProperty(property) ::= <<
+
+public <property.type> get<property.upperCamelCaseName>() {
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
+ }
+ <getValueExpression(property)>
+ if (ve != null) {
+ try {
+ <if(property.defaultCode)>
+ <property.type> <property.propertyName> = (<property.type>) <getValue(property)>
+ if (<property.propertyName> != null) {
+ return <property.propertyName>;
+ }
+ <else>
+ return (<property.type>) <getValue(property)>
+ <endif>
+ } catch (javax.el.ELException e) {
+ throw new javax.faces.FacesException(e);
+ }
+ }
+ <if(property.defaultCode)>
+ return <property.defaultCode>;
+ <else>
+ return null;
+ <endif>
+}
+
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+ this.<property.propertyName> = <property.propertyName>;
+}
+>>
+
+
+field() ::= <<
+private <it.type> <it.propertyName>;
+>>
+
+restoreStateField() ::= <<
+<it.propertyName> = (<it.type>) values[<i>];
+>>
+
+saveStateField() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+WizardSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+ObjectSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+IntegerSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+StringSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+StringArraySaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+BooleanSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+CharacterSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+SeveritySaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+OrderBySaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = <it.propertyName>;
+>>
+
+MethodBindingSaveStateProperty() ::= <<
+values[<it.indexPlusOne>] = saveAttachedState(context, <it.propertyName>);
+>>
+
+
+WizardRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+ObjectRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+IntegerRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+StringRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+StringArrayRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+BooleanRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+CharacterRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+SeverityRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+OrderByRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+>>
+
+MethodBindingRestoreStateProperty() ::= <<
+<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.indexPlusOne>]);
+>>
+
+
+
+getValueExpression(property) ::= <<
+javax.el.ValueExpression ve = getValueExpression("<property.name>");
+>>
+
+getValue(property) ::= <<
+ve.getValue(getFacesContext().getELContext());
+>>
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tag.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tag.stg?rev=644014&r1=644013&r2=644014&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tag.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tag.stg Wed Apr 2 12:36:26 2008
@@ -19,11 +19,27 @@
tag(tagInfo) ::= <<
+//------------------ GENERATED CODE BEGIN (do not modify!) --------------------
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package <tagInfo.packageName>;
-import javax.faces.component.UIComponent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
<tagInfo.imports:import(); separator="\n">
public class <tagInfo.className> extends <tagInfo.superClassName> {
@@ -34,28 +50,33 @@
public String getComponentType() {
return <tagInfo.componentClassName>.COMPONENT_TYPE;
}
-
+ @Override
public String getRendererType() {
<if(tagInfo.rendererName)>
- return "<tagInfo.rendererName>";
+ return "<tagInfo.rendererName>";
<else>
- return null;
+ return null;
<endif>
}
+ <if(tagInfo.properties)>
@Override
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
- <tagInfo.properties:setProperty(); separator="\n">
+ protected void setProperties(UIComponent uiComponent) {
+ super.setProperties(uiComponent);
+ <tagInfo.componentClassName> component = (<tagInfo.componentClassName>) uiComponent;
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application application = context.getApplication();
+ <tagInfo.properties:{ p | <p:(p.template)()>}; separator="\n">
}
<tagInfo.properties:property(); separator="\n">
- @Override
+ @Override
public void release() {
super.release();
<tagInfo.properties:release(); separator="\n">
}
+ <endif>
}
>>
@@ -67,21 +88,6 @@
<it.propertyName> = null;
>>
-setProperty() ::= <<
-<if(it.methodBinding)>
-TagUtils.set<it.upperCamelCaseName><it.shortType>(component, <it.propertyName>,
-new Class[] { <first(it.methodSignature):{ n | <n>.class }><rest(it.methodSignature):{ n | , <n>.class}>} );
-<else>
-<if(it.deprecated)>
-if (<it.propertyName> != null) {
- LOG.warn("The <it.name> attribute is deprecated.");
-}
-
-<endif>
-TagUtils.set<it.shortType>Property(component, "<it.name>", <it.propertyName>);
-<endif>
->>
-
property() ::= <<
public String get<it.upperCamelCaseName>() {
return <it.propertyName>;
@@ -96,5 +102,174 @@
field() ::= <<
private String <it.propertyName>;
>>
+
+ValueExpression() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+}
+>>
+
+String() ::= <<
+<createStringProperty(it)>
+>>
+
+Severity() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.getAttributes().put("<it.name>", <it.propertyName>);
+ }
+}
+>>
+
+Object() ::= <<
+<createStringProperty(it)>
+>>
+
+Character() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(<it.propertyName>.charAt(0));
+ }
+}
+>>
+
+Boolean() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(Boolean.valueOf(<it.propertyName>));
+ }
+}
+>>
+
+Integer() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ <if(it.widthOrHeight)>
+ if (<it.propertyName>.endsWith("px")) {
+ <it.propertyName> = <it.propertyName>.substring(0, <it.propertyName>.length() - 2);
+ }
+ <endif>
+ component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>));
+ }
+}
+>>
+
+OrderBy() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.component.AbstractUIMessages.OrderBy.parse(<it.propertyName>));
+ }
+}
+>>
+
+StringArray() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(splitList(<it.propertyName>));
+ }
+}
+>>
+
+TabChangeListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+ActionListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+ValueChangeListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+StateChangeListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+SortActionListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+SuggestMethod() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+Validator() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.setValidator(methodBinding);
+}
+>>
+
+Action() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.setAction(methodBinding);
+ } else {
+ component.setAction(new org.apache.myfaces.tobago.el.ConstantMethodBinding(<it.propertyName>));
+ }
+}
+>>
+
+Converter() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.setConverter(context.getApplication().createConverter(<it.propertyName>));
+ }
+}
+>>
+
+createMethodBinding(it) ::= <<
+javax.faces.el.MethodBinding methodBinding = application.createMethodBinding(<it.propertyName>,
+ new Class[] { <first(it.methodSignature):{ n | <n>.class }><rest(it.methodSignature):{ n | , <n>.class}>} );
+>>
+
+createStringProperty(it) ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(<it.propertyName>);
+ }
+}
+>>
+
+createValueBinding(it) ::= <<
+component.setValueBinding("<it.name>", application.createValueBinding(<it.propertyName>));
+>>
+