JBoss Rich Faces SVN: r7770 - in trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder: mojo and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-04-11 11:16:20 -0400 (Fri, 11 Apr 2008)
New Revision: 7770
Added:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
Log:
http://jira.jboss.com/jira/browse/RF-2526
Copied: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java (from rev 7763, branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java)
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java (rev 0)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java 2008-04-11 15:16:20 UTC (rev 7770)
@@ -0,0 +1,120 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+/**
+ * Class is used to locate and merge several xml files
+ * @author Maksim Kaszynski
+ *
+ */
+public class MavenXMLMerge {
+
+ class DirectoryItem {
+ private File baseDir;
+ private String [] includes;
+ public DirectoryItem(File baseDir, String[] includes) {
+ super();
+ this.baseDir = baseDir;
+ this.includes = includes;
+ }
+
+ }
+
+ private boolean namespaceAware = false;
+
+ private Log log;
+
+ private String xPath;
+
+ private String keyXPath;
+
+ private String [] sortBy = {};
+
+ private List<DirectoryItem> directories = new ArrayList<DirectoryItem>();
+
+ public MavenXMLMerge() {
+ }
+
+ public void addDirectory(File dir, String [] includes) {
+ directories.add(new DirectoryItem(dir, includes));
+ }
+
+ public void setSortBy(String ... sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public void performMerge(XMLMergeCallback callback) throws MojoExecutionException {
+ XMLBodyMerge merge = new XMLBodyMerge(xPath, keyXPath);
+
+ for (DirectoryItem item : directories) {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(item.baseDir);
+ ds.setIncludes(item.includes);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (String file : files) {
+ File sourceFile = new File(item.baseDir, file);
+ if (log != null){
+ log.info("Process file " + sourceFile.getPath());
+ }
+ try {
+ XMLBody configBody = new XMLBody();
+ configBody.loadXML(new FileInputStream(sourceFile), namespaceAware);
+ merge.add(configBody);
+
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Could't read file "
+ + sourceFile.getPath(), e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing config file "
+ + sourceFile.getPath(), e);
+ }
+
+ }
+ }
+
+ if (sortBy != null) {
+ merge.sort(new XPathComparator(sortBy));
+ }
+
+ try {
+ callback.onMergeComplete(merge.getContent());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Exception uring XML merge", e);
+ }
+ }
+
+ public void setNamespaceAware(boolean namespaceAware) {
+ this.namespaceAware = namespaceAware;
+ }
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ public void setXPath(String path) {
+ xPath = path;
+ }
+
+ public void setKeyXPath(String keyXPath) {
+ this.keyXPath = keyXPath;
+ }
+}
Copied: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java (from rev 7763, branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java)
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java (rev 0)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java 2008-04-11 15:16:20 UTC (rev 7770)
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+import java.io.File;
+import java.io.FileWriter;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class VelocityTaglibMergeCallBack implements XMLMergeCallback {
+
+ private File target;
+
+ private String template;
+
+ private VelocityComponent velocity;
+
+ private VelocityContext initialContext;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.maven.XMLMergeCallback#onMergeComplete(java.lang.String)
+ */
+ public void onMergeComplete(String mergedContent) throws Exception{
+
+ VelocityContext velocityContext;
+
+ if (initialContext != null) {
+ velocityContext = new VelocityContext(initialContext);
+ } else {
+ velocityContext = new VelocityContext();
+ }
+
+ VelocityEngine velocityEngine = velocity.getEngine();
+ Template template2 = velocityEngine.getTemplate(template);
+
+ File parentFile = target.getParentFile();
+ if (!parentFile.exists()) {
+ parentFile.mkdirs();
+ }
+
+ FileWriter fileWriter = new FileWriter(target);
+
+ template2.merge(velocityContext, fileWriter);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+}
Copied: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java (from rev 7763, branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java)
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java (rev 0)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java 2008-04-11 15:16:20 UTC (rev 7770)
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface XMLMergeCallback {
+ void onMergeComplete(String mergedContent) throws Exception;
+
+}
Modified: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2008-04-11 15:16:12 UTC (rev 7769)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2008-04-11 15:16:20 UTC (rev 7770)
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -39,6 +40,8 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -55,15 +58,11 @@
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.shared.io.scan.ResourceInclusionScanner;
-import org.apache.maven.shared.io.scan.SimpleResourceInclusionScanner;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.w3c.dom.Node;
/**
* This plugin assembly full components library from modules, included in parent
@@ -357,17 +356,17 @@
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml",
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource", "name/text()",
- new VelocityContext(), resourcesConfig);
+ new VelocityContext(), resourcesConfig, null);
File tld = new File(outputDirectory, "META-INF/"
+ library.getTaglib().getShortName() + ".tld");
mergeXML(models, includeTld, TLD_TEMPLATE,
"/taglib/tag | /taglib/listener",
- null, new VelocityContext(), tld);
+ null, new VelocityContext(), tld, new XPathComparator("local-name()", "name/text()", "listener-class/text()"));
File taglib = new File(outputDirectory, "META-INF/"
+ library.getTaglib().getShortName() + ".taglib.xml");
mergeXML(models, includeTaglib, TAGLIB_TEMPLATE,
"/facelet-taglib/tag | /facelet-taglib/function",
- null, new VelocityContext(), taglib);
+ null, new VelocityContext(), taglib, new XPathComparator("local-name()", "tag-name/text()", "function-name/text()"));
}else {
throw new MojoFailureException("Components library project must have parent pom with components modules");
}
@@ -447,15 +446,15 @@
* Velocity context for template processing.
* @throws MojoExecutionException
*/
- private void mergeXML(List models, String filename, String templateName,
- String commonXpath, String keyXPath, VelocityContext context, File target)
+ private void mergeXML(List<Model> models, String filename, String templateName,
+ String commonXpath, String keyXPath, VelocityContext context, File target, Comparator<Node> comparator)
throws MojoExecutionException {
- Set<String> keySet = new HashSet<String>();
- StringBuffer content = new StringBuffer();
+ StringBuilder content = new StringBuilder();
+ XMLBodyMerge bodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
String[] split = filename.split(",");
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleDir = new File(buildDirectory, model.getArtifactId());
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
@@ -473,15 +472,7 @@
try {
configBody.loadXML(new FileInputStream(moduleFacesConfig));
xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
+ bodyMerge.add(configBody);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could't read file "
+ moduleFacesConfig.getPath(), e);
@@ -490,10 +481,22 @@
"Error parsing config file "
+ moduleFacesConfig.getPath(), e);
}
+
+
}
}
+ if (comparator != null) {
+ bodyMerge.sort(comparator);
+ }
+
+ try {
+ content.append(bodyMerge.getContent());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
if (xmls.size() > 0) {
- context.put("content", content.toString());
+ context.put("content", content);
context.put("library", library);
context.put("models", models);
context.put("xmls", xmls);
Modified: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-04-11 15:16:12 UTC (rev 7769)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-04-11 15:16:20 UTC (rev 7770)
@@ -40,6 +40,8 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -59,6 +61,7 @@
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.w3c.dom.Node;
/**
* This plugin assembly full components library from modules, included in parent
@@ -92,6 +95,10 @@
private static final String TAGLIB_TEMPLATE = "taglib.vm";
+ private static final Comparator<Node> TLD_COMPARATOR = new XPathComparator("local-name()", "listener-class/text()", "name/text()");
+ private static final Comparator<Node> FACELET_COMPARATOR = new XPathComparator("local-name()", "function-name/text()", "tag-name/text()");
+
+
/**
* Used to look up Artifacts in the remote repository.
*
@@ -237,17 +244,17 @@
templates = Library.JSF12.equals(library.getJsfVersion()) ? TEMPLATES12_PREFIX
: TEMPLATES_PREFIX;
}
- List models = extractModules();
+ List<Model> models = extractModules();
mergeFacesConfig(models);
File resourcesConfig = new File(outputDirectory,
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml", null,
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
- "name/text()", new VelocityContext(), resourcesConfig, false);
+ "name/text()", new VelocityContext(), resourcesConfig, false, null);
if (null != commonStyle) {
File commonXcss = new File(outputDirectory, commonStyle);
mergeXML(models, includeXcss, excludeXcss, XCSS_TEMPLATE,
- templateXpath, null, new VelocityContext(), commonXcss, true);
+ templateXpath, null, new VelocityContext(), commonXcss, true, null);
}
if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
@@ -268,7 +275,7 @@
excludeModules = taglib.getExcludeModules().split(",");
Arrays.sort(excludeModules);
}
- taglibModels = new ArrayList();
+ taglibModels = new ArrayList<Model>();
for (Iterator iterator = models.iterator(); iterator
.hasNext();) {
Model model = (Model) iterator.next();
@@ -281,27 +288,6 @@
}
}
}
- // sort taglib models by artifactIds in ASC order
- Collections.sort(taglibModels, new Comparator<Model>() {
- /**
- * Compares two <code>Model</code> objects by artifactIds
- * for sorting in ASC order
- * @param m1 - model object
- * @param m2 - model object
- * @return result of comparing
- */
- public int compare(Model m1, Model m2) {
- // check incoming parameters for null
- if ((m1 == null) || (m1.getArtifactId() == null)) {
- return -1;
- } else
- if ((m2 == null) || (m2.getArtifactId() == null)) {
- return 1;
- }
-
- return m1.getArtifactId().compareTo(m2.getArtifactId());
- }
- });
generateTaglib(taglibModels, taglib);
}
} else {
@@ -313,7 +299,7 @@
* @param models
* @throws MojoExecutionException
*/
- private void generateTaglib(List models, Taglib taglib)
+ private void generateTaglib(List<Model> models, Taglib taglib)
throws MojoExecutionException {
getLog().debug(
"Assembly taglib for uri " + taglib.getUri()
@@ -326,15 +312,21 @@
File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
+ ".tld");
getLog().debug("Write JSP taglib " + tld.getPath());
- mergeXML(models, includeTld, null, TLD_TEMPLATE, "/taglib/tag"
- + createTagCondition(taglib, "name") + " | /taglib/listener",
- null, new VelocityContext(taglibContext), tld, false);
+ String commonXPath = "/taglib/tag"
+ + createTagCondition(taglib, "name") + " | /taglib/listener | /taglib/function";
+
+ mergeXML(models, includeTld, null, TLD_TEMPLATE, commonXPath,
+ "listener-class/text() | name/text()", new VelocityContext(taglibContext), tld, false, TLD_COMPARATOR);
+
+
File faceletsTaglib = new File(outputDirectory, "META-INF/"
+ taglib.getTaglib() + ".taglib.xml");
- mergeXML(models, includeTaglib, null, TAGLIB_TEMPLATE, "/facelet-taglib/tag"
- + createTagCondition(taglib, "tag-name")
- + " | /facelet-taglib/function", null, new VelocityContext(
- taglibContext), faceletsTaglib, false);
+ commonXPath = "/facelet-taglib/tag"
+ + createTagCondition(taglib, "tag-name")
+ + " | /facelet-taglib/function";
+
+ mergeXML(models, includeTaglib, null, TAGLIB_TEMPLATE, commonXPath, "tag-name/text() | function-name/text()", new VelocityContext(
+ taglibContext), faceletsTaglib, false, FACELET_COMPARATOR);
getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
}
@@ -385,12 +377,12 @@
* @return
* @throws MojoExecutionException
*/
- private List extractModules() throws MojoExecutionException {
- List modules = parentProject.getModules();
- List models = new ArrayList(modules.size());
+ private List<Model> extractModules() throws MojoExecutionException {
+ List<String> modules = parentProject.getModules();
+ List<Model> models = new ArrayList<Model>(modules.size());
Map<String, Dependency> projectsDependencies = new HashMap<String, Dependency>();
- for (Iterator iter = modules.iterator(); iter.hasNext();) {
- String moduleName = (String) iter.next();
+ for (Iterator<String> iter = modules.iterator(); iter.hasNext();) {
+ String moduleName = iter.next();
getLog().info("Parent project have module " + moduleName);
Model model;
File f = new File(parentProject.getBasedir(), moduleName
@@ -417,10 +409,10 @@
getLog().debug(
"Project " + model.getName()
+ " included to library set");
- List dependencies = model.getDependencies();
- for (Iterator iterator = dependencies.iterator(); iterator
+ List<Dependency> dependencies = model.getDependencies();
+ for (Iterator<Dependency> iterator = dependencies.iterator(); iterator
.hasNext();) {
- Dependency dependency = (Dependency) iterator.next();
+ Dependency dependency = iterator.next();
getLog().debug(
dependency.getClass().getName() + " : "
+ dependency + " with key: "
@@ -436,9 +428,9 @@
}
// Remove modules projects from dependencise
Set<String> unwanted = new HashSet<String>(projectsDependencies.size());
- for (Iterator iter = models.iterator(); iter.hasNext();) {
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
- for (Iterator iterator = projectsDependencies.values().iterator(); iterator
+ for (Iterator<Dependency> iterator = projectsDependencies.values().iterator(); iterator
.hasNext();) {
Dependency dependency = (Dependency) iterator.next();
if (model.getGroupId().equals(dependency.getGroupId())
@@ -485,7 +477,7 @@
generatedProject.getDependencies()
.addAll(projectsDependencies.values());
writePom(generatedProject);
- project.setDependencies(new ArrayList(projectsDependencies.values()));
+ project.setDependencies(new ArrayList<Dependency>(projectsDependencies.values()));
// project.setFile(generatedPom);
}
@@ -533,15 +525,15 @@
* @param models
* @throws MojoExecutionException
*/
- private void mergeFacesConfig(List models) throws MojoExecutionException {
+ private void mergeFacesConfig(List<Model> models) throws MojoExecutionException {
StringBuffer facesConfig = new StringBuffer();
for (int i = 0; i < library.getRenderkits().length; i++) {
Renderkit kit = library.getRenderkits()[i];
kit.setContent(new StringBuffer());
}
// Process all faces-config.xml from modules
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleFacesConfig = new File(modulesDirectory, model
.getArtifactId()
+ "/META-INF/faces-config.xml");
@@ -605,7 +597,7 @@
*
* @param models
* models collected in library.
- * @param filename
+ * @param includes
* relative path to config file in models/output.
* @param templateName -
* name of velocity template for result file.
@@ -620,34 +612,39 @@
* {@link Set} to check for duplicate keys. Must not be null
* @throws MojoExecutionException
*/
- private void mergeXML(List models, String filename, String excludes, String templateName,
+ private void mergeXML(List<Model> models, String includes, String excludes, String templateName,
String commonXpath, String keyXPath, VelocityContext context,
- File target, boolean namespaceAware) throws MojoExecutionException {
- Set<String> keySet = new HashSet<String>();
+ File target, boolean namespaceAware, Comparator<Node> comparator) throws MojoExecutionException {
StringBuffer content = new StringBuffer();
- List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
- String[] split = filename.split(",");
+ String[] split = includes.split(",");
String[] excludesSplit = excludes != null ? excludes.split(",") : null;
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ XMLBodyMerge xBodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleDir = new File(modulesDirectory, model.getArtifactId());
- mergeXMLdir(moduleDir, commonXpath, keyXPath, namespaceAware,
- keySet, content, xmls, split, excludesSplit);
+ mergeXMLdir(moduleDir, namespaceAware, split, excludesSplit, xBodyMerge);
}
if(null!=config){
- mergeXMLdir(config, commonXpath, keyXPath, namespaceAware,
- keySet, content, xmls, split, excludesSplit);
+ mergeXMLdir(config, namespaceAware, split, excludesSplit, xBodyMerge);
}
- if (xmls.size() > 0) {
+
+ if (comparator != null) {
+ xBodyMerge.sort(comparator);
+ }
+ try {
+ content.append(xBodyMerge.getContent());
+ } catch (Exception e1) {
+ throw new MojoExecutionException("XML Merge Exception Occured", e1);
+ }
+ if (content.length() > 0) {
context.put("content", content.toString());
context.put("library", library);
context.put("models", models);
- context.put("xmls", xmls);
try {
writeParsedTemplate(templates + templateName, context, target);
} catch (Exception e) {
throw new MojoExecutionException("Error to process template "
- + templateName + " for files " + filename, e);
+ + templateName + " for files " + includes, e);
}
}
@@ -665,9 +662,7 @@
* @throws IllegalStateException
* @throws MojoExecutionException
*/
- private void mergeXMLdir(File moduleDir, String commonXpath,
- String keyXPath, boolean namespaceAware, Set<String> keySet,
- StringBuffer content, List<XMLBody> xmls, String[] split, String[] excludesSplit)
+ private void mergeXMLdir(File moduleDir, boolean namespaceAware, String[] split, String[] excludesSplit, XMLBodyMerge xBodyMerge)
throws IllegalStateException, MojoExecutionException {
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
@@ -684,17 +679,7 @@
XMLBody configBody = new XMLBody();
try {
configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
- xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(
- commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
+ xBodyMerge.add(configBody);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could't read file "
+ moduleFacesConfig.getPath(), e);
16 years, 9 months
JBoss Rich Faces SVN: r7769 - in trunk/cdk/generator/src: test/java/org/ajax4jsf/builder/xml and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-04-11 11:16:12 -0400 (Fri, 11 Apr 2008)
New Revision: 7769
Added:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java
trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java
trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java
trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java
Log:
http://jira.jboss.com/jira/browse/RF-2526
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2008-04-11 13:21:11 UTC (rev 7768)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -24,19 +24,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
@@ -44,7 +37,6 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -87,14 +79,14 @@
// Create Document Builder Factory
DocumentBuilderFactory docFactory = DocumentBuilderFactory
.newInstance();
-
+ docFactory.setIgnoringElementContentWhitespace(true);
docFactory.setValidating(false);
docFactory.setNamespaceAware(namespaceAware);
// Create Document Builder
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ //docBuilder.
+ //docBuilder.isValidating();
- docBuilder.isValidating();
-
// Disable loading of external Entityes
docBuilder.setEntityResolver(new EntityResolver() {
// Dummi resolver - alvays do nothing
@@ -152,66 +144,36 @@
}
private String serializeNodes(NodeList childNodes) throws ParsingException {
- DocumentFragment fragment = xmlDocument.createDocumentFragment();
- for (int i = 0; i < childNodes.getLength(); i++) {
- fragment.appendChild(childNodes.item(i).cloneNode(true));
- }
try {
- TransformerFactory transformerFactory = TransformerFactory
- .newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setErrorListener(new ErrorListener(){
-
- public void error(TransformerException exception)
- throws TransformerException {
- // TODO Auto-generated method stub
-
- }
-
- public void fatalError(TransformerException exception)
- throws TransformerException {
- // TODO Auto-generated method stub
-
- }
-
- public void warning(TransformerException exception)
- throws TransformerException {
- // TODO Auto-generated method stub
-
- }
-
- });
- transformer.setOutputProperty("omit-xml-declaration", "yes");
- StringWriter out = new StringWriter();
- StreamResult result = new StreamResult(out);
- transformer.transform(new DOMSource(fragment), result);
- return out.toString();
-
+ return new XMLBodySerializer().serialize(childNodes, xmlDocument);
} catch (Exception e) {
throw new ParsingException(e);
}
}
public String getContent(String xpath) throws ParsingException{
+ return serializeNodes(getByXpath(xpath));
+ }
+
+ public NodeList getByXpath(String xpath) throws ParsingException {
XPath path = XPathFactory.newInstance().newXPath();
NodeList childNodes;
try {
- childNodes = (NodeList) path.evaluate(xpath, xmlDocument,XPathConstants.NODESET);
+ childNodes = (NodeList) path.evaluate(xpath, xmlDocument, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
throw new ParsingException("Error evaluate xpath",e);
}
- return serializeNodes(childNodes);
+ return childNodes;
}
-
- public String getContentUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException{
+
+ public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException {
if (keyXPath == null) {
- return getContent(xpath);
+ return getByXpath(xpath);
} else {
-
XPath path = XPathFactory.newInstance().newXPath();
NodeList childNodes;
try {
- childNodes = (NodeList) path.evaluate(xpath, xmlDocument,XPathConstants.NODESET);
+ childNodes = getByXpath(xpath);
List<Node> nodeSet = new ArrayList<Node>();
@@ -224,14 +186,16 @@
nodeSet.add(node);
}
}
-
- return serializeNodes(new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()])));
-
+ return new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()]));
} catch (XPathExpressionException e) {
throw new ParsingException("Error evaluate xpath",e);
}
+
}
}
+ public String getContentUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException{
+ return serializeNodes(getByXpathUnique(xpath, keyXPath, keySet));
+ }
}
class ArrayNodeList implements NodeList {
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java (from rev 7758, branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -0,0 +1,130 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodyMerge implements NodeList{
+
+ private String xpath;
+
+ private List<Node> nodes = new ArrayList<Node>();
+
+ private Document document = null;
+
+ private XPathExpression keyXpath = null;
+
+ private StringBuffer content = new StringBuffer();
+
+ private Set<String> keys = new HashSet<String>();
+
+
+
+ public XMLBodyMerge(String xpath) {
+ super();
+ this.xpath = xpath;
+ }
+
+ public XMLBodyMerge(String xpath, String keyXpath) {
+ this(xpath);
+ if (keyXpath != null) {
+ try {
+ XPath newXPath = XPathFactory.newInstance().newXPath();
+ this.keyXpath = newXPath.compile(keyXpath);
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void add(Node node) {
+
+ if (keyXpath != null) {
+ String key = getKey(node);
+ if (key == null || keys.contains(key)) {
+ return;
+ }
+ }
+
+ if (document == null) {
+ document = node.getOwnerDocument();
+ } else {
+ node = document.importNode(node, true);
+ }
+ nodes.add(node);
+ }
+
+ public void add(XMLBody xmlBody) throws ParsingException {
+
+ if (xpath != null) {
+ NodeList nodeList = xmlBody.getByXpath(xpath);
+ if (nodeList != null) {
+ for(int i = 0; i < nodeList.getLength(); i++) {
+ add(nodeList.item(i));
+ }
+ }
+ } else {
+ content.append(xmlBody.getContent());
+ }
+
+ }
+
+ public int getLength() {
+ return nodes.size();
+ }
+
+ public Node item(int index) {
+ if (index < nodes.size()) {
+ return nodes.get(index);
+ }
+ return null;
+ }
+
+
+ public void sort(Comparator<Node> comparator) {
+ Collections.sort(nodes, comparator);
+ }
+
+ public String getContent() throws Exception{
+ StringBuilder buf = new StringBuilder();
+ if (content != null) {
+ buf.append(content);
+ }
+ if (document != null) {
+ buf.append(new XMLBodySerializer().serialize(this, document));
+ }
+
+ return buf.toString();
+ }
+
+ private String getKey(Node node) {
+ try {
+ NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
+ return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
+ } catch (Exception e) {
+ }
+ return null;
+ }
+}
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java (from rev 7758, branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -0,0 +1,60 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.io.StringWriter;
+
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodySerializer {
+ public String serialize(NodeList childNodes, Document xmlDocument) throws ParsingException {
+ try {
+ StringWriter out;
+ DocumentFragment fragment = xmlDocument.createDocumentFragment();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ fragment.appendChild(childNodes.item(i).cloneNode(true));
+ }
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setErrorListener(new ErrorListener(){
+
+ public void error(TransformerException exception)
+ throws TransformerException {
+ }
+
+ public void fatalError(TransformerException exception)
+ throws TransformerException {
+ }
+
+ public void warning(TransformerException exception)
+ throws TransformerException {
+ }
+
+ });
+ transformer.setOutputProperty("indent", "yes");
+ transformer.setOutputProperty("omit-xml-declaration", "yes");
+ out = new StringWriter();
+ StreamResult result = new StreamResult(out);
+ transformer.transform(new DOMSource(fragment), result);
+ return out.toString();
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
+}
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java (from rev 7758, branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -0,0 +1,79 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.util.Comparator;
+
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Node;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XPathComparator implements Comparator<Node> {
+
+ class XPathCompatorCriterion {
+ private XPathExpression expression = null;
+
+ public XPathCompatorCriterion(String xPath){
+ try {
+ expression = XPathFactory.newInstance().newXPath().compile(xPath);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public String getValue(Object node) throws XPathExpressionException {
+ return expression == null ? null : expression.evaluate(node);
+ }
+ }
+
+ private XPathCompatorCriterion [] criteria;
+
+ public XPathComparator(String ... criteria) {
+ this.criteria = new XPathCompatorCriterion[criteria.length];
+ for(int i = 0; i < criteria.length; i++) {
+ this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
+ }
+ }
+
+ public int compare(Node o1, Node o2) {
+ int result = 0;
+
+ for(int i = 0; i < criteria.length && result == 0; i++) {
+ String s1 = null;
+ String s2 = null;
+ try {
+ s1 = this.criteria[i].getValue(o1);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ s2 = this.criteria[i].getValue(o2);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (s1 != null) {
+ if (s2 != null) {
+ result = s1.compareTo(s2);
+ } else {
+ result = 1;
+ }
+ } else if (s2 != null) {
+ result = -1;
+ }
+ }
+
+ return result;
+ }
+
+}
Copied: trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java (from rev 7758, branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java)
===================================================================
--- trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java (rev 0)
+++ trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodyMergeTest extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#add(org.w3c.dom.Node)}.
+ */
+ public void testAddNode() {
+ XMLBodyMerge merge = new XMLBodyMerge("//node()");
+
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#add(org.ajax4jsf.builder.xml.XMLBody)}.
+ */
+ public void testAddXMLBody() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#getLength()}.
+ */
+ public void testGetLength() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#item(int)}.
+ */
+ public void testItem() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#getContent()}.
+ */
+ public void testGetContent() {
+ //fail("Not yet implemented");
+ }
+
+}
Copied: trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java (from rev 7758, branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java)
===================================================================
--- trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java (rev 0)
+++ trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -0,0 +1,73 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodySerializerTest extends TestCase {
+
+ private XMLBodySerializer serializer;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ serializer = new XMLBodySerializer();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ serializer = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodySerializer#serialize(org.w3c.dom.NodeList, org.w3c.dom.Document)}.
+ */
+ public void testSerialize() throws ParsingException{
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in);
+
+ NodeList singleElementList = body.getByXpath("/faces-config");
+ assertEquals(1, singleElementList.getLength());
+ Node node = singleElementList.item(0);
+ assertNotNull(node);
+ assertEquals("faces-config", node.getNodeName());
+ String actual = serializer.serialize(singleElementList, node.getOwnerDocument()).replaceAll("\\s", "");
+ String expected = "<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
+ assertEquals(expected, actual);
+
+ NodeList children = node.getChildNodes();
+ actual = serializer.serialize(children, node.getOwnerDocument()).replaceAll("\\s", "");
+ expected = "<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
+ assertEquals(expected, actual);
+
+
+ }
+
+}
Modified: trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java
===================================================================
--- trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2008-04-11 13:21:11 UTC (rev 7768)
+++ trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -25,12 +25,10 @@
import java.io.InputStream;
import java.util.HashSet;
-import javax.xml.xpath.XPathExpressionException;
+import junit.framework.TestCase;
import org.ajax4jsf.builder.config.ParsingException;
-import junit.framework.TestCase;
-
/**
* @author shura
*
@@ -145,7 +143,7 @@
InputStream in = new ByteArrayInputStream(xml.getBytes());
XMLBody body = new XMLBody();
body.loadXML(in);
- assertEquals("<modelVersion>4.0.0</modelVersion>", body.getContent());
+ assertEquals("<modelVersion>4.0.0</modelVersion>", body.getContent().trim());
}
public void testGetContentXpath() throws ParsingException {
@@ -160,7 +158,7 @@
try {
assertEquals(
"<component>blabla</component>",
- body.getContent("/faces-config/component"));
+ body.getContent("/faces-config/component").trim());
} catch (ParsingException e) {
e.printStackTrace();
assertTrue(e.getMessage(),false);
@@ -177,9 +175,12 @@
XMLBody body = new XMLBody();
body.loadXML(in);
try {
+ String expected = "<component><test>blabla</test></component><component><test>blabla2</test></component>";
+ String actual = body.getContentUnique("/faces-config/component", "test/text()", new HashSet<String>()).replaceAll("\\s", "");
+
assertEquals(
- "<component><test>blabla</test></component><component><test>blabla2</test></component>",
- body.getContentUnique("/faces-config/component", "test/text()", new HashSet<String>()));
+ expected,
+ actual);
} catch (ParsingException e) {
e.printStackTrace();
assertTrue(e.getMessage(),false);
@@ -197,7 +198,7 @@
try {
assertEquals(
"<f:component xmlns:f=\"http://foo.baz\"><test f:foo=\"xxx\" xmlns=\"http://foo.bar\">blabla</test></f:component>",
- body.getContent());
+ body.getContent().replace("\r", "\n").replace("\n", ""));
} catch (ParsingException e) {
e.printStackTrace();
assertTrue(e.getMessage(),false);
Copied: trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java (from rev 7758, branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java)
===================================================================
--- trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java (rev 0)
+++ trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java 2008-04-11 15:16:12 UTC (rev 7769)
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XPathComparatorTest extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testCompare() throws Exception{
+ String xml = "<faces-config>" +
+ "<component><test>blabla1</test></component>" +
+ "<component><test>blabla</test></component>" +
+ "<renderer><foo>blabla2</foo></renderer>" +
+ "<component><test>blabla2</test></component>"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in);
+ NodeList list = body.getByXpath("//component|//renderer");
+ assertEquals(4, list.getLength());
+ Node node0 = list.item(0);
+ Node node1 = list.item(1);
+ Node node2 = list.item(2);
+ Node node3 = list.item(3);
+
+ XPathComparator dummyComparator = new XPathComparator();
+ assertEquals(0, dummyComparator.compare(node0, node1));
+ assertEquals(0, dummyComparator.compare(node1, node2));
+ assertEquals(0, dummyComparator.compare(node0, node2));
+ assertEquals(0, dummyComparator.compare(node0, node3));
+ assertEquals(0, dummyComparator.compare(node2, node3));
+ assertEquals(0, dummyComparator.compare(node1, node0));
+ assertEquals(0, dummyComparator.compare(node2, node1));
+ assertEquals(0, dummyComparator.compare(node2, node0));
+
+ XPathComparator simpleComparator = new XPathComparator("local-name()");
+ assertEquals(0, simpleComparator.compare(node0, node1));
+ assertEquals(0, simpleComparator.compare(node0, node3));
+ assertTrue(simpleComparator.compare(node0, node2) < 0);
+ assertTrue(simpleComparator.compare(node2, node1) > 0);
+
+ XPathComparator advancedComparator = new XPathComparator("local-name()", "test/text()", "foo/text()");
+ assertTrue(advancedComparator.compare(node0, node2) < 0);
+ assertTrue(advancedComparator.compare(node2, node1) > 0);
+ assertTrue(advancedComparator.compare(node0, node1) > 0);
+ assertTrue(advancedComparator.compare(node1, node0) < 0);
+
+
+ }
+}
16 years, 9 months
JBoss Rich Faces SVN: r7768 - trunk/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2008-04-11 09:21:11 -0400 (Fri, 11 Apr 2008)
New Revision: 7768
Added:
trunk/docs/userguide/en/src/main/resources/images/inplaceSelectFct.png
trunk/docs/userguide/en/src/main/resources/images/inplaceSelectSC.png
trunk/docs/userguide/en/src/main/resources/images/inplaceSelectSoE.png
trunk/docs/userguide/en/src/main/resources/images/inplaceSelectTL.png
Log:
http://jira.jboss.com/jira/browse/RF-1226
additional images for InplaceSelect
Added: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectFct.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectFct.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectSC.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectSC.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectSoE.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectSoE.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectTL.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectTL.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 9 months
JBoss Rich Faces SVN: r7767 - trunk/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2008-04-11 09:20:25 -0400 (Fri, 11 Apr 2008)
New Revision: 7767
Added:
trunk/docs/userguide/en/src/main/resources/images/inplaceSelectCentLeft.png
Log:
http://jira.jboss.com/jira/browse/RF-1226
Added: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectCentLeft.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/userguide/en/src/main/resources/images/inplaceSelectCentLeft.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 9 months
JBoss Rich Faces SVN: r7766 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2008-04-11 09:05:31 -0400 (Fri, 11 Apr 2008)
New Revision: 7766
Modified:
trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.xml
Log:
http://jira.jboss.com/jira/browse/RF-1226 - Details of Usage were changed
Modified: trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.xml 2008-04-11 13:04:56 UTC (rev 7765)
+++ trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.xml 2008-04-11 13:05:31 UTC (rev 7766)
@@ -19,23 +19,23 @@
<tbody>
<row>
<entry>component-type</entry>
- <entry>org.richfaces.inplaceInput</entry>
+ <entry>org.richfaces.InplaceSelect</entry>
</row>
- <!--row>
+ <row>
<entry>component-class</entry>
- <entry></entry>
- </row-->
+ <entry>org.richfaces.component.html.HtmlInplaceSelect</entry>
+ </row>
<row>
- <entry>component-family</entry>
- <entry>org.richfaces.inplaceInput</entry>
+ <entry>component-family</entry>
+ <entry>org.richfaces.InplaceSelect</entry>
</row>
<row>
- <entry>renderer-type</entry>
- <entry>org.richfaces.renderkit.inplaceInputRenderer</entry>
+ <entry>renderer-type</entry>
+ <entry>org.richfaces.renderkit.InplaceSelectRenderer</entry>
</row>
<row>
<entry>tag-class</entry>
- <entry>org.richfaces.taglib.inplaceInputTag</entry>
+ <entry>org.richfaces.taglib.InplaceSelectTag</entry>
</row>
</tbody>
</tgroup>
@@ -49,10 +49,8 @@
<!-- itemLabels has to have realy value-->
<programlisting role="XML"><![CDATA[...
-<rich:inplaceSelect value="#{Bean.inputValue}" defaultLabel="Click to edit">
- <f:selectItems value="#{bean.selectItems}"/>
+<rich:inplaceSelect value="#{bean.inputValue}">
<f:selectItem itemValue="1" itemLabel="factory"/>
- <f:selectItem itemValue="2" itemLabel="newspaper"/>
</rich:inplaceSelect>
...]]></programlisting>
</section>
@@ -67,22 +65,51 @@
...]]></programlisting>
</section>
-
-
-
-
<!-- Start Details of Usage-->
<section>
<title>Details of Usage</title>
+
+ <para>
+ The <emphasis><property>"value"</property></emphasis> attribute is a value-binding expression for the current value of the component.
+ </para>
<para>
- The <emphasis role="bold"><property><rich:inplaceSelect></property> </emphasis> component has three functional states, which are:
- </para>
- <para>
+ The <emphasis role="bold"><property><rich:inplaceSelect></property> </emphasis> component has three functional states:
+ </para>
<itemizedlist>
<listitem>
- <para><property>View </property>state displays some sting type data that <emphasis><property>"value"</property></emphasis> or <emphasis><property>"defaultLabel"</property></emphasis> attributes contain;</para>
- <figure>
+ <para>
+ <property>View</property> state displays default label with the value taken from
+ <emphasis><property>"value"</property></emphasis> or <emphasis><property>"defaultLabel"</property></emphasis> attributes.
+ </para>
+ <para>
+ If the initial value of the <emphasis><property>"value"</property></emphasis>
+ attribute is "null" or <property>empty string</property>
+ the <emphasis><property>"defaultLabel"</property></emphasis> attribute is used to define default label.
+ </para>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<rich:inplaceSelect value="#{bean.value}" defaultLabel="click to edit">
+ <f:selectItems value="#{bean.selectItems}" />
+</rich:inplaceSelect>
+...]]> </programlisting>
+ <para>
+ The managed bean code:
+ </para>
+ <programlisting role="JAVA"><![CDATA[...
+private String value = "";
+...]]> </programlisting>
+ <para>
+ In the example above the <emphasis><property>"value"</property></emphasis> attribute is empty string
+ therefore "click to edit" value is displayed since it is placed into the
+ <emphasis><property>"defaultLabel"</property></emphasis> attribute.
+ </para>
+ <para>
+ This is the result:
+ </para>
+ <figure>
<title>View state</title>
<mediaobject>
<imageobject>
@@ -92,8 +119,10 @@
</figure>
</listitem>
<listitem>
- <para><property>Edit </property>state displays a list with options;</para>
- <figure>
+ <para>
+ <property>Edit </property>state - select representation to allow value edit
+ </para>
+ <figure>
<title>Edit state</title>
<mediaobject>
<imageobject>
@@ -103,7 +132,9 @@
</figure>
</listitem>
<listitem>
- <para><property>Changed </property>state displays the value of the selected option as text</para>
+ <para>
+ <property>Changed</property> state - value representation after it was changed
+ </para>
<figure>
<title>Changed state</title>
<mediaobject>
@@ -115,101 +146,159 @@
</listitem>
</itemizedlist>
- </para>
-
- <para>
- The
- <emphasis><property>"value"</property></emphasis>
- attribute displays the value as text.
- The attribute is defined when some option in the list is selected.
- </para>
-
-
-
-
- <para>You can form he list of the options: using
- <emphasis role="bold"><property><f:selectItem></property></emphasis> and
- <emphasis role="bold"><property><f:selectItems></property></emphasis> </para>
- <para>Please see the example below</para>
-
-
-
-
-
-<para>
+ <para>
+ You can form the list of the options using <emphasis role="bold"><property><f:selectItem/></property></emphasis> and
+ <emphasis role="bold"><property><f:selectItems/></property></emphasis> facets.
+ </para>
+ <para>
+ Please, see the example below.
+ </para>
+ <para>
<emphasis role="bold">Example:</emphasis>
</para>
<programlisting role="XML"><![CDATA[...
-<rich:inplaceSelect value="#{inplaceComponentsBean.inputValue}" showControls="true" defaultLabel="click to edit">
+<rich:inplaceSelect value="#{bean.inputValue}" defaultLabel="click to edit">
<f:selectItems value="#{bean.selectItems}"/>
<f:selectItem itemValue="1" itemLabel="factory"/>
<f:selectItem itemValue="2" itemLabel="newspaper"/>
</rich:inplaceSelect>
-...]]> </programlisting>
+...]]></programlisting>
<para>
- The <emphasis><property>"value"</property></emphasis> attribute gets
- some value when an option in the select-box in clicked on (the default action).
+ In the example above the value of the selected item is available via <emphasis><property>"value"</property></emphasis> attribute.
</para>
-
- <para>
- Nowever, if you want the end user to confirm the data saving explicitly you can: </para>
+ <para>
+ The <emphasis><property>"editEvent"</property></emphasis> attribute provides an option to assign an JavaScript action
+ that initiates the change of the state from <property>view</property> to <property>edit</property>.
+ The default value is "onclick".
+ </para>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<rich:inplaceSelect value="#{bean.inputValue}" defaultLabel="Double Click to edit" editEvent="ondblclick">
+ <f:selectItems value="#{demo.selectItems}" />
+</rich:inplaceSelect>
+...]]></programlisting>
+ <para>
+ The <emphasis role="bold"><property><rich:inplaceSelect></property></emphasis>
+ component provides specific event attributes:
+ </para>
<itemizedlist>
<listitem>
- <para>Use a <emphasis><property>"showControls"</property></emphasis> attribute, which makes "Save" and "Cancel" buttons (displayed as icons) appear next to the input field;
+ <para>
+ <emphasis><property>"oneditactivation"</property></emphasis> which is fired on <property>edit</property> state activation
</para>
- <para>Please see the example </para>
+ </listitem>
+ <listitem>
<para>
+ <emphasis><property>"oneditactivated"</property></emphasis> which is fired when <property>edit</property> state is activated
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis><property>"onviewactivation"</property></emphasis> which is fired on <property>view</property> state activation
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis><property>"onviewactivated"</property></emphasis> which is fired after the component is changed to representation state
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<rich:inplaceSelect value="#{bean.inputValue}" oneditactivation="if (confirm('Are you sure you want to change value?')){return false;}">
+ <f:selectItems value="#{demo.selectItems}" />
+</rich:inplaceSelect>
+...]]> </programlisting>
+ <para>
+ The given code illustrates how <emphasis><property>"oneditactivation"</property></emphasis> attribute works,
+ namely when the state is being changed from <property>view</property> to <property>edit</property>,
+ a confirmation window with a message "Are you sure you want to change value?" comes up.
+ </para>
+ <para>
+ The <emphasis><property>"selectOnEdit"</property></emphasis> (with possible values "true", "false") gives you an
+ option to make the text in the input field selected right after the change from <property>view</property> state to <property>edit</property> occurs.
+ </para>
+ <para>
+ Another useful attribute is <emphasis><property>"openOnEdit"</property></emphasis>.
+ With "true" value it defines that the drop-down list with items opens automatically after <property>edit</property> state is activated.
+ </para>
+
+ <para>
+ Nowever, if you want to confirm the data saving explicitly you can use the <emphasis><property>"showControls"</property></emphasis> attribute,
+ which makes "Save" and "Cancel" buttons (displayed as icons) appear next to the input field.
+ </para>
+ <para>
<emphasis role="bold">Example:</emphasis>
- </para>
-
+ </para>
<programlisting role="XML"><![CDATA[...
- <rich:inplaceSelect value="#{inplaceComponentsBean.inputValue}"
- defaultLabel="Click here to edit">
- <f:selectItem itemValue="0" itemLabel="oil well"/>
- <f:selectItem itemValue="1" itemLabel="factory"/>
- <f:selectItem itemValue="2" itemLabel="newspaper"/>
- </rich:inplaceSelect>
-...]]> </programlisting>
+<rich:inplaceSelect value="#{bean.inputValue}" showControls="true">
+ <f:selectItems value="#{bean.selectItems}"/>
+</rich:inplaceSelect>
+...]]></programlisting>
- </listitem>
-
+ <para>
+ You can also position the controls relatively to the input field, by means of
+ </para>
+ <itemizedlist>
<listitem>
- <para>Use standard buttons by means of the <emphasis><property>"controls"</property></emphasis>facet
+ <para>
+ The <emphasis><property>"controlsHorizontalPosition"</property></emphasis> attribute
+ with "left", "right" and "center" definitions
</para>
- <para>Please see the example </para>
+ </listitem>
+ <listitem>
<para>
+ The <emphasis><property>"controlsVerticalPosition "</property></emphasis> attribute
+ with "bottom", "center" and "top" definitions
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<rich:inplaceSelect value="#{bean.inputValue}" controlsHorizontalPosition="left" controlsVerticalPosition="bottom" showControls="true">
+ <f:selectItems value="#{bean.selectItems}"/>
+</rich:inplaceSelect>
+...]]> </programlisting>
+
+
+ <para>It is also possible to use <emphasis><property>"controls"</property></emphasis>
+ facet in order to replace the default controls with facets content. See the example below.
+ </para>
+ <para>Please, see the example.</para>
+ <para>
<emphasis role="bold">Example:</emphasis>
</para>
-
<programlisting role="XML"><![CDATA[...
-<rich:inplaceSelect value="#{inplaceComponentsBean.inputValue}" defaultLabel="Click to edit" showControls="true">
+<rich:inplaceSelect value="#{bean.inputValue}" showControls="true" controlsHorizontalPosition="left" controlsVerticalPosition="bottom">
<f:facet name="controls">
- <input type="button" value="Save"/>
- <input type="button" value="Cancel"/>
- </f:facet>
- <f:selectItem itemValue="0" itemLabel="oil well"/>
- <f:selectItem itemValue="1" itemLabel="factory"/>
- <f:selectItem itemValue="2" itemLabel="newspaper"/>
+ <button onclick="#{rich:component('inplaceSelect')}.save();" type="button">Save</button>
+ <button onclick="#{rich:component('inplaceSelect')}.cancel();" type="button">Cancel</button>
+ </f:facet>
+ <f:selectItems value="#{bean.selectItems}"/>
</rich:inplaceSelect>
...]]> </programlisting>
-
- </listitem>
- </itemizedlist>
-
-
+
<note>
<title>Note:</title>
<para>
- The <emphasis> <property>"controls"</property></emphasis>facet also implies using showcontrols
+ The <emphasis> <property>"controls"</property></emphasis>facet also implies using
+ <emphasis><property>"showControls"</property></emphasis>
attribute and it has to be defined as "true".
</para>
</note>
<!--Icons redefinitions-->
- <para>
+ <!--para>
Redefinition of the
"save" and "cancel" icons can be performed using
<emphasis><property>"saveControlIcon"</property></emphasis>
@@ -234,89 +323,28 @@
<f:selectItem itemValue="1" itemLabel="factory"/>
<f:selectItem itemValue="2" itemLabel="newspaper"/>
</rich:inplaceSelect>
- ...]]> </programlisting>
+ ...]]> </programlisting-->
<para>
- You can also position the controls relatively to the input field, by means of
- <emphasis><property>" controlsHorizontalPosition"</property></emphasis>
- <emphasis><property>" controlsVerticalPosition "</property></emphasis>
- attributes.
-
- The
- <emphasis><property>" controlsHorizontalPosition"</property></emphasis> attribute has
- "left", "right" and "center" definitions.
-
- The
- <emphasis><property>" controlsVerticalPosition "</property></emphasis>
- attribute has "bottom", "center" and "top" definitions.
+ The <emphasis role="bold"><property><rich:inplaceSelect></property></emphasis> component could be rendered with
+ <emphasis role="bold"><property><span></property></emphasis> or <emphasis role="bold"><property><div></property></emphasis>
+ elements to display its value.
+ In order to change default <emphasis role="bold"><property><span></property></emphasis> output,
+ use the <emphasis><property>"layout"</property></emphasis> attribute with "block" value.
</para>
-
-
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
- <programlisting role="XML"><![CDATA[...
-<rich:inplaceSelect value="#{inplaceComponentsBean.inputValue}" defaultLabel="Click to edit" controlsHorizontalPosition="left" controlsVerticalPosition="top" showControls="true">
- <f:facet name="controls" >
- <input type="button" value="Save"/>
- <input type="button" value="Cancel"/>
- </f:facet>
- <f:selectItem itemValue="0" itemLabel="oil well"/>
- <f:selectItem itemValue="1" itemLabel="factory"/>
- <f:selectItem itemValue="2" itemLabel="newspaper"/>
-</rich:inplaceSelect>
-...]]> </programlisting>
-
- <para>
- Another useful attribute is
- <emphasis><property>"openOnEdit"</property></emphasis>.
- It allows you to make the drop-down box with options appear once "edit" state activated.
- </para>
-
-
-
-
-
-
<para>
- The
- <emphasis><property>"editEvent"</property></emphasis>
- attribute provides an option to assign an JavaScript action that initiates the change of the state from
- <property>view</property>
- to
- <property>edit</property>.
-
-
- The default value is "click".
-
- </para>
-
-
-
- <note>
- <title>Note:</title>
- <para>
- Do not use "on" prefix applying event action. E.g. use "click" instead of "onClick", use "mouseover" instead of "onMouseOver".
- </para>
- </note>
-
- <para>
- The
- <emphasis><property>"selectOnEdit"</property></emphasis>
- (with possible values "true", "false") gives you an
- option to make the text in the input area selected right after the change from
- <property>view</property> state to <property>edit</property> occurs.
-
- </para>
-
-
+ The <emphasis role="bold"><property><rich:inplaceSelect></property></emphasis> component supports standard
+ <emphasis><property>"tabindex"</property></emphasis> attribute.
+ When the component gets focus and the <emphasis><property>"editOnTab"</property></emphasis> attribute is "true"
+ the <property>edit</property> mode is activated and drop-down list is opened.
+ </para>
<para>
The
- <emphasis><property>" inputWidth"</property></emphasis> ,
- <emphasis><property>" minInputWidth"</property></emphasis> , and
- <emphasis><property>" maxInputWidth"</property></emphasis>
+ <emphasis><property>"selectWidth"</property></emphasis> ,
+ <emphasis><property>"minSelectWidth"</property></emphasis> and
+ <emphasis><property>"maxSelectWidth"</property></emphasis>
attributes are provided to specify the width, minimal width and maximal width for the input element respectively.
</para>
<para>
@@ -326,19 +354,6 @@
</para>
- <para>
- The
- <emphasis><property>" oneditactivation"</property></emphasis> ,
- <emphasis><property>"oneditactivated"</property></emphasis> ,
- <emphasis><property>"onviewactivation"</property></emphasis>
- and
- <emphasis><property>" onviewactivated"</property></emphasis> attributes
- provide a possibility to assign JavaScript code on
- <property>edit</property> state activation, on
- <property>edit</property> state activated,on
- <property>view</property> state activation and on
- <property>view</property> state activated respectively.
- </para>
</section>
<!-- End. Details of Usage-->
16 years, 9 months
JBoss Rich Faces SVN: r7765 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2008-04-11 09:04:56 -0400 (Fri, 11 Apr 2008)
New Revision: 7765
Modified:
trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.desc.xml
Log:
http://jira.jboss.com/jira/browse/RF-1226 - Key features were changed according to doc-file
Modified: trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.desc.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.desc.xml 2008-04-11 13:04:31 UTC (rev 7764)
+++ trunk/docs/userguide/en/src/main/docbook/included/inplaceSelect.desc.xml 2008-04-11 13:04:56 UTC (rev 7765)
@@ -23,12 +23,27 @@
<section>
<title>Key Features</title>
<itemizedlist>
- <listitem>Option to display "Save", "Cancel" buttons as icons</listitem>
- <listitem>Option to display "Save", "Cancel" buttons as standard buttons</listitem>
- <listitem>Possibility to assign an JavaScript action on state change</listitem>
- <listitem>Switching between<emphasis role="bold"><property><rich:inplaceSelect></property></emphasis> components using "Tab" key</listitem>
- <listitem>Resizable select field</listitem>
- <listitem>Full skinability </listitem>
+ <listitem>
+ <para>View/changed/edit states highly customizable representations</para>
+ </listitem>
+ <listitem>
+ <para>Optional "inline" or "block" element rendering on a page</para>
+ </listitem>
+ <listitem>
+ <para>Changing state event customization</para>
+ </listitem>
+ <listitem>
+ <para>Possibility to call custom JavaScript function on state changes</para>
+ </listitem>
+ <listitem>
+ <para>Edit mode activation when the component got focus with the "Tab"</para>
+ </listitem>
+ <listitem>
+ <para>Sizes synchronizations between modes</para>
+ </listitem>
+ <listitem>
+ <para>Highly customizable look and feel</para>
+ </listitem>
</itemizedlist>
</section>
</section>
\ No newline at end of file
16 years, 9 months
JBoss Rich Faces SVN: r7764 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2008-04-11 09:04:31 -0400 (Fri, 11 Apr 2008)
New Revision: 7764
Modified:
trunk/docs/userguide/en/src/main/docbook/included/inplaceInput.xml
Log:
http://jira.jboss.com/jira/browse/RF-1226 - edit position the controls
Modified: trunk/docs/userguide/en/src/main/docbook/included/inplaceInput.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/inplaceInput.xml 2008-04-11 12:22:38 UTC (rev 7763)
+++ trunk/docs/userguide/en/src/main/docbook/included/inplaceInput.xml 2008-04-11 13:04:31 UTC (rev 7764)
@@ -252,7 +252,7 @@
</listitem>
<listitem>
<para>
- <emphasis><property>"controlsVerticalPosition "</property></emphasis> attribute
+ The <emphasis><property>"controlsVerticalPosition "</property></emphasis> attribute
with "bottom", "center" and "top" definitions
</para>
</listitem>
16 years, 9 months
JBoss Rich Faces SVN: r7763 - in branches/3.1.x/ui/calendar/src/main: java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2008-04-11 08:22:38 -0400 (Fri, 11 Apr 2008)
New Revision: 7763
Modified:
branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
http://jira.jboss.com/jira/browse/RF-3003
http://jira.jboss.com/jira/browse/RF-2269
Modified: branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml 2008-04-11 11:48:28 UTC (rev 7762)
+++ branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml 2008-04-11 12:22:38 UTC (rev 7763)
@@ -554,6 +554,23 @@
<name>label</name>
<classname>java.lang.String</classname>
<description>A localized user presentable name for this component.</description>
+ </property>
+ <property>
+ <name>firstWeekDay</name>
+ <classname>int</classname>
+ <description>Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.</description>
+ <defaultvalue>getDefaultFirstWeekDay()</defaultvalue>
+ </property>
+ <property>
+ <name>minDaysInFirstWeek</name>
+ <classname>int</classname>
+ <description>
+ Gets what the minimal days required in the first week of the year
+ are; e.g., if the first week is defined as one that contains the first
+ day of the first month of a year, this method returns 1. If the
+ minimal days required must be a full week, this method returns 7.
+ </description>
+ <defaultvalue>getDefaultMinDaysInFirstWeek()</defaultvalue>
</property>
<property>
<name>showHeader</name>
Modified: branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-11 11:48:28 UTC (rev 7762)
+++ branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-11 12:22:38 UTC (rev 7763)
@@ -204,8 +204,13 @@
public abstract boolean isShowApplyButton();
public abstract void setShowApplyButton(boolean showApplyButton);
+
+ public abstract int getFirstWeekDay();
+ public abstract void setFirstWeekDay(int firstWeekDay);
+
+ public abstract int getMinDaysInFirstWeek();
+ public abstract void setMinDaysInFirstWeek(int minDaysInFirstWeek);
-
// TODO onclick add users onclick
// currentDate processing -------------------------------------------------
@@ -606,5 +611,14 @@
}
}
}
+
+ protected int getDefaultFirstWeekDay() {
+ Calendar cal = getCalendar();
+ return cal.getFirstDayOfWeek() - cal.getActualMinimum(Calendar.DAY_OF_WEEK);
+ }
+
+ protected int getDefaultMinDaysInFirstWeek() {
+ return getCalendar().getMinimalDaysInFirstWeek();
+ }
}
Modified: branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2008-04-11 11:48:28 UTC (rev 7762)
+++ branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2008-04-11 12:22:38 UTC (rev 7763)
@@ -449,15 +449,12 @@
public String getFirstWeekDay(FacesContext context, UICalendar calendar)
throws IOException {
- Calendar cal = calendar.getCalendar();
- return String.valueOf(cal.getFirstDayOfWeek()
- - cal.getActualMinimum(Calendar.DAY_OF_WEEK));
+ return String.valueOf(calendar.getFirstWeekDay());
}
public String getMinDaysInFirstWeek(FacesContext context,
UICalendar calendar) throws IOException {
- Calendar cal = calendar.getCalendar();
- return String.valueOf(cal.getMinimalDaysInFirstWeek());
+ return String.valueOf(calendar.getMinDaysInFirstWeek());
}
public String getCurrentDateAsString(FacesContext context, UICalendar calendar, Date date)
16 years, 9 months
JBoss Rich Faces SVN: r7762 - trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/fileUpload.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2008-04-11 07:48:28 -0400 (Fri, 11 Apr 2008)
New Revision: 7762
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/fileUpload/FileUploadBean.java
Log:
Fixed compilation problem.
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/fileUpload/FileUploadBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/fileUpload/FileUploadBean.java 2008-04-11 11:47:11 UTC (rev 7761)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/fileUpload/FileUploadBean.java 2008-04-11 11:48:28 UTC (rev 7762)
@@ -34,7 +34,7 @@
public void paint(OutputStream stream, Object object) throws IOException {
stream.write(getFiles().get((Integer)object).getData());
}
- public void listener(UploadEvent event) throws IOException{
+ public void listener(UploadEvent event) throws Exception{
UploadItem item = event.getUploadItem();
File file = new File();
file.setLength(item.getData().length);
16 years, 9 months
JBoss Rich Faces SVN: r7761 - in trunk/ui/inplaceSelect/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 07:47:11 -0400 (Fri, 11 Apr 2008)
New Revision: 7761
Modified:
trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java
trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
Log:
apply TODO, http://jira.jboss.com/jira/browse/RF-3021
Modified: trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java
===================================================================
--- trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java 2008-04-11 11:46:07 UTC (rev 7760)
+++ trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java 2008-04-11 11:47:11 UTC (rev 7761)
@@ -11,5 +11,5 @@
*/
public abstract class UIInplaceSelect extends UISelectOne{
public static final String COMPONENT_TYPE = "org.richfaces.InplaceSelect";
- final static public String COMPONENT_FAMILY = "org.richfaces.InplaceSelect";
+ public static final String COMPONENT_FAMILY = "org.richfaces.InplaceSelect";
}
Modified: trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
--- trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-04-11 11:46:07 UTC (rev 7760)
+++ trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-04-11 11:47:11 UTC (rev 7761)
@@ -44,7 +44,7 @@
variables.setVariable("fieldLabel", fieldLabel);
variables.setVariable("fieldValue", fieldValue);
- /*String saveIcon = (String)component.getAttributes().get("saveControlIcon");
+ String saveIcon = (String)component.getAttributes().get("saveControlIcon");
if (saveIcon != null && saveIcon.length() != 0 ) {
variables.setVariable("saveIcon", saveIcon);
}
@@ -53,13 +53,13 @@
if (cancelIcon != null && cancelIcon.length() != 0 ) {
variables.setVariable("cancelIcon", cancelIcon);
}
- //TODO use EL exprs.
+
String controlClass = (String)component.getAttributes().get("controlClass");
variables.setVariable("controlClass", controlClass);
String controlHoveredClass = (String)component.getAttributes().get("controlHoveredClass");
variables.setVariable("controlHoveredClass", controlHoveredClass);
String controlPressedClass = (String)component.getAttributes().get("controlPressedClass");
- variables.setVariable("controlPressedClass", controlPressedClass);*/
+ variables.setVariable("controlPressedClass", controlPressedClass);
String layout = (String)component.getAttributes().get("layout");
if (layout != null && layout.length() != 0) {
@@ -96,7 +96,7 @@
readonly="readonly"
class="rich-inplace-select-field"/>
<input id="#{clientId}inselArrow" readonly="readonly" type="Text" value="" class="rich-inplace-select-arrow" style='display:none;'/>
- <input id='#{clientId}inplaceValue' name='#{clientId}' type='hidden' value='#{fieldValue}'/>
+ <input id='#{clientId}inplaceValue' name='#{clientId' type='hidden' value='#{fieldValue}'/>
<div id="#{clientId}bar" class="rich-inplace-select-control-set" style="display:none;">
<jsp:scriptlet>
<![CDATA[
@@ -126,8 +126,19 @@
</table>
</div>
<div id="#{clientId}buttons" style="position : relative">
- <input id="#{clientId}ok" type="image" src="#{saveIcon}" class="rich-inplace-select-control" onmousedown="this.className='rich-inplace-select-control-press'" onmouseout="this.className='rich-inplace-select-control'" onmouseup="this.className='rich-inplace-select-control'"/>
- <input id="#{clientId}cancel" type="image" src="#{cancelIcon}" class="rich-inplace-select-control" onmousedown="this.className='rich-inplace-select-control-press'" onmouseout="this.className='rich-inplace-select-control'" onmouseup="this.className='rich-inplace-select-control'"/>
+ <input id="#{clientId}ok" type="image" src="#{saveIcon}"
+ class="rich-inplace-select-control #{controlClass}"
+ onmousedown="this.className='rich-inplace-select-control-press #{controlPressedClass}'"
+ onmouseout="this.className='rich-inplace-select-control #{controlClass}'"
+ onmouseup="this.className='rich-inplace-select-control #{controlClass}'"
+ onmouseover="this.className='rich-inplace-select-control #{controlHoverClass}'"/>
+ <input id="#{clientId}cancel" type="image" src="#{cancelIcon}"
+ class="rich-inplace-select-control #{controlClass}"
+ onmousedown="this.className='rich-inplace-select-control-press #{controlPressedClass}''"
+ onmouseout="this.className='rich-inplace-select-control #{controlClass}'"
+ onmouseup="this.className='rich-inplace-select-control#{controlClass}'"
+ onmouseover="this.className='rich-inplace-select-control #{controlHoverClass}'"
+ />
</div>
<jsp:scriptlet>
16 years, 9 months