You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/11/17 00:38:25 UTC
svn commit: r475985 - in /tapestry/tapestry5/tapestry-core/trunk/src:
main/java/org/apache/tapestry/corelib/components/
main/java/org/apache/tapestry/corelib/pages/
main/java/org/apache/tapestry/dom/
main/java/org/apache/tapestry/internal/services/ mai...
Author: hlship
Date: Thu Nov 16 15:38:22 2006
New Revision: 475985
URL: http://svn.apache.org/viewvc?view=rev&rev=475985
Log:
Add a strategy for generating end tags from DOM elements that is based on the type of markup.
Extend ExceptionReport page to display Session attributes.
Add a TextArea component.
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/EndTagStyle.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/XMLMarkupModel.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/DefaultMarkupModel.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Document.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/MarkupModel.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Text.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/SimpleForm.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/document_with_root_element_and_attributes.txt
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/nested_elements.txt
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html
Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java?view=auto&rev=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java Thu Nov 16 15:38:22 2006
@@ -0,0 +1,38 @@
+package org.apache.tapestry.corelib.components;
+
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.annotations.AfterRender;
+import org.apache.tapestry.annotations.BeginRender;
+import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.services.WebRequest;
+
+public class TextArea extends AbstractField
+{
+
+ @Parameter(required = true)
+ private Object _value;
+
+ @BeginRender
+ void begin(MarkupWriter writer)
+ {
+ writer.element("textarea", "name", getElementName(), "id", getClientId(), "value", _value);
+ }
+
+ @AfterRender
+ void after(MarkupWriter writer)
+ {
+ // TextArea will not have a template. Should we forbid a body?
+
+ if (_value != null)
+ writer.write(_value.toString());
+
+ writer.end(); // textarea
+ }
+
+ @Override
+ protected void processSubmission(WebRequest request)
+ {
+ _value = request.getParameter(getElementName());
+ }
+
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java Thu Nov 16 15:38:22 2006
@@ -22,12 +22,12 @@
import org.apache.tapestry.ioc.services.ExceptionAnalyzer;
import org.apache.tapestry.ioc.services.ExceptionInfo;
import org.apache.tapestry.services.ExceptionReporter;
+import org.apache.tapestry.services.WebRequest;
+import org.apache.tapestry.services.WebSession;
/**
* Responsible for reporting runtime exceptions. This page is quite verbose and is usually
* overridden in a production application.
- *
- *
*/
@ComponentClass
public class ExceptionReport implements ExceptionReporter
@@ -35,14 +35,19 @@
private List<ExceptionInfo> _stack;
private ExceptionInfo _info;
-
+
private String _propertyName;
-
+
private String _frame;
+ private String _attributeName;
+
@Inject("service:tapestry.ioc.ExceptionAnalyzer")
private ExceptionAnalyzer _analyzer;
+ @Inject("infrastructure:request")
+ private WebRequest _request;
+
public void reportException(Throwable exception)
{
ExceptionAnalysis analysis = _analyzer.analyze(exception);
@@ -84,9 +89,34 @@
{
_propertyName = propertyName;
}
-
+
public Object getPropertyValue()
{
return _info.getProperty(_propertyName);
+ }
+
+ public boolean getHasSession()
+ {
+ return _request.getSession(false) != null;
+ }
+
+ public WebSession getSession()
+ {
+ return _request.getSession(false);
+ }
+
+ public String getAttributeName()
+ {
+ return _attributeName;
+ }
+
+ public void setAttributeName(String attributeName)
+ {
+ _attributeName = attributeName;
+ }
+
+ public Object getAttributeValue()
+ {
+ return getSession().getAttribute(_attributeName);
}
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/DefaultMarkupModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/DefaultMarkupModel.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/DefaultMarkupModel.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/DefaultMarkupModel.java Thu Nov 16 15:38:22 2006
@@ -14,13 +14,30 @@
package org.apache.tapestry.dom;
+import static org.apache.tapestry.util.CollectionFactory.newSet;
+
+import java.util.Set;
+
/**
- * Default implementation of {@link org.apache.tapestry.dom.MarkupModel}.
- *
- *
+ * Default implementation of {@link org.apache.tapestry.dom.MarkupModel} that is appropriate for
+ * traditional HTML markup. This conforms to the SGML HTML definition, including some things that
+ * are not well formed XML-style markup. Assumes that all tags are lowercase.
*/
public class DefaultMarkupModel implements MarkupModel
{
+ private final Set<String> EMPTY_ELEMENTS = newSet(
+ "base",
+ "br",
+ "col",
+ "frame",
+ "hr",
+ "img",
+ "input",
+ "link",
+ "meta",
+ "option",
+ "param");
+
/** Passes all characters but '<', '>' and '&' through unchanged. */
public void encode(String content, StringBuilder buffer)
{
@@ -46,6 +63,13 @@
buffer.append(ch);
}
}
+ }
+
+ public EndTagStyle getEndTagStyle(String element)
+ {
+ boolean isEmpty = EMPTY_ELEMENTS.contains(element);
+
+ return isEmpty ? EndTagStyle.OMIT : EndTagStyle.REQUIRE;
}
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Document.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Document.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Document.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Document.java Thu Nov 16 15:38:22 2006
@@ -18,8 +18,6 @@
/**
* The root node of a DOM.
- *
- *
*/
public final class Document extends Node
{
@@ -33,8 +31,7 @@
_model = model;
}
- @Override
- public Document getDocument()
+ Document getDocument()
{
return this;
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java Thu Nov 16 15:38:22 2006
@@ -30,16 +30,19 @@
*/
public final class Element extends Node
{
- private String _name;
+ private final String _name;
private Map<String, String> _attributes;
private Element _parent;
+ private final Document _document;
+
Element(Document container, String name)
{
super(container);
+ _document = container;
_name = name;
}
@@ -49,6 +52,13 @@
_parent = parent;
_name = name;
+
+ _document = parent.getDocument();
+ }
+
+ public Document getDocument()
+ {
+ return _document;
}
/**
@@ -127,7 +137,7 @@
public Text text(String text)
{
- return newChild(new Text(this, text));
+ return newChild(new Text(this, _document, text));
}
private <T extends Node> T newChild(T child)
@@ -157,15 +167,24 @@
}
}
- if (hasChildren())
- {
- writer.print(">");
+ EndTagStyle style = _document.getMarkupModel().getEndTagStyle(_name);
+
+ boolean hasChildren = hasChildren();
+
+ String close = (!hasChildren && style == EndTagStyle.ABBREVIATE) ? "/>" : ">";
+
+ writer.print(close);
+
+ if (hasChildren)
writeChildXML(writer);
+
+ // Dangerous -- perhaps it should be an error for a tag of type OMIT to even have children!
+ // We'll certainly be writing out unbalanced markup in that case.
+
+ if (style == EndTagStyle.OMIT)
+ return;
+
+ if (hasChildren || style == EndTagStyle.REQUIRE)
writer.printf("</%s>", _name);
- }
- else
- {
- writer.print("/>");
- }
}
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/EndTagStyle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/EndTagStyle.java?view=auto&rev=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/EndTagStyle.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/EndTagStyle.java Thu Nov 16 15:38:22 2006
@@ -0,0 +1,11 @@
+package org.apache.tapestry.dom;
+
+public enum EndTagStyle {
+
+ /** Omit the end tag. Examples for HTML include the input, br and img elements. */
+ OMIT,
+ /** Require an end tag always. This is the default for most elements in HTML. */
+ REQUIRE,
+ /** Require an end tag, but abbreviate it if the element has no children. This is the only value used in XML documents. */
+ ABBREVIATE
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/MarkupModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/MarkupModel.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/MarkupModel.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/MarkupModel.java Thu Nov 16 15:38:22 2006
@@ -17,8 +17,6 @@
/**
* Used by a the DOM to determine how to produce markup. Delegates details about converted entities
* and some formatting details.
- *
- *
*/
public interface MarkupModel
{
@@ -32,4 +30,9 @@
* to recieve the filtered content
*/
void encode(String content, StringBuilder buffer);
+
+ /**
+ * For a given element, determines how the end tag for the element should be rendered.
+ */
+ EndTagStyle getEndTagStyle(String element);
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java Thu Nov 16 15:38:22 2006
@@ -44,7 +44,7 @@
{
return _container;
}
-
+
protected void addChild(Node child)
{
if (_children == null)
@@ -65,11 +65,6 @@
for (Node child : _children)
child.toXML(writer);
- }
-
- public Document getDocument()
- {
- return _container.getDocument();
}
/**
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Text.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Text.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Text.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Text.java Thu Nov 16 15:38:22 2006
@@ -18,22 +18,20 @@
/**
* A type of node that contains text.
- *
- *
*/
public final class Text extends Node
{
private final StringBuilder _buffer;
- private MarkupModel _model;
+ private final Document _document;
- Text(Node container, String text)
+ Text(Node container, Document document, String text)
{
super(container);
- _buffer = new StringBuilder();
+ _document = document;
- _model = getDocument().getMarkupModel();
+ _buffer = new StringBuilder();
write(text);
}
@@ -41,7 +39,7 @@
/** Writes additional text into the node, appending it to any existing text. */
public void write(String text)
{
- _model.encode(text, _buffer);
+ _document.getMarkupModel().encode(text, _buffer);
}
public void writef(String format, Object... args)
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java Thu Nov 16 15:38:22 2006
@@ -17,8 +17,10 @@
import java.io.PrintWriter;
import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.dom.DefaultMarkupModel;
import org.apache.tapestry.dom.Document;
import org.apache.tapestry.dom.Element;
+import org.apache.tapestry.dom.MarkupModel;
import org.apache.tapestry.dom.Text;
/**
@@ -26,12 +28,22 @@
*/
public class MarkupWriterImpl implements MarkupWriter
{
- private final Document _document = new Document();
+ private final Document _document;
private Element _current;
private Text _currentText;
+ public MarkupWriterImpl()
+ {
+ this(new DefaultMarkupModel());
+ }
+
+ public MarkupWriterImpl(MarkupModel model)
+ {
+ _document = new Document(model);
+ }
+
public void toXML(PrintWriter writer)
{
_document.toXML(writer);
@@ -46,6 +58,9 @@
public void write(String text)
{
ensureCurrentElement();
+
+ if (text == null)
+ return;
if (_currentText == null)
{
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java Thu Nov 16 15:38:22 2006
@@ -15,6 +15,7 @@
package org.apache.tapestry.util;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -63,6 +64,11 @@
public static <T> Set<T> newSet(Collection<? extends T> values)
{
return new HashSet<T>(values);
+ }
+
+ public static <T> Set<T> newSet(T... values)
+ {
+ return newSet(Arrays.asList(values));
}
/**
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html Thu Nov 16 15:38:22 2006
@@ -32,5 +32,17 @@
</li>
</t:comp>
</ul>
+
+ <div class="tapestry-env-data">
+ <t:comp type="If" test="prop:hasSession">
+ <h2>Session</h2>
+ <dl>
+ <t:comp type="Loop" source="prop:session.attributeNames" value="prop:attributeName">
+ <dt>${attributeName}</dt>
+ <dd>${attributeValue}</dd>
+ </t:comp>
+ </dl>
+ </t:comp>
+ </div>
</body>
</html>
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java Thu Nov 16 15:38:22 2006
@@ -65,6 +65,16 @@
d.newRootElement("empty");
+ assertEquals(d.toString(), "<empty></empty>");
+ }
+
+ @Test
+ public void xml_style_empty_element()
+ {
+ Document d = new Document(new XMLMarkupModel());
+
+ d.newRootElement("empty");
+
assertEquals(d.toString(), "<empty/>");
}
@@ -139,7 +149,7 @@
e.attribute("foo", "bar");
- final String expected = "<root foo=\"bar\"/>";
+ final String expected = "<root foo=\"bar\"></root>";
assertEquals(d.toString(), expected);
@@ -199,7 +209,7 @@
e.element("foo", "alpha", "legion");
- assertEquals(d.toString(), "<root><foo alpha=\"legion\"/></root>");
+ assertEquals(d.toString(), "<root><foo alpha=\"legion\"></foo></root>");
}
@Test
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/XMLMarkupModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/XMLMarkupModel.java?view=auto&rev=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/XMLMarkupModel.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/XMLMarkupModel.java Thu Nov 16 15:38:22 2006
@@ -0,0 +1,13 @@
+package org.apache.tapestry.dom;
+
+/** Used for some testing where we want a model with XML style semantics. */
+public final class XMLMarkupModel extends DefaultMarkupModel
+{
+
+ /** Always returns ABBREVIATE. */
+ @Override
+ public EndTagStyle getEndTagStyle(String element)
+ {
+ return EndTagStyle.ABBREVIATE;
+ }
+}
\ No newline at end of file
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Nov 16 15:38:22 2006
@@ -251,10 +251,14 @@
clickAndWait("link=SimpleForm");
_selenium.type("email", "foo@gmail.com");
+ _selenium.type("message", "Message for you, sir!");
clickAndWait("//input[@type='submit']");
- assertTextPresent("You entered: foo@gmail.com");
+ // Tried to use "email:" and "exact:email:" but Selenium 0.8.1 doesn't seem to accept that.
+
+ assertTextPresent("[foo@gmail.com]");
+ assertTextPresent("[Message for you, sir!]");
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java?view=auto&rev=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java Thu Nov 16 15:38:22 2006
@@ -0,0 +1,33 @@
+package org.apache.tapestry.integration.app1.data;
+
+import java.io.Serializable;
+
+public class IncidentData implements Serializable
+{
+ private static final long serialVersionUID = 7512595251925899186L;
+
+ private String _email;
+
+ private String _message;
+
+ public String getEmail()
+ {
+ return _email;
+ }
+
+ public void setEmail(String email)
+ {
+ _email = email;
+ }
+
+ public String getMessage()
+ {
+ return _message;
+ }
+
+ public void setMessage(String message)
+ {
+ _message = message;
+ }
+
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/SimpleForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/SimpleForm.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/SimpleForm.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/SimpleForm.java Thu Nov 16 15:38:22 2006
@@ -15,22 +15,25 @@
package org.apache.tapestry.integration.app1.pages;
import org.apache.tapestry.annotations.ComponentClass;
+import org.apache.tapestry.annotations.OnEvent;
import org.apache.tapestry.annotations.Persist;
+import org.apache.tapestry.integration.app1.data.IncidentData;
@ComponentClass
public class SimpleForm
{
@Persist
- private String _email;
+ private IncidentData _incident;
- public String getEmail()
+ public IncidentData getIncident()
{
- return _email;
+ return _incident;
}
- public void setEmail(String email)
+ @OnEvent("prepare")
+ void prepare()
{
- _email = email;
+ if (_incident == null)
+ _incident = new IncidentData();
}
-
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java Thu Nov 16 15:38:22 2006
@@ -19,9 +19,7 @@
import org.testng.Assert;
import org.testng.annotations.Test;
-/**
- *
- */
+
public class MarkupWriterImplTest extends Assert
{
@Test(expectedExceptions = IllegalStateException.class)
@@ -100,7 +98,9 @@
w.element("img", "src", "foo.png", "width", 20, "height", 20);
w.end();
- assertEquals(w.toString(), "<img height=\"20\" src=\"foo.png\" width=\"20\"/>");
+ // img is a tag with an end tag style of omit, so no close tag is written.
+
+ assertEquals(w.toString(), "<img height=\"20\" src=\"foo.png\" width=\"20\">");
}
@Test
@@ -112,7 +112,7 @@
w.attributes("foo", "bar", "gnip", "gnop");
- assertEquals(w.toString(), "<root foo=\"bar\" gnip=\"gnop\"/>");
+ assertEquals(w.toString(), "<root foo=\"bar\" gnip=\"gnop\"></root>");
}
@Test
@@ -139,6 +139,18 @@
w.end();
assertEquals(w.toString(), "<root>before<!-- A comment -->after</root>");
+ }
+
+ @Test
+ public void null_write_is_ok()
+ {
+ MarkupWriter w = new MarkupWriterImpl();
+
+ w.element("root");
+ w.write(null);
+ w.end();
+
+ assertEquals(w.toString(), "<root></root>");
}
@Test
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java Thu Nov 16 15:38:22 2006
@@ -16,6 +16,8 @@
import org.apache.tapestry.Location;
import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.dom.MarkupModel;
+import org.apache.tapestry.dom.XMLMarkupModel;
import org.apache.tapestry.internal.parser.AttributeToken;
import org.apache.tapestry.internal.parser.StartElementToken;
import org.apache.tapestry.internal.parser.TextToken;
@@ -31,6 +33,8 @@
*/
public class PageElementFactoryImplTest extends InternalBaseTestCase
{
+ private static MarkupModel _xmlModel = new XMLMarkupModel();
+
@Test
public void start_element()
{
@@ -52,7 +56,7 @@
verify();
assertEquals(element.toString(), "Start[fred]");
- assertEquals(writer.toString(), "<fred/>");
+ assertEquals(writer.toString(), "<fred></fred>");
}
@Test
@@ -60,7 +64,7 @@
{
ComponentInstantiatorSource source = newComponentInstantiatorSource();
ComponentClassResolver resolver = newComponentClassResolver();
- MarkupWriter writer = new MarkupWriterImpl();
+ MarkupWriter writer = new MarkupWriterImpl(_xmlModel);
Location l = newLocation();
RenderQueue queue = newRenderQueue();
@@ -86,7 +90,7 @@
{
ComponentInstantiatorSource source = newComponentInstantiatorSource();
ComponentClassResolver resolver = newComponentClassResolver();
- MarkupWriter writer = new MarkupWriterImpl();
+ MarkupWriter writer = new MarkupWriterImpl(_xmlModel);
RenderQueue queue = newRenderQueue();
replay();
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java Thu Nov 16 15:38:22 2006
@@ -84,6 +84,16 @@
}
@Test
+ public void set_from_varargs()
+ {
+ Set<String> set = newSet("fred", "barney");
+
+ assertEquals(set.size(), 2);
+ assertTrue(set.contains("fred"));
+ assertTrue(set.contains("barney"));
+ }
+
+ @Test
public void new_list()
{
List<String> list = newList();
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/document_with_root_element_and_attributes.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/document_with_root_element_and_attributes.txt?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/document_with_root_element_and_attributes.txt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/document_with_root_element_and_attributes.txt Thu Nov 16 15:38:22 2006
@@ -1 +1 @@
-<has-attributes barney="rubble" fred="flintstone"/>
\ No newline at end of file
+<has-attributes barney="rubble" fred="flintstone"></has-attributes>
\ No newline at end of file
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/nested_elements.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/nested_elements.txt?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/nested_elements.txt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/dom/nested_elements.txt Thu Nov 16 15:38:22 2006
@@ -1,4 +1,4 @@
<population>
- <person first-name="Fred" last-name="Flintstone"/>
- <person first-name="Barney" last-name="Rubble"/>
+ <person first-name="Fred" last-name="Flintstone"></person>
+ <person first-name="Barney" last-name="Rubble"></person>
</population>
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html?view=diff&rev=475985&r1=475984&r2=475985
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.html Thu Nov 16 15:38:22 2006
@@ -5,16 +5,30 @@
<t:comp type="Form">
- <t:comp type="TextField" id="email" value="prop:email" size="50"/>
+ Email: <t:comp type="TextField" id="email" value="prop:incident.email" size="50"/>
+
+<br/>
+
+Message: <t:comp type="TextArea" id="message" value="prop:incident.message" cols="50" rows="10"/>
<br/>
<input type="submit"/>
- </t:comp>
-
- <t:comp type="If" test="prop:email">
- <p> You entered: ${email} </p>
- </t:comp>
+ </t:comp>
+
+
+ <hr/>
+
+ <p>
+ Entered data:
+ </p>
+
+ <ul>
+ <li>email: [${incident.email}]</li>
+ <li>message: [${incident.message}]</li>
+ </ul>
+
+
</t:comp>