Author: gvanmatre
Date: Wed Oct 18 16:06:50 2006
New Revision: 465411
URL: http://svn.apache.org/viewvc?view=rev&rev=465411
Log:
Change the method of generating component id's to be more in line with the JSP
2.1 JspIdConsumer (SHALE-67). The JspIdConsumer is an interface implement by
Tags. It forces a unique id that is the same - even for multiple requests to
the page. I modified the base configuration bean to generate a unique id per
object instance. These beans are used by clay to build the component instead
of JSP tags. The clay jspid is now used to populate the component's id if not
explicitly provided.
Modified:
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/WEB-INF/faces-config.xml
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/rolodex/jsprolodex.jsp
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/SequenceGenerator.java
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/VerbatimBuilder.java
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/JSFRuntimeTracker.java
Modified:
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/WEB-INF/faces-config.xml
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/WEB-INF/faces-config.xml
(original)
+++
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/WEB-INF/faces-config.xml
Wed Oct 18 16:06:50 2006
@@ -49,7 +49,7 @@
<from-view-id>/usecases*</from-view-id>
<navigation-case>
<from-outcome>rolodex$test1</from-outcome>
- <to-view-id>/rolodex/jsprolodex.faces</to-view-id>
+ <to-view-id>/rolodex/jsprolodex.jsp</to-view-id>
</navigation-case>
<!-- HTML View -->
@@ -99,27 +99,27 @@
<navigation-case>
<from-action>#{rolodex.selectContact}</from-action>
<from-outcome>rolodex$test</from-outcome>
- <to-view-id>/rolodex/jsprolodex.faces</to-view-id>
+ <to-view-id>/rolodex/jsprolodex.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{rolodex.saveContact}</from-action>
<from-outcome>rolodex$test</from-outcome>
- <to-view-id>/rolodex/jsprolodex.faces</to-view-id>
+ <to-view-id>/rolodex/jsprolodex.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{rolodex.deleteContact}</from-action>
<from-outcome>rolodex$test</from-outcome>
- <to-view-id>/rolodex/jsprolodex.faces</to-view-id>
+ <to-view-id>/rolodex/jsprolodex.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{rolodex.newContact}</from-action>
<from-outcome>rolodex$test</from-outcome>
- <to-view-id>/rolodex/jsprolodex.faces</to-view-id>
+ <to-view-id>/rolodex/jsprolodex.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{rolodex.changeTab}</from-action>
<from-outcome>rolodex$test</from-outcome>
- <to-view-id>/rolodex/jsprolodex.faces</to-view-id>
+ <to-view-id>/rolodex/jsprolodex.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>home</from-outcome>
Modified:
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/rolodex/jsprolodex.jsp
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/rolodex/jsprolodex.jsp?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/rolodex/jsprolodex.jsp
(original)
+++
shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/rolodex/jsprolodex.jsp
Wed Oct 18 16:06:50 2006
@@ -3,8 +3,7 @@
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="s" uri="http://shale.apache.org/core"%>
<%@ taglib prefix="val" uri="http://shale.apache.org/validator"%>
-<%@ taglib prefix="clay"
- uri="http://shale.apache.org/clay"%>
+<%@ taglib prefix="clay" uri="http://shale.apache.org/clay"%>
<html>
<head>
<title>Rolodex Example Using Clay</title>
Modified:
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java
(original)
+++
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java
Wed Oct 18 16:06:50 2006
@@ -67,11 +67,11 @@
/**
* <p>Returns a unique component id for the request/response lifecycle.</p>
- *
+ * @param configBean metadata bean used to build the JSF view
* @param facesContext faces context
* @return unique component id
*/
- private String createUniqueId(FacesContext facesContext) {
+ private String createUniqueId(FacesContext facesContext, ComponentBean
configBean) {
String id = null;
if (!isRI11Installed()) {
@@ -82,7 +82,7 @@
generator = new SequenceGenerator();
requestMap.put(Globals.CLAY_SEQUENCE_GENERATOR, generator);
}
- id = generator.createUniqueId();
+ id = generator.createUniqueId(configBean);
} else {
id = facesContext.getViewRoot().createUniqueId();
}
@@ -142,7 +142,7 @@
String id = displayElement.getId();
if (id == null) {
- id = createUniqueId(facesContext);
+ id = createUniqueId(facesContext, displayElement);
} else {
id = replaceMnemonic(clayContext, id);
}
Modified:
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/SequenceGenerator.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/SequenceGenerator.java?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/SequenceGenerator.java
(original)
+++
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/chain/SequenceGenerator.java
Wed Oct 18 16:06:50 2006
@@ -22,6 +22,7 @@
import javax.faces.component.UIViewRoot;
+import org.apache.shale.clay.config.beans.ComponentBean;
import org.apache.shale.clay.utils.JSFRuntimeTracker;
/**
@@ -32,7 +33,7 @@
* This object will be cached in request scope each time the view is rendered
* and the component tree contains one or more
* [EMAIL PROTECTED] org.apache.shale.clay.component.Clay}
components.<br/><br/>
- * This class is only used with the myfaces implementation.</p>
+ * This class is used with all but the RI 1.1 implementation.</p>
*/
public class SequenceGenerator {
@@ -57,7 +58,7 @@
* same prefix of the <code>UIViewRoot.UNIQUE_ID_PREFIX</code> to
* play nicely with the 1.2 RI.</p>
*/
- public static String uniqueIdPrefix = UIViewRoot.UNIQUE_ID_PREFIX + "sc";
+ private static String uniqueIdPrefix = UIViewRoot.UNIQUE_ID_PREFIX + "sc";
/**
* <p>Holds the id prefix of <code>UIViewRoot.UNIQUE_ID_PREFIX</code> +
"sc".
@@ -67,19 +68,14 @@
private StringBuffer buff = new StringBuffer(uniqueIdPrefix);
/**
- * <p>Sequencial generated unique number for the object instance.</p>
- */
- private int uniqueId = 0;
-
- /**
* <p>Returns a unique component id prefixed with
* <code>UIViewRoot.UNIQUE_ID_PREFIX</code> + "sc".</p>
- *
+ * @param configBean the Clay metadata bean used to build a view component
* @return a unique id per object instance
*/
- public String createUniqueId() {
+ public String createUniqueId(ComponentBean configBean) {
buff.setLength(uniqueIdPrefix.length());
- buff.append(uniqueId++);
+ buff.append(configBean.getJspId());
return buff.toString();
}
}
Modified:
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
(original)
+++
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
Wed Oct 18 16:06:50 2006
@@ -60,6 +60,38 @@
}
/**
+ * <p>A class scoped unique sequence counter.</p>
+ */
+ private static long uniqueSequence = -1;
+
+ /**
+ * @return the next <code>uniqueSequence</code>
+ */
+ private synchronized long generateId() {
+ return ++uniqueSequence;
+ }
+
+ /**
+ * <p>The config beans unique sequence. The value is
+ * populated from a call to <code>generateId</code>.</p>
+ */
+ private long jspId = -1;
+
+ /**
+ * <p>Returns a unique id that will stick to the config bean.
+ * This is clay's version of the <code>JspIdConsumer</code>
+ * in JSP 2.1.</p>
+ *
+ * @return unique id for a view element
+ */
+ public long getJspId() {
+ if (jspId == -1) {
+ jspId = generateId();
+ }
+ return jspId;
+ }
+
+ /**
* <p>
* Message resources for this class.
* </p>
Modified:
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/VerbatimBuilder.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/VerbatimBuilder.java?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/VerbatimBuilder.java
(original)
+++
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/VerbatimBuilder.java
Wed Oct 18 16:06:50 2006
@@ -144,7 +144,7 @@
/**
* <p>Skip the processing of attributes for a verbatim node. This
* was a bug uncovered with JSF RI 1.2. The <code>TextRenderer</code>
- * is sensitive to pass thru attributes. If it finds a pass thru
+ * is sensitive to pass thru attributes. If it finds a pass thru
* attribute, it wraps the text in a HTML span tag.</p>
*
* @param node markup node
Modified:
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/JSFRuntimeTracker.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/JSFRuntimeTracker.java?view=diff&rev=465411&r1=465410&r2=465411
==============================================================================
---
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/JSFRuntimeTracker.java
(original)
+++
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/JSFRuntimeTracker.java
Wed Oct 18 16:06:50 2006
@@ -25,7 +25,15 @@
* <p>This utility class is used to determine the
* JSF runtime that will take presidency.</p>
*/
-public class JSFRuntimeTracker {
+public final class JSFRuntimeTracker {
+
+ /**
+ * <p>Utility Class hides the default constructor.</p>
+ */
+ private JSFRuntimeTracker() {
+ super();
+ }
+
/**
* <p>This enumeration indicates the JSF RI 1.1.x runtime is installed.</p>
*/