Author: alexsmirnov
Date: 2009-01-08 18:50:53 -0500 (Thu, 08 Jan 2009)
New Revision: 12167
Added:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ContentBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ParsingException.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/TabNavigation.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBody.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBodySerializer.java
trunk/samples/beanValidatorSample/src/main/webapp/example/
trunk/samples/beanValidatorSample/src/main/webapp/example/pages/
trunk/samples/beanValidatorSample/src/main/webapp/example/pages/textValidation.xhtml
trunk/samples/beanValidatorSample/src/main/webapp/pages/beanValidation.xhtml
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/example/
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/example/Bean.java
Removed:
trunk/samples/beanValidatorSample/src/main/webapp/pages/textValidation.xhtml
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/Bean.java
Modified:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Pages.java
trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml
trunk/samples/beanValidatorSample/src/main/webapp/pages/ajaxValidation.xhtml
trunk/ui/insert/src/main/java/org/ajax4jsf/renderkit/AbstractInsertRenderer.java
Log:
<rich:insert performance optimisation.
beanValidationSample improvement
Added: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ContentBean.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ContentBean.java
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ContentBean.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,53 @@
+/**
+ *
+ */
+package org.richfaces;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ContentBean {
+
+ private static final String PRELUDE="<html
xmlns=\"http://www.w3.org/1999/xhtml\"\n" +
+ "
xmlns:f=\"http://java.sun.com/jsf/core\"\n" +
+ "
xmlns:h=\"http://java.sun.com/jsf/html\"\n" +
+ "
xmlns:a4j=\"http://richfaces.org/a4j\"\n" +
+ "
xmlns:rich=\"http://richfaces.org/rich\"\n" +
+ "
xmlns:c=\"http://java.sun.com/jsp/jstl/core\">\n";
+
+ private static final String TAIL="\n</html>";
+
+ private String
xpath="//*[local-name()='define'][@name='content']/*";
+
+ public String getContent() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ String viewId = context.getViewRoot().getViewId();
+ XMLBody xmlBody = new XMLBody();
+ try {
+ xmlBody.loadXML(context.getExternalContext().getResourceAsStream(viewId),false);
+ return PRELUDE+xmlBody.getContent(getXpath())+TAIL;
+ } catch (ParsingException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ /**
+ * @param xpath the xpath to set
+ */
+ public void setXpath(String xpath) {
+ this.xpath = xpath;
+ }
+
+ /**
+ * @return the xpath
+ */
+ public String getXpath() {
+ return xpath;
+ }
+
+}
Property changes on:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ContentBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Pages.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Pages.java 2009-01-08
23:31:40 UTC (rev 12166)
+++ trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Pages.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -24,12 +24,13 @@
public class Pages {
+ public static final String DEFAULT_TITLE_PATTERN =
"<h1>(.*)</h1>";
+
private static final Pattern JSP_PATTERN = Pattern.compile(".*\\.jspx?");
private static final Pattern XHTML_PATTERN = Pattern.compile(".*\\.xhtml");
- private static final Pattern TITLE_PATTERN = Pattern.compile(
- "<h1>(.*)</h1>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
+ private Pattern titlePattern = compilePattern(DEFAULT_TITLE_PATTERN);
private List<PageDescriptionBean> _jspPages;
@@ -44,6 +45,11 @@
return _path;
}
+ public Pattern compilePattern(String titlePattern) {
+ return Pattern.compile(
+ titlePattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
+ }
+
/**
* @param path
* the path to set
@@ -98,7 +104,7 @@
try {
int readed = pageInputStream.read(head);
String headString = new String(head, 0, readed);
- Matcher titleMatcher = TITLE_PATTERN
+ Matcher titleMatcher = titlePattern
.matcher(headString);
if (titleMatcher.find()
&& titleMatcher.group(1).length() > 0) {
@@ -124,5 +130,19 @@
return jspPages;
}
+ /**
+ * @param titlePattern the titlePattern to set
+ */
+ public void setTitlePattern(String titlePattern) {
+ this.titlePattern = compilePattern(titlePattern);
+ }
+ /**
+ * @return the titlePattern
+ */
+ public String getTitlePattern() {
+ return titlePattern.toString();
+ }
+
+
}
Added:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ParsingException.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ParsingException.java
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ParsingException.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+package org.richfaces;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ParsingException extends Exception {
+
+ /**
+ *
+ */
+ public ParsingException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public ParsingException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public ParsingException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/ParsingException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/TabNavigation.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/TabNavigation.java
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/TabNavigation.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.richfaces;
+
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UITabPanel;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class TabNavigation {
+
+ private UITabPanel tabPanel;
+
+ /**
+ * @return the tabPanel
+ */
+ public UITabPanel getTabPanel() {
+ return tabPanel;
+ }
+
+ /**
+ * @param tabPanel the tabPanel to set
+ */
+ public void setTabPanel(UITabPanel tabPanel) {
+ this.tabPanel = tabPanel;
+ FacesContext context = FacesContext.getCurrentInstance();
+ Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
+ if(requestParameterMap.containsKey("page")){
+ tabPanel.setValue("page");
+ } else if(requestParameterMap.containsKey("java")){
+ tabPanel.setValue("java");
+ } else if(requestParameterMap.containsKey("usage")){
+ tabPanel.setValue("usage");
+ }
+ }
+
+}
Property changes on:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/TabNavigation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBody.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBody.java
(rev 0)
+++ trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBody.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,219 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+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.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * This class must read XML file from input stream and can extract body of root
+ * element for include into target in generation.
+ *
+ * @author shura
+ *
+ */
+public class XMLBody {
+ private Document xmlDocument;
+
+ private Element rootElement;
+
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input) throws ParsingException {
+ loadXML(input,false);
+ }
+
+
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input, boolean namespaceAware) throws ParsingException
{
+ try {
+ // 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();
+
+ // Disable loading of external Entityes
+ docBuilder.setEntityResolver(new EntityResolver() {
+ // Dummi resolver - alvays do nothing
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+
+ });
+
+ // open and parse XML-file
+ xmlDocument = docBuilder.parse(input);
+
+ // Get Root xmlElement
+ rootElement = xmlDocument.getDocumentElement();
+ } catch (Exception e) {
+ throw new ParsingException("Error load XML ", e);
+ }
+
+ }
+
+ /**
+ * Check name of root element is as expected.
+ *
+ * @param name
+ * @return
+ */
+ public boolean isRootName(String name) {
+ return rootElement.getNodeName().equals(name);
+ }
+
+ public String getDoctype() {
+ DocumentType doctype = xmlDocument.getDoctype();
+ if (null != doctype) {
+ return doctype.getName();
+ }
+ return null;
+ }
+
+ public String getPiblicId() {
+ DocumentType doctype = xmlDocument.getDoctype();
+ if (null != doctype) {
+ return doctype.getPublicId();
+ }
+ return null;
+ }
+
+ public String getRootTypeName() {
+ return rootElement.getSchemaTypeInfo().getTypeName();
+ }
+
+ public String getContent() throws ParsingException {
+ NodeList childNodes = rootElement.getChildNodes();
+ return serializeNodes(childNodes);
+ }
+
+ private String serializeNodes(NodeList childNodes) throws ParsingException {
+ try {
+ 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);
+ } catch (XPathExpressionException e) {
+ throw new ParsingException("Error evaluate xpath",e);
+ }
+ return childNodes;
+ }
+
+ public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String>
keySet) throws ParsingException {
+ if (keyXPath == null) {
+ return getByXpath(xpath);
+ } else {
+ XPath path = XPathFactory.newInstance().newXPath();
+ NodeList childNodes;
+ try {
+ childNodes = getByXpath(xpath);
+
+ List<Node> nodeSet = new ArrayList<Node>();
+
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node node = childNodes.item(i).cloneNode(true);
+
+ String key = serializeNodes((NodeList) path.evaluate(keyXPath, node,
XPathConstants.NODESET));
+ if (!keySet.contains(key)) {
+ keySet.add(key);
+ nodeSet.add(node);
+ }
+ }
+ 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 {
+ private Node[] nodes;
+
+ public ArrayNodeList(Node[] nodes) {
+ super();
+ this.nodes = nodes;
+ }
+
+ public int getLength() {
+ return nodes.length;
+ }
+
+ public Node item(int index) {
+ if (index < nodes.length) {
+ return this.nodes[index];
+ }
+
+ return null;
+ }
+}
Property changes on:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBody.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBodySerializer.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBodySerializer.java
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBodySerializer.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,77 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces;
+
+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.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);
+ }
+ }
+}
Property changes on:
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/XMLBodySerializer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml 2009-01-08
23:31:40 UTC (rev 12166)
+++ trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml 2009-01-08
23:50:53 UTC (rev 12167)
@@ -4,7 +4,7 @@
<faces-config>
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
- <managed-bean-class>org.richfaces.Bean</managed-bean-class>
+ <managed-bean-class>org.richfaces.example.Bean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
@@ -27,4 +27,14 @@
<managed-bean-class>org.richfaces.Pages</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>contentBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.ContentBean</managed-bean-class>
+ <managed-bean-scope>none</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>tabNavigation</managed-bean-name>
+ <managed-bean-class>org.richfaces.TabNavigation</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
</faces-config>
Added:
trunk/samples/beanValidatorSample/src/main/webapp/example/pages/textValidation.xhtml
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/example/pages/textValidation.xhtml
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/webapp/example/pages/textValidation.xhtml 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,18 @@
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+ <h:form id="form">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="text" value="Enter Id" />
+ <h:inputText id="text" value="#{bean.text}"
label="Id">
+ <rich:beanValidator summary="Invalid Id"/>
+ </h:inputText>
+ <rich:message for="text" showDetail="true"
showSummary="true" />
+ </h:panelGrid>
+ <h:commandButton value="Submit"></h:commandButton>
+ <rich:messages/>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Property changes on:
trunk/samples/beanValidatorSample/src/main/webapp/example/pages/textValidation.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml 2009-01-08
23:31:40 UTC (rev 12166)
+++ trunk/samples/beanValidatorSample/src/main/webapp/layout/template.xhtml 2009-01-08
23:50:53 UTC (rev 12167)
@@ -20,14 +20,15 @@
<div class="yui-main">
<div class="yui-b">
<!-- YOUR DATA GOES HERE -->
- <rich:tabPanel switchType="ajax">
- <rich:tab label="Usage">
+ <rich:tabPanel binding="#{tabNavigation.tabPanel}"
switchType="ajax">
+ <rich:tab name="usage" label="Usage">
+ <ui:insert name="description" />
<ui:insert name="content" />
</rich:tab>
- <rich:tab label="Page Source">
- <rich:insert src="#{facesContext.viewRoot.viewId}"
highlight="xhtml"/>
+ <rich:tab name="page" label="Page Source">
+ <rich:insert content="#{contentBean.content}"
highlight="xhtml"/>
</rich:tab>
- <rich:tab label="Java Source" rendered="#{!empty
javaBean}">
+ <rich:tab name="java" label="Java Source"
rendered="#{!empty javaBean}">
<rich:insert src="/src/#{javaBean}"
highlight="java"/>
</rich:tab>
</rich:tabPanel>
Modified: trunk/samples/beanValidatorSample/src/main/webapp/pages/ajaxValidation.xhtml
===================================================================
---
trunk/samples/beanValidatorSample/src/main/webapp/pages/ajaxValidation.xhtml 2009-01-08
23:31:40 UTC (rev 12166)
+++
trunk/samples/beanValidatorSample/src/main/webapp/pages/ajaxValidation.xhtml 2009-01-08
23:50:53 UTC (rev 12167)
@@ -9,7 +9,7 @@
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition template="/layout/template.xhtml">
<ui:param name="title" value="<rich:ajaxValidator>
usage" />
- <ui:param name="javaBean" value="org/richfaces/Bean.java" />
+ <ui:param name="javaBean" value="org/richfaces/example/Bean.java"
/>
<!-- Page header -->
<ui:define name="header">
<h1><rich:ajaxValidator> usage</h1>
Copied: trunk/samples/beanValidatorSample/src/main/webapp/pages/beanValidation.xhtml (from
rev 12158, trunk/samples/beanValidatorSample/src/main/webapp/pages/textValidation.xhtml)
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/pages/beanValidation.xhtml
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/webapp/pages/beanValidation.xhtml 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:c="http://java.sun.com/jsp/jstl/core">
+<ui:composition template="/layout/template.xhtml">
+ <ui:param name="title" value="<rich:beanValidator>
usage" />
+ <ui:param name="javaBean" value="org/richfaces/example/Bean.java"
/>
+ <!-- Page header -->
+ <ui:define name="header">
+ <h1><rich:beanValidator> usage</h1>
+ </ui:define>
+ <!-- content -->
+ <ui:define name="content">
+ <h:form id="form">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="email" value="Email Address:" />
+ <h:inputText id="email" value="#{bean.email}"
label="Email">
+ <rich:beanValidator summary="Invalid Email address"/>
+ </h:inputText>
+ <rich:message for="email"/>
+ <h:outputLabel for="card" value="Credit card number:" />
+ <h:inputText id="card" value="#{bean.creditCardNumber}"
label="Credit card">
+ <rich:beanValidator summary="Invalid credit card number"/>
+ </h:inputText>
+ <rich:message for="card"/>
+ </h:panelGrid>
+ <h:commandButton value="Submit"></h:commandButton>
+ <rich:messages/>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
Property changes on:
trunk/samples/beanValidatorSample/src/main/webapp/pages/beanValidation.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/samples/beanValidatorSample/src/main/webapp/pages/textValidation.xhtml
===================================================================
---
trunk/samples/beanValidatorSample/src/main/webapp/pages/textValidation.xhtml 2009-01-08
23:31:40 UTC (rev 12166)
+++
trunk/samples/beanValidatorSample/src/main/webapp/pages/textValidation.xhtml 2009-01-08
23:50:53 UTC (rev 12167)
@@ -1,31 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.org/rich"
-
xmlns:s="http://jboss.com/products/seam/taglib"
-
xmlns:c="http://java.sun.com/jsp/jstl/core">
-<ui:composition template="/layout/template.xhtml">
- <ui:param name="title" value="<rich:beanValidator>
usage" />
- <!-- Page header -->
- <ui:define name="header">
- <h1><rich:beanValidator> usage</h1>
- </ui:define>
- <!-- content -->
- <ui:define name="content">
- <h:form id="form">
- <h:panelGrid columns="3">
- <h:outputLabel for="text" value="Enter Id" />
- <h:inputText id="text" value="#{bean.text}"
label="Id">
- <rich:beanValidator summary="Invalid Id"/>
- </h:inputText>
- <rich:message for="text" showDetail="true"
showSummary="true" />
- </h:panelGrid>
- <h:commandButton value="Submit"></h:commandButton>
- <rich:messages/>
- </h:form>
- </ui:define>
-</ui:composition>
-</html>
Deleted: trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/Bean.java
===================================================================
---
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/Bean.java 2009-01-08
23:31:40 UTC (rev 12166)
+++
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/Bean.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces;
-
-import org.hibernate.validator.Length;
-import org.hibernate.validator.NotEmpty;
-
-/**
- * JSF bean with text property validation.
- */
-public class Bean {
-
- /**
- * Text property
- */
- private String text;
-
- /**
- * @return the text
- */
- @NotEmpty
- @Length(max=5)
- public String getText() {
- return text;
- }
-
- /**
- * @param text the text to set
- */
- public void setText(String text) {
- this.text = text;
- }
-
-}
\ No newline at end of file
Copied:
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/example/Bean.java
(from rev 12158,
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/Bean.java)
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/example/Bean.java
(rev 0)
+++
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/example/Bean.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -0,0 +1,71 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.example;
+
+import org.hibernate.validator.CreditCardNumber;
+import org.hibernate.validator.Email;
+import org.hibernate.validator.NotEmpty;
+
+/**
+ * JSF bean with text property validation.
+ */
+public class Bean {
+
+ /**
+ * Text property
+ */
+ private String email;
+
+ private String creditCardNumber;
+
+ /**
+ * @return the creditCardNumber
+ */
+ @CreditCardNumber
+ public String getCreditCardNumber() {
+ return creditCardNumber;
+ }
+
+ /**
+ * @param creditCardNumber the creditCardNumber to set
+ */
+ public void setCreditCardNumber(String creditCardNumber) {
+ this.creditCardNumber = creditCardNumber;
+ }
+
+ /**
+ * @return the text
+ */
+ @NotEmpty
+ @Email
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setEmail(String text) {
+ this.email = text;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/samples/beanValidatorSample/src/main/webapp/src/org/richfaces/example/Bean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/ui/insert/src/main/java/org/ajax4jsf/renderkit/AbstractInsertRenderer.java
===================================================================
---
trunk/ui/insert/src/main/java/org/ajax4jsf/renderkit/AbstractInsertRenderer.java 2009-01-08
23:31:40 UTC (rev 12166)
+++
trunk/ui/insert/src/main/java/org/ajax4jsf/renderkit/AbstractInsertRenderer.java 2009-01-08
23:50:53 UTC (rev 12167)
@@ -56,8 +56,10 @@
public void renderContent(FacesContext context, UIInsert component)
throws IOException {
- boolean isSrcAvailable = (component.getSrc() != null);
- boolean isContentAvailable = (component.getContent() != null);
+ String src = component.getSrc();
+ boolean isSrcAvailable = (src != null);
+ String content = component.getContent();
+ boolean isContentAvailable = (content != null);
if (isSrcAvailable && isContentAvailable) {
throw new FacesException(UIInsert.ILLEGAL_ATTRIBUTE_VALUE_MESSAGE);
}
@@ -67,9 +69,9 @@
InputStream inputStream = null;
if (isSrcAvailable) {
- inputStream = externalContext.getResourceAsStream(component.getSrc());
+ inputStream = externalContext.getResourceAsStream(src);
} else if (isContentAvailable) {
- inputStream = new ByteArrayInputStream(component.getContent().getBytes());
+ inputStream = new ByteArrayInputStream(content.getBytes());
}
if (null != inputStream) {
renderStream(context, component, inputStream);