[seam-commits] Seam SVN: r15058 - in branches/community/Seam_2_3: examples-ee6/blog/blog-web/src/main/webapp and 12 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Aug 20 07:24:58 EDT 2012


Author: manaRH
Date: 2012-08-20 07:24:57 -0400 (Mon, 20 Aug 2012)
New Revision: 15058

Added:
   branches/community/Seam_2_3/seam-cdk-helper/
   branches/community/Seam_2_3/seam-cdk-helper/README.md
   branches/community/Seam_2_3/seam-cdk-helper/pom.xml
   branches/community/Seam_2_3/seam-cdk-helper/src/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/SeamGeneratorValidatorAndConvertersMojo.java
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java
   branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java
Modified:
   branches/community/Seam_2_3/examples-ee6/blog/blog-web/src/main/webapp/post.xhtml
   branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-web/src/main/webapp/viewContact.xhtml
   branches/community/Seam_2_3/jboss-seam-ui/pom.xml
   branches/community/Seam_2_3/pom.xml
   branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Controls.xml
Log:
JBSEAM-4955 added seam-cdk-helper

Modified: branches/community/Seam_2_3/examples-ee6/blog/blog-web/src/main/webapp/post.xhtml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/blog/blog-web/src/main/webapp/post.xhtml	2012-08-20 10:02:48 UTC (rev 15057)
+++ branches/community/Seam_2_3/examples-ee6/blog/blog-web/src/main/webapp/post.xhtml	2012-08-20 11:24:57 UTC (rev 15058)
@@ -21,16 +21,16 @@
          <s:decorate template="edit.xhtml" id="title">
             <ui:define name="label">Title</ui:define>
             <h:inputText value="#{blogEntry.title}" size="70" maxlength="70" required="true" id="titleInput">
-<!--             	 <s:validateFormattedText /> -->
-                <f:validator validatorId="org.jboss.seam.ui.FormattedTextValidator" />
+            	 <s:validateFormattedText />
+<!--                 <f:validator validatorId="org.jboss.seam.ui.FormattedTextValidator" /> -->
             </h:inputText>
          </s:decorate>
       
          <s:decorate template="edit.xhtml" id="excerpt">
             <ui:define name="label">Excerpt (optional)</ui:define>
             <h:inputTextarea value="#{blogEntry.excerpt}" cols="68" rows="3" id="excerptInput">
-<!--          	     <s:validateFormattedText /> -->
-                <f:validator validatorId="org.jboss.seam.ui.FormattedTextValidator" />
+         	     <s:validateFormattedText />
+<!--                 <f:validator validatorId="org.jboss.seam.ui.FormattedTextValidator" /> -->
             </h:inputTextarea>
          </s:decorate>
       

Modified: branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-web/src/main/webapp/viewContact.xhtml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-web/src/main/webapp/viewContact.xhtml	2012-08-20 10:02:48 UTC (rev 15057)
+++ branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-web/src/main/webapp/viewContact.xhtml	2012-08-20 11:24:57 UTC (rev 15058)
@@ -86,8 +86,8 @@
         <h:column>
           <f:facet name="header">Posted</f:facet>
           <h:outputText value="#{c.created}">
-<!--            <s:convertDateTime type="both"/>-->
-            <f:convertDateTime type="both" />
+           <s:convertDateTime type="both"/>
+<!--  JSF 2 way           <f:convertDateTime type="both" /> -->
           </h:outputText>
         </h:column>
         <h:column>

Modified: branches/community/Seam_2_3/jboss-seam-ui/pom.xml
===================================================================
--- branches/community/Seam_2_3/jboss-seam-ui/pom.xml	2012-08-20 10:02:48 UTC (rev 15057)
+++ branches/community/Seam_2_3/jboss-seam-ui/pom.xml	2012-08-20 11:24:57 UTC (rev 15058)
@@ -40,7 +40,21 @@
                     </library>
                 </configuration>
             </plugin>
+            <!-- This need to be after Richfaces CDK plugin -->
             <plugin>
+               <groupId>org.jboss.seam</groupId>
+               <artifactId>seam-cdk-helper</artifactId>
+               <version>1.0-SNAPSHOT</version>
+               <executions>
+                  <execution>
+                     <phase>generate-sources</phase>
+                     <goals>
+                        <goal>execute</goal>
+                     </goals>
+                  </execution>
+               </executions>
+            </plugin> 
+            <plugin>
                 <artifactId>maven-javadoc-plugin</artifactId>
                 <configuration>
                     <links>

Modified: branches/community/Seam_2_3/pom.xml
===================================================================
--- branches/community/Seam_2_3/pom.xml	2012-08-20 10:02:48 UTC (rev 15057)
+++ branches/community/Seam_2_3/pom.xml	2012-08-20 11:24:57 UTC (rev 15058)
@@ -44,6 +44,7 @@
 		<pdf.name>${project.artifactId}.pdf</pdf.name>
 
 		<!-- Version string properties -->
+        <version.seam>2.3.0.CR1-SNAPSHOT</version.seam>
 		<version.arquillian_core>1.0.1.Final</version.arquillian_core>
 		<version.wicket>1.4.14</version.wicket>
 		<version.testng>5.14.10</version.testng>
@@ -71,7 +72,7 @@
 			<dependency>
 				<groupId>org.jboss.seam</groupId>
 				<artifactId>bom</artifactId>
-				<version>${project.version}</version>
+				<version>${version.seam}</version>
 				<type>pom</type>
 				<scope>import</scope>
 			</dependency>
@@ -410,25 +411,26 @@
 		</plugins>
 	</build>
 
-	<modules>
+   <modules>
       <module>bom</module>
+      <module>seam-cdk-helper</module>
       <module>jboss-seam</module>
-	   <module>jboss-seam-ui</module>
-	   <module>jboss-seam-debug</module>
-		<module>jboss-seam-gen</module>
-		<module>jboss-seam-excel</module>
-		<module>jboss-seam-flex</module>
-		<module>jboss-seam-mail</module>
-		<module>jboss-seam-pdf</module>
-		<module>jboss-seam-remoting</module>
-		<module>jboss-seam-resteasy</module>
-		<module>jboss-seam-rss</module>
-		<module>jboss-seam-wicket</module>
-		<module>jboss-seam-ioc</module>
-		<module>jboss-seam-jul</module>
+      <module>jboss-seam-ui</module>
+      <module>jboss-seam-debug</module>
+      <module>jboss-seam-gen</module>
+      <module>jboss-seam-excel</module>
+      <module>jboss-seam-flex</module>
+      <module>jboss-seam-mail</module>
+      <module>jboss-seam-pdf</module>
+      <module>jboss-seam-remoting</module>
+      <module>jboss-seam-resteasy</module>
+      <module>jboss-seam-rss</module>
+      <module>jboss-seam-wicket</module>
+      <module>jboss-seam-ioc</module>
+      <module>jboss-seam-jul</module>
       <module>functional-tests</module>
-      <module>seam-integration-tests</module>             
-	</modules>
+      <module>seam-integration-tests</module>
+   </modules>
 	
 	<profiles>
 	   <!-- Profile for generating Seam reference documentation  -->

Added: branches/community/Seam_2_3/seam-cdk-helper/README.md
===================================================================
--- branches/community/Seam_2_3/seam-cdk-helper/README.md	                        (rev 0)
+++ branches/community/Seam_2_3/seam-cdk-helper/README.md	2012-08-20 11:24:57 UTC (rev 15058)
@@ -0,0 +1,43 @@
+Seam CDK Helper
+=============
+Author: Rafael Benevides
+
+Maven Plugin to generate Validators and Converters for Seam 2.3 - Workaround for Richfaces 4 CDK
+
+Why this Maven Plugin was created?
+----------------------------------
+
+The converters and validators wasn't available as related at https://issues.jboss.org/browse/JBSEAM-4955
+
+There is a related issue with Richfaces 4 the prevents this generation https://issues.jboss.org/browse/RF-12271
+
+This plugin generates the conveters by looking for classes annotated with @FacesConvertes and the looks for its configs to generate its tag on s.taglib.xml
+
+For validators the source of the information is the correspondent xml files
+
+
+How to use this plugin ?
+-----------------------
+
+Just at the plugin information on jboss-seam-ui pom.xml
+
+
+    <build>
+        <plugins>
+          ...
+          <!-- This need to be after Richfaces CDK plugin -->
+          <plugin>
+             <groupId>org.jboss.seam</groupId>
+        		 <artifactId>seam-cdk-helper</artifactId>
+        		 <version>1.0-SNAPSHOT</version>
+        		 <executions>
+                <execution>
+                   <phase>generate-sources</phase>
+                   <goals>
+                      <goal>execute</goal>
+                   </goals>
+                </execution>
+             </executions>
+          </plugin>
+          ...
+

Added: branches/community/Seam_2_3/seam-cdk-helper/pom.xml
===================================================================
--- branches/community/Seam_2_3/seam-cdk-helper/pom.xml	                        (rev 0)
+++ branches/community/Seam_2_3/seam-cdk-helper/pom.xml	2012-08-20 11:24:57 UTC (rev 15058)
@@ -0,0 +1,29 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <artifactId>jboss-seam-parent</artifactId>
+      <groupId>org.jboss.seam</groupId>
+      <version>2.3.0.CR1-SNAPSHOT</version>
+      <relativePath>../pom.xml</relativePath>
+   </parent>
+
+   <artifactId>seam-cdk-helper</artifactId>
+   <packaging>maven-plugin</packaging>
+   <version>1.0-SNAPSHOT</version>
+   <name>Seam 2.3 CDK Helper for using RF 4 CDK</name>
+   <url>http://seamframework.org</url>
+   <dependencies>
+      <dependency>
+         <groupId>org.apache.maven</groupId>
+         <artifactId>maven-plugin-api</artifactId>
+         <version>2.0</version>
+      </dependency>
+      <dependency>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <scope>test</scope>
+      </dependency>
+   </dependencies>
+</project>

Added: branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java
===================================================================
--- branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java	                        (rev 0)
+++ branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java	2012-08-20 11:24:57 UTC (rev 15058)
@@ -0,0 +1,99 @@
+package org.jboss.seam.maven.helper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+import org.apache.maven.plugin.logging.Log;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * Generates JSF taglib descriptor for all FacesConverter annotated classes
+ * 
+ * @author Rafael Benevides <https://community.jboss.org/people/rafabene>
+ * @author Marek Novotny <https://community.jboss.org/people/manaRH>
+ *
+ */
+public class ConverterGenerator
+{
+
+   private List<File> converterSources = new ArrayList<File>();
+   private Log log;
+   private String sourceDirectory;
+   private String targetDirectory;
+
+   public ConverterGenerator(String sourceDirectory, String targetDirectory, Log log)
+   {
+      this.sourceDirectory = sourceDirectory;
+      this.targetDirectory = targetDirectory;
+      this.log = log;
+   }
+
+   public void addFile(File file) throws FileNotFoundException
+   {
+      if (fileIsConverterSource(file))
+      {
+         converterSources.add(file);
+      }
+   }
+
+   private boolean fileIsConverterSource(File file) throws FileNotFoundException
+   {
+      if (file.getName().endsWith(".java"))
+      {
+         Scanner scanner = new Scanner(file);
+         String find = scanner.findWithinHorizon("@FacesConverter", 0);
+         if (find != null)
+         {
+            log.info("Identified " + file.getName() + " as Converter source code");
+            return true;
+         }
+      }
+      return false;
+   }
+
+   public void generateConverters() throws Exception
+   {
+      log.info("Generating Converters");
+      XMLGenerator xmlGenerator = new XMLGenerator(log);
+      File outXML = new File(targetDirectory + "/generated-sources/main/resources/META-INF", "s.taglib.xml");
+      List<Element> tagsToAdd = new ArrayList<Element>();
+      for (File source : converterSources)
+      {
+         String classFromSource = source.getAbsolutePath().replace(sourceDirectory, "").replace(File.separatorChar, '.').replace(".java", "").substring(1);
+         File facesConfigXML = findCorrespondentConfig(classFromSource);
+         if (facesConfigXML != null)
+         {
+            Element tag = xmlGenerator.getFaceletsTagElementFromFacesconfig(facesConfigXML, facesConfigXML.getName().replace(".xml", ""), "converter");
+            tagsToAdd.add(tag);
+         }
+      }
+      xmlGenerator.updateFile(outXML, tagsToAdd);
+
+   }
+
+   private File findCorrespondentConfig(String classFromSource) throws FileNotFoundException
+   {
+      String whereToFind = sourceDirectory.replace("/java", "/config/component");
+      log.debug("Searching correspondent config for " + classFromSource + " in " + whereToFind);
+      File componentFolder = new File(whereToFind);
+      for (File f : componentFolder.listFiles())
+      {
+         // Search only files
+         if (f.isFile())
+         {
+            Scanner scanner = new Scanner(f);
+            String find = scanner.findWithinHorizon(classFromSource, 0);
+            if (find != null)
+            {
+               return f;
+            }
+         }
+      }
+      return null;
+   }
+
+}

Added: branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/SeamGeneratorValidatorAndConvertersMojo.java
===================================================================
--- branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/SeamGeneratorValidatorAndConvertersMojo.java	                        (rev 0)
+++ branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/SeamGeneratorValidatorAndConvertersMojo.java	2012-08-20 11:24:57 UTC (rev 15058)
@@ -0,0 +1,79 @@
+package org.jboss.seam.maven.helper;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * 
+ * Goal which appends validator and converter custom tag file into face.
+ * 
+ * @goal execute
+ * 
+ * @phase generate-sources
+ * 
+ * @author Rafael Benevides <https://community.jboss.org/people/rafabene>
+ * @author Marek Novotny <https://community.jboss.org/people/manaRH>
+ *
+ */
+public class SeamGeneratorValidatorAndConvertersMojo extends AbstractMojo
+{
+   /**
+    * The source directories containing the sources to be compiled.
+    * 
+    * @parameter expression="${project.build.sourceDirectory}"
+    * @required
+    * @readonly
+    */
+   protected String sourceDirectory;
+
+   /**
+    * Output directory for processed resources
+    * 
+    * @parameter expression="${project.build.directory}"
+    * @required
+    */
+   private String targetDirectory;
+
+   private ConverterGenerator converterGenerator;
+   private ValidatorGenerator validatorGenerator;
+
+   public void execute() throws MojoExecutionException
+   {
+      converterGenerator = new ConverterGenerator(sourceDirectory, targetDirectory, getLog());
+      validatorGenerator = new ValidatorGenerator(targetDirectory, getLog());
+      try
+      {
+         File sourceFolder = new File(sourceDirectory);
+         getLog().info("Source Folder: " + sourceFolder);
+         visitFolder(sourceFolder);
+         converterGenerator.generateConverters();
+         visitFolder(new File(sourceFolder.getParent(), "config/component"));
+         validatorGenerator.generateValidators();
+      }
+      catch (Exception e)
+      {
+         throw new MojoExecutionException("Error on Generator", e);
+      }
+
+   }
+
+   private void visitFolder(File sourceFolder) throws FileNotFoundException
+   {
+      for (File file : sourceFolder.listFiles())
+      {
+         if (file.isDirectory())
+         {
+            visitFolder(file);
+         }
+         else
+         {
+            converterGenerator.addFile(file);
+            validatorGenerator.addFile(file);
+         }
+      }
+   }
+}

Added: branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java
===================================================================
--- branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java	                        (rev 0)
+++ branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java	2012-08-20 11:24:57 UTC (rev 15058)
@@ -0,0 +1,75 @@
+package org.jboss.seam.maven.helper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+
+import org.apache.maven.plugin.logging.Log;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * Generates JSF taglib descriptor for all Validators classes
+ * 
+ * @author Rafael Benevides <https://community.jboss.org/people/rafabene>
+ * @author Marek Novotny <https://community.jboss.org/people/manaRH>
+ *
+ */
+public class ValidatorGenerator
+{
+
+   private List<File> validatorXMLs = new ArrayList<File>();
+   private Log log;
+   private String targetDirectory;
+   private Map<String, String> validatorNames = new HashMap<String, String>();
+
+   public ValidatorGenerator(String targetDirectory, Log log)
+   {
+      this.targetDirectory = targetDirectory;
+      this.log = log;
+      validatorNames.put("formattedTextValidator.xml", "validateFormattedText");
+      validatorNames.put("modelValidator.xml", "validate");
+   }
+
+   public void addFile(File file) throws FileNotFoundException
+   {
+      if (fileIsValidatorXML(file))
+      {
+         validatorXMLs.add(file);
+      }
+   }
+
+   private boolean fileIsValidatorXML(File file) throws FileNotFoundException
+   {
+      if (file.getName().endsWith(".xml"))
+      {
+         Scanner scanner = new Scanner(file);
+         String find = scanner.findWithinHorizon("<validator>", 0);
+         if (find != null)
+         {
+            log.info("Identified " + file.getName() + " as Validator XML");
+            return true;
+         }
+      }
+      return false;
+   }
+
+   public void generateValidators() throws Exception
+   {
+      log.info("Generating Validators");
+      XMLGenerator xmlGenerator = new XMLGenerator(log);
+      File outXML = new File(targetDirectory + "/generated-sources/main/resources/META-INF", "s.taglib.xml");
+      List<Element> tagsToAdd = new ArrayList<Element>();
+      for (File xml : validatorXMLs)
+      {
+         Element tag = xmlGenerator.getFaceletsTagElementFromFacesconfig(xml, validatorNames.get(xml.getName()), "validator");
+         tagsToAdd.add(tag);
+      }
+      xmlGenerator.updateFile(outXML, tagsToAdd);
+   }
+
+}

Added: branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java
===================================================================
--- branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java	                        (rev 0)
+++ branches/community/Seam_2_3/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java	2012-08-20 11:24:57 UTC (rev 15058)
@@ -0,0 +1,183 @@
+package org.jboss.seam.maven.helper;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.maven.plugin.logging.Log;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
+/**
+ * 
+ * Generates JSF taglib descriptor xml
+ * 
+ * @author Rafael Benevides <https://community.jboss.org/people/rafabene>
+ * @author Marek Novotny <https://community.jboss.org/people/manaRH>
+ *
+ */
+public class XMLGenerator
+{
+
+   private Log log;
+
+   public XMLGenerator(Log log)
+   {
+      this.log = log;
+   }
+
+   public Element getFaceletsTagElementFromFacesconfig(File xml, String tagName, String converterOrValidator) throws Exception
+   {
+      log.info("Generating taglib from " + xml);
+
+      DocumentBuilder dstDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+      DocumentBuilder srcDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+      Document destDocument = dstDB.newDocument();
+      Document srcDocument = srcDB.parse(xml);
+
+      XPath xpath = XPathFactory.newInstance().newXPath();
+
+      Element tagElement = destDocument.createElement("tag");
+      Node tagNode = destDocument.appendChild(tagElement);
+      Element tagNameElement = destDocument.createElement("tag-name");
+      tagNameElement.setTextContent(tagName);
+      tagNode.appendChild(tagNameElement);
+
+      Element component = destDocument.createElement(converterOrValidator);
+      Node componentNode = tagNode.appendChild(component);
+
+      Element description = destDocument.createElement("description");
+      String descriptionContent = xpath.evaluate("//" + converterOrValidator + "/description/text()", srcDocument);
+      description.setTextContent(descriptionContent);
+
+      componentNode.appendChild(description);
+
+      Element componentType = destDocument.createElement(converterOrValidator + "-id");
+      String componentTypeContent = xpath.evaluate("//" + converterOrValidator + "-id/text()", srcDocument);
+      componentType.setTextContent(componentTypeContent);
+
+      componentNode.appendChild(componentType);
+
+      NodeList propertyNodes = (NodeList) xpath.evaluate("//property", srcDocument, XPathConstants.NODESET);
+
+      for (int i = 0; i < propertyNodes.getLength(); i++)
+      {
+         Node nNode = propertyNodes.item(i);
+         if (nNode.getNodeType() == Node.ELEMENT_NODE)
+         {
+
+            Element eElement = (Element) nNode;
+            String propDescription = getTagValue("description", eElement);
+            String propName = getTagValue("property-name", eElement);
+            String propClass = getTagValue("property-class", eElement);
+
+            Element attribute = destDocument.createElement("attribute");
+            Element atributeDescription = destDocument.createElement("description");
+            atributeDescription.setTextContent(propDescription);
+            attribute.appendChild(atributeDescription);
+
+            Element attributeName = destDocument.createElement("name");
+            attributeName.setTextContent(propName);
+            attribute.appendChild(attributeName);
+
+            Element attributeClass = destDocument.createElement("type");
+            attributeClass.setTextContent(propClass);
+            attribute.appendChild(attributeClass);
+
+            tagElement.appendChild(attribute);
+         }
+
+      }
+
+      return tagElement;
+
+   }
+
+   private static String getTagValue(String sTag, Element eElement)
+   {
+      NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
+
+      Node nValue = (Node) nlList.item(0);
+
+      return nValue.getNodeValue();
+   }
+
+   private void writeFileContent(File outXML, String content) throws IOException
+   {
+      log.info("Updating " + outXML);
+      FileOutputStream fos = new FileOutputStream(outXML);
+      fos.write(content.getBytes());
+
+   }
+
+   public void updateFile(File outXML, List<Element> tags) throws Exception
+   {
+      DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+      Document doc = docBuilder.parse(outXML);
+
+      for (Element tag : tags)
+      {
+         Comment comment = doc.createComment("Converter added by seam-cdk-helper plugin");
+         Node firstchild = doc.getFirstChild();
+         firstchild.appendChild(comment);
+         firstchild.appendChild(doc.importNode(tag, true));
+      }
+
+      // ///////////////
+      // Output the XML
+      TransformerFactory tf = TransformerFactory.newInstance();
+      tf.setAttribute("indent-number", new Integer(4));
+
+      Transformer transformer = tf.newTransformer();
+      transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
+      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
+      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+
+      DOMImplementation domImplementation = doc.getImplementation();
+      if (domImplementation.hasFeature("LS", "3.0") && domImplementation.hasFeature("Core", "2.0"))
+      {
+         DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation.getFeature("LS", "3.0");
+         LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
+         DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
+         if (domConfiguration.canSetParameter("format-pretty-print", true))
+         {
+            lsSerializer.getDomConfig().setParameter("format-pretty-print", true);
+            LSOutput lsOutput = domImplementationLS.createLSOutput();
+            lsOutput.setEncoding("UTF-8");
+            StringWriter stringWriter = new StringWriter();
+            lsOutput.setCharacterStream(stringWriter);
+            lsSerializer.write(doc, lsOutput);
+            writeFileContent(outXML, stringWriter.toString());
+         }
+         else
+         {
+            throw new RuntimeException("DOMConfiguration 'format-pretty-print' parameter isn't settable.");
+         }
+      }
+      else
+      {
+         throw new RuntimeException("DOM 3.0 LS and/or DOM 2.0 Core not supported.");
+      }
+   }
+}

Modified: branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Controls.xml
===================================================================
--- branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Controls.xml	2012-08-20 10:02:48 UTC (rev 15057)
+++ branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Controls.xml	2012-08-20 11:24:57 UTC (rev 15058)
@@ -304,7 +304,7 @@
       <section>
          <title>Converters and Validators</title>
          
-<!--          <section>
+          <section>
             <title><literal>&lt;s:convertDateTime&gt;</literal></title>
             
             <para><emphasis>Description</emphasis></para>
@@ -318,14 +318,11 @@
    <s:convertDateTime type="both" dateStyle="full"/>
 </h:outputText>]]></programlisting>
    
-         <warning><para>This is not supported, use f:convertDateTime instead</para></warning>
          </section>
    
          <section>
             <title><literal>&lt;s:convertEntity&gt;</literal></title>
             
-            <warning><para>This is not supported, use <![CDATA[<f:converter converterId="your_converter" />]]> instead</para></warning>
-            
             <para><emphasis>Description</emphasis></para>
             <para>
                Assigns an entity converter to the current component. This is
@@ -494,7 +491,6 @@
 </h:outputText>]]></programlisting>
          </section>
          
-	 -->	 
          <section>
             <title><literal>&lt;s:validateEquality&gt;</literal></title>
             
@@ -973,7 +969,8 @@
             <programlisting role="XHTML"><![CDATA[<h:selectOneRadio id="radioList"
                   layout="lineDirection"
                   value="#{newPayment.paymentFrequency}">
-   <f:converter converterId="org.jboss.seam.ui.EnumConverter" />
+   <!-- JSF 2 way <f:converter converterId="org.jboss.seam.ui.EnumConverter" />-->
+   <s:convertEnum />
    <s:enumItem enumValue="ONCE"         label="Only Once" />
    <s:enumItem enumValue="EVERY_MINUTE" label="Every Minute" />
    <s:enumItem enumValue="HOURLY"       label="Every Hour" />



More information about the seam-commits mailing list