Author: jkuhnert
Date: Thu Dec 7 21:43:16 2006
New Revision: 483838
URL: http://svn.apache.org/viewvc?view=rev&rev=483838
Log:
Fixed a bunch of low hanging fruit.
Even mucked around with the template parser! (i only changed one boolean from
false to true ;) )
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestLocalizedStringRender.java
Modified:
tapestry/tapestry4/trunk/pom.xml
tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/inspector/ShowTemplate.java
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
tapestry/tapestry4/trunk/tapestry-examples/Vlib/pom.xml
tapestry/tapestry4/trunk/tapestry-examples/VlibBeans/pom.xml
tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartPage.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/encoders/AssetEncoder.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.js
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.jwc
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/validator/Email.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/LocalizationToken.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateParser.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateToken.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateTokenFactory.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TextToken.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/LocalizedStringRender.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestStrings.xml
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/encoders/AssetEncoderTest.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestEmail.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.html
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.properties
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/BasicLocalization.html
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/TestTemplateParser.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
tapestry/tapestry4/trunk/tapestry-portlet/pom.xml
Modified: tapestry/tapestry4/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/pom.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/pom.xml (original)
+++ tapestry/tapestry4/trunk/pom.xml Thu Dec 7 21:43:16 2006
@@ -170,6 +170,7 @@
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
Modified:
tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/inspector/ShowTemplate.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/inspector/ShowTemplate.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/inspector/ShowTemplate.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/inspector/ShowTemplate.java
Thu Dec 7 21:43:16 2006
@@ -76,8 +76,8 @@
/**
* Writes the HTML template for the component. When <jwc> tags are
written, the id is made
* a link (that selects the named component). We use some magic to
accomplish this, creating
- * links as if we were a [EMAIL PROTECTED] DirectLink}component, and
attributing those links to the
- * captive [EMAIL PROTECTED] DirectLink}component embedded here.
+ * links as if we were a [EMAIL PROTECTED] DirectLink} component, and
attributing those links to the
+ * captive [EMAIL PROTECTED] DirectLink} component embedded here.
*/
private void writeTemplate(IMarkupWriter writer, IRequestCycle cycle)
Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml Thu Dec 7
21:43:16 2006
@@ -61,6 +61,12 @@
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.0</version>
Modified: tapestry/tapestry4/trunk/tapestry-examples/Vlib/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Vlib/pom.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Vlib/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Vlib/pom.xml Thu Dec 7 21:43:16
2006
@@ -48,6 +48,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
</dependency>
Modified: tapestry/tapestry4/trunk/tapestry-examples/VlibBeans/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/VlibBeans/pom.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/VlibBeans/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/VlibBeans/pom.xml Thu Dec 7
21:43:16 2006
@@ -29,6 +29,12 @@
<artifactId>tapestry-contrib</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>jboss</groupId>
<artifactId>jboss-j2ee</artifactId>
<version>4.0.2</version>
Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml Thu Dec 7
21:43:16 2006
@@ -1,22 +1,21 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-Workbench</artifactId>
<packaging>war</packaging>
<version>4.1.1-SNAPSHOT</version>
-
+
<!-- This should change to tapestry-project -->
<parent>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-examples</artifactId>
<version>4.1.1-SNAPSHOT</version>
</parent>
-
+
<name>Tapestry Workbench</name>
<inceptionYear>2006</inceptionYear>
-
+
<dependencies>
<dependency>
<groupId>jcharts</groupId>
@@ -33,15 +32,25 @@
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-framework</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
-
+
<build>
<sourceDirectory>src/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
-
+
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
@@ -81,7 +90,7 @@
</plugin>
</plugins>
</build>
-
+
<reporting>
<plugins>
<plugin>
Modified:
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartPage.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartPage.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartPage.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartPage.java
Thu Dec 7 21:43:16 2006
@@ -14,7 +14,6 @@
package org.apache.tapestry.workbench.chart;
-import java.awt.Color;
import java.awt.Paint;
import java.util.ArrayList;
import java.util.List;
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/encoders/AssetEncoder.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/encoders/AssetEncoder.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/encoders/AssetEncoder.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/encoders/AssetEncoder.java
Thu Dec 7 21:43:16 2006
@@ -31,21 +31,29 @@
{
public static final String DIGEST_STATIC = "static";
+ private static final String PATH_SEPARATOR = "/";
+
private String _path;
-
+
public void setPath(String path)
{
_path = path;
}
-
+
public void encode(ServiceEncoding encoding)
{
if
(!encoding.getParameterValue(ServiceConstants.SERVICE).equals(Tapestry.ASSET_SERVICE))
return;
-
+
String path = encoding.getParameterValue(AssetService.PATH);
String digest = encoding.getParameterValue(AssetService.DIGEST);
-
+
+ // fix broken path if doesn't start with /
+
+ if (!path.startsWith(PATH_SEPARATOR))
+ path = PATH_SEPARATOR + path;
+
+
// _path ends with a slash, path starts with one.
String fullPath = _path + ((digest != null) ? "/" + digest : "/" +
DIGEST_STATIC) + path;
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java
Thu Dec 7 21:43:16 2006
@@ -46,7 +46,7 @@
private Map _primitiveParser = new HashMap();
{
- _primitiveParser.put(boolean.class, "java.lang.Boolean.parseBoolean");
+ _primitiveParser.put(boolean.class, "java.lang.Boolean.getBoolean");
_primitiveParser.put(short.class, "java.lang.Short.parseShort");
_primitiveParser.put(int.class, "java.lang.Integer.parseInt");
_primitiveParser.put(long.class, "java.lang.Long.parseLong");
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.js
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.js?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
Binary files - no diff available.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.java
Thu Dec 7 21:43:16 2006
@@ -33,7 +33,6 @@
*/
public abstract class RadioGroup extends AbstractFormComponent implements
ValidatableField
{
-
/**
* A <code>RadioGroup</code> places itself into the [EMAIL PROTECTED]
IRequestCycle}as an attribute, so
* that its wrapped [EMAIL PROTECTED] Radio}components can identify thier
state.
@@ -123,9 +122,9 @@
if (cycle.getAttribute(ATTRIBUTE_NAME) != null)
throw new
ApplicationRuntimeException(Tapestry.getMessage("RadioGroup.may-not-nest"),
this, null, null);
-
+
cycle.setAttribute(ATTRIBUTE_NAME, this);
-
+
_rendering = true;
_nextOptionId = 0;
}
@@ -148,16 +147,28 @@
protected void renderFormComponent(IMarkupWriter writer, IRequestCycle
cycle)
{
_rewinding = false;
-
+
// For rendering, the Radio components need to know what the current
// selection is, so that the correct one can mark itself 'checked'.
_selection = getBinding("selected").getObject();
-
+
+ renderDelegatePrefix(writer, cycle);
+
+ writer.begin(getTemplateTagName());
+
+ renderInformalParameters(writer, cycle);
+
+ renderDelegateAttributes(writer, cycle);
+
renderBody(writer, cycle);
-
+
+ writer.closeTag();
+
+ renderDelegateSuffix(writer, cycle);
+
getValidatableFieldSupport().renderContributions(this, writer, cycle);
}
-
+
/**
* @see
org.apache.tapestry.form.AbstractFormComponent#rewindFormComponent(org.apache.tapestry.IMarkupWriter,
* org.apache.tapestry.IRequestCycle)
@@ -172,9 +183,9 @@
_selectedOption = Integer.parseInt(value);
_rewinding = true;
-
+
renderBody(writer, cycle);
-
+
try
{
getValidatableFieldSupport().validate(this, writer, cycle,
_selection);
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.jwc
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.jwc?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.jwc
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/RadioGroup.jwc
Thu Dec 7 21:43:16 2006
@@ -19,7 +19,7 @@
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
-<component-specification class="org.apache.tapestry.form.RadioGroup"
allow-informal-parameters="no">
+<component-specification class="org.apache.tapestry.form.RadioGroup"
allow-informal-parameters="yes">
<description>
Groups together a number of Radio components.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/validator/Email.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/validator/Email.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/validator/Email.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/validator/Email.java
Thu Dec 7 21:43:16 2006
@@ -36,11 +36,12 @@
*/
public class Email extends BaseValidator
{
- static final String PATTERN = "[EMAIL PROTECTED],6}$";
+ static final String PATTERN = "^[A-Za-z0-9]+([-_\\.]*[A-Za-z0-9]+)[EMAIL
PROTECTED]([-_\\.]*[A-Za-z0-9]+)*(\\.[_A-Za-z]{2,6})$";
// TODO: Possible thread safety issue if the validator
// is shared across threads, because the matcher
// will be too.
+
private RegexpMatcher _matcher = new RegexpMatcher();
public Email()
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/LocalizationToken.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/LocalizationToken.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/LocalizationToken.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/LocalizationToken.java
Thu Dec 7 21:43:16 2006
@@ -17,6 +17,7 @@
import java.util.Map;
import org.apache.hivemind.Location;
+import org.apache.hivemind.util.ToStringBuilder;
/**
* Represents localized text from the template.
@@ -82,5 +83,12 @@
public String getKey()
{
return _key;
+ }
+
+ protected void extendDescription(ToStringBuilder builder)
+ {
+ builder.append("tag", _tag);
+ builder.append("key", _key);
+ builder.append("raw", _raw);
}
}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateParser.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateParser.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateParser.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateParser.java
Thu Dec 7 21:43:16 2006
@@ -348,7 +348,7 @@
* a description of where the template originated from, used
with error messages.
*/
- public TemplateToken[] parse(char[] templateData, ITemplateParserDelegate
delegate,
+ public TemplateToken[] parse(char[] templateData, ITemplateParserDelegate
delegate,
Resource resourceLocation) throws TemplateParseException
{
try
@@ -369,8 +369,7 @@
* perform default initialization of the parser.
*/
- protected void beforeParse(char[] templateData, ITemplateParserDelegate
delegate,
- Resource resourceLocation)
+ protected void beforeParse(char[] templateData, ITemplateParserDelegate
delegate, Resource resourceLocation)
{
_templateData = templateData;
_resourceLocation = resourceLocation;
@@ -804,11 +803,11 @@
tagEndEvent(_cursor);
// Check for invisible localizations
-
+
String localizationKey =
findValueCaselessly(LOCALIZATION_KEY_ATTRIBUTE_NAME, _attributes);
String jwcId = findValueCaselessly(_componentAttributeName,
_attributes);
-
- if (localizationKey != null && tagName.equalsIgnoreCase("span") &&
jwcId == null)
+
+ if (localizationKey != null && jwcId == null)
{
if (_ignoring)
templateParseProblem(
@@ -816,53 +815,52 @@
startLocation,
startLine,
cursorStart);
-
+
// If the tag isn't empty, then create a Tag instance to ignore the
// body of the tag.
-
+
if (!emptyTag)
{
Tag tag = new Tag(tagName, startLine);
-
+
tag._component = false;
- tag._removeTag = true;
+ tag._removeTag = false;
tag._ignoringBody = true;
tag._mustBalance = true;
-
+
_stack.add(tag);
-
+
// Start ignoring content until the close tag.
-
+
_ignoring = true;
}
else
{
// Cursor is at the closing carat, advance over it.
advance();
- // TAPESTRY-359: *don't* skip whitespace
+ // TAPESTRY-359: *don't* skip whitespace
advanceOverWhitespace()
}
-
+
// End any open block.
-
+
addTextToken(cursorStart - 1);
-
+
boolean raw = checkBoolean(RAW_ATTRIBUTE_NAME, _attributes);
-
- Map attributes = filter(_attributes, new String[]
- { LOCALIZATION_KEY_ATTRIBUTE_NAME, RAW_ATTRIBUTE_NAME });
-
+
+ Map attributes = filter(_attributes, new String[] {
LOCALIZATION_KEY_ATTRIBUTE_NAME, RAW_ATTRIBUTE_NAME });
+
TemplateToken token = _factory.createLocalizationToken(
tagName,
localizationKey,
raw,
attributes,
startLocation);
-
+
_tokens.add(token);
-
+
return;
}
-
+
if (jwcId != null)
{
processComponentStart(tagName, jwcId, emptyTag, startLine,
cursorStart, startLocation);
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateToken.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateToken.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateToken.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateToken.java
Thu Dec 7 21:43:16 2006
@@ -54,7 +54,7 @@
builder.append("type", _type.getName());
builder.append("location", _location);
-
+
extendDescription(builder);
return builder.toString();
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateTokenFactory.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateTokenFactory.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateTokenFactory.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TemplateTokenFactory.java
Thu Dec 7 21:43:16 2006
@@ -21,9 +21,10 @@
/**
* A Factory used by [EMAIL PROTECTED]
org.apache.tapestry.parse.TemplateParser} to create
* [EMAIL PROTECTED] org.apache.tapestry.parse.TemplateToken} objects.
+ *
* <p>
* This class is extended by Spindle - the Eclipse Plugin for Tapestry.
- * <p>
+ * </p>
*
* @author [EMAIL PROTECTED]
* @since 3.0
@@ -42,17 +43,14 @@
return new CloseToken(tagName, location);
}
- public TextToken createTextToken(char[] templateData, int blockStart,
- int end, Location templateLocation)
+ public TextToken createTextToken(char[] templateData, int blockStart, int
end, Location templateLocation)
{
return new TextToken(templateData, blockStart, end, templateLocation);
}
- public LocalizationToken createLocalizationToken(String tagName,
- String localizationKey, boolean raw, Map attributes,
- Location startLocation)
+ public LocalizationToken createLocalizationToken(String tagName, String
localizationKey,
+ boolean raw, Map attributes, Location startLocation)
{
- return new LocalizationToken(tagName, localizationKey, raw, attributes,
- startLocation);
+ return new LocalizationToken(tagName, localizationKey, raw,
attributes, startLocation);
}
}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TextToken.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TextToken.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TextToken.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/TextToken.java
Thu Dec 7 21:43:16 2006
@@ -72,6 +72,7 @@
{
builder.append("offset", _offset);
builder.append("length", _length);
+ builder.append("templateData", getTemplateDataAsString());
}
public String getTemplateDataAsString()
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/LocalizedStringRender.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/LocalizedStringRender.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/LocalizedStringRender.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/LocalizedStringRender.java
Thu Dec 7 21:43:16 2006
@@ -43,12 +43,15 @@
private String _value;
private boolean _raw;
+
+ private String _tag;
public LocalizedStringRender(IComponent component, LocalizationToken token)
{
_component = component;
_key = token.getKey();
_raw = token.isRaw();
+ _tag = token.getTag();
_attributes = token.getAttributes();
}
@@ -59,8 +62,8 @@
if (_attributes != null)
{
- writer.begin("span");
-
+ writer.begin(_tag == null ? "span" : _tag);
+
Iterator i = _attributes.entrySet().iterator();
while (i.hasNext())
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
Thu Dec 7 21:43:16 2006
@@ -75,7 +75,8 @@
String id = field == null ? null : field.getClientId();
- delegate.writeLabelPrefix(field, writer, cycle);
+ if (field != null)
+ delegate.writeLabelPrefix(field, writer, cycle);
writer.begin("label");
@@ -93,7 +94,8 @@
writer.end();
- delegate.writeLabelSuffix(field, writer, cycle);
+ if (field != null)
+ delegate.writeLabelSuffix(field, writer, cycle);
}
/** displayName parameter. */
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestStrings.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestStrings.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestStrings.xml
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestStrings.xml Thu
Dec 7 21:43:16 2006
@@ -48,6 +48,12 @@
]]>
</assert-output>
+ <assert-output name="Whitespace">
+<![CDATA[
+Whitespace: Hello World
+]]>
+ </assert-output>
+
</request>
</mock-test>
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/encoders/AssetEncoderTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/encoders/AssetEncoderTest.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/encoders/AssetEncoderTest.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/encoders/AssetEncoderTest.java
Thu Dec 7 21:43:16 2006
@@ -33,7 +33,7 @@
@Test
public class AssetEncoderTest extends TestBase
{
- public void testWrongService()
+ public void test_Wrong_Service()
{
ServiceEncoding encoding = newEncoding();
@@ -56,7 +56,7 @@
return newMock(ServiceEncoding.class);
}
- public void testWrongPath()
+ public void test_Wrong_Path()
{
ServiceEncoding encoding = newEncoding();
@@ -77,14 +77,14 @@
expect(encoding.getServletPath()).andReturn(servletPath);
}
- public void testEncode()
+ public void test_Encode()
{
ServiceEncoding encoding = newEncoding();
-
+
trainGetParameterValue(encoding, ServiceConstants.SERVICE,
Tapestry.ASSET_SERVICE);
trainGetParameterValue(encoding, AssetService.PATH,
"/foo/bar/Baz.gif");
trainGetParameterValue(encoding, AssetService.DIGEST, "12345");
-
+
encoding.setServletPath("/assets/12345/foo/bar/Baz.gif");
encoding.setParameterValue(AssetService.PATH, null);
encoding.setParameterValue(AssetService.DIGEST, null);
@@ -100,7 +100,30 @@
verify();
}
- public void testDecode()
+ public void test_Encode_Missing_Path()
+ {
+ ServiceEncoding encoding = newEncoding();
+
+ trainGetParameterValue(encoding, ServiceConstants.SERVICE,
Tapestry.ASSET_SERVICE);
+ trainGetParameterValue(encoding, AssetService.PATH, "foo/bar/Baz.gif");
+ trainGetParameterValue(encoding, AssetService.DIGEST, "12345");
+
+ encoding.setServletPath("/assets/12345/foo/bar/Baz.gif");
+ encoding.setParameterValue(AssetService.PATH, null);
+ encoding.setParameterValue(AssetService.DIGEST, null);
+ encoding.setParameterValue(ServiceConstants.SERVICE, null);
+
+ replay();
+
+ AssetEncoder encoder = new AssetEncoder();
+ encoder.setPath("/assets");
+
+ encoder.encode(encoding);
+
+ verify();
+ }
+
+ public void test_Decode()
{
ServiceEncoding encoding = newEncoding();
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestEmail.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestEmail.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestEmail.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/validator/TestEmail.java
Thu Dec 7 21:43:16 2006
@@ -48,6 +48,20 @@
verify();
}
+ public void test_Ok_Single_Character() throws Exception
+ {
+ IFormComponent field = newField();
+ ValidationMessages messages = newMessages();
+
+ replay();
+
+ Email email = new Email();
+ email.validate(field, messages, "[EMAIL PROTECTED]");
+ email.validate(field, messages, "[EMAIL PROTECTED]");
+
+ verify();
+ }
+
public void test_Fail()
{
IFormComponent field = newField("My Email");
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.html
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.html?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.html
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.html
Thu Dec 7 21:43:16 2006
@@ -7,10 +7,17 @@
<p>
Raw: <span key="message" raw="true"/>
+</p>
<p>
Style: <span key="message" raw="true" class="custom"/>
+</p>
+
+<p>
+
+Whitespace: <span key="hello-key">Hello</span> <span
key="world-key">World</span>
+</p>
</span>
</span>
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.properties
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.properties?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.properties
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/Strings.properties
Thu Dec 7 21:43:16 2006
@@ -13,3 +13,5 @@
# limitations under the License.
message=<b>Important Message</b>
+hello-key=Hello
+world-key=World
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/BasicLocalization.html
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/BasicLocalization.html?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
Binary files - no diff available.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/TestTemplateParser.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/TestTemplateParser.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/TestTemplateParser.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/parse/TestTemplateParser.java
Thu Dec 7 21:43:16 2006
@@ -154,6 +154,12 @@
assertEquals(expectedLength, t.getLength());
}
+ protected void assertText(TextToken token, int offset, int length)
+ {
+ assertEquals(token.getOffset(), offset);
+ assertEquals(token.getLength(), length);
+ }
+
/** @since 3.0 * */
protected void checkLine(TemplateToken token, int line)
@@ -185,10 +191,10 @@
{
OpenToken t = (OpenToken) token;
- assertEquals(TokenType.OPEN, t.getType());
- assertEquals(id, t.getId());
- assertEquals(componentType, t.getComponentType());
- assertEquals(tag, t.getTag());
+ assertEquals(t.getType(), TokenType.OPEN);
+ assertEquals(t.getId(), id);
+ assertEquals(t.getComponentType(), componentType);
+ assertEquals(t.getTag(), tag);
checkLine(token, line);
}
@@ -197,12 +203,12 @@
{
OpenToken t = (OpenToken) token;
- assertEquals(expected, t.getAttributesMap());
+ assertEquals(t.getAttributesMap(), expected);
}
protected void assertCloseToken(TemplateToken token, int line)
{
- assertEquals(TokenType.CLOSE, token.getType());
+ assertEquals(token.getType(), TokenType.CLOSE);
checkLine(token, line);
}
@@ -210,7 +216,7 @@
protected void assertTokenCount(TemplateToken[] tokens, int count)
{
assertNotNull(tokens);
- assertEquals(count, tokens.length);
+ assertEquals(tokens.length, count);
}
private void runFailure(String file, String message)
@@ -236,7 +242,7 @@
public void testAllStatic() throws TemplateParseException
{
TemplateToken[] tokens = run("AllStatic.html");
-
+
assertTokenCount(tokens, 1);
assertTextToken(tokens[0], 0, 172);
}
@@ -471,14 +477,18 @@
* @since 2.0.4
*/
- public void testBasicLocalization() throws TemplateParseException
+ public void test_Basic_Localization() throws TemplateParseException
{
TemplateToken[] tokens = run("BasicLocalization.html");
-
- assertTokenCount(tokens, 3);
+
+ assertTokenCount(tokens, 7);
assertTextToken(tokens[0], 0, 35);
assertLocalizationToken(tokens[1], "the.localization.key", null, 3);
- assertTextToken(tokens[2], 89, 117);
+ assertText((TextToken)tokens[2], 87, 44);
+ assertLocalizationToken(tokens[3], "hello-key", null, 7);
+ assertText((TextToken)tokens[4], 165, 1);
+ assertLocalizationToken(tokens[5], "world-key", null, 7);
+ assertText((TextToken)tokens[6], 200, 1);
}
/**
@@ -514,7 +524,7 @@
* @since 2.0.4
*/
- public void testEmptyLocalization() throws TemplateParseException
+ public void test_Empty_Localization() throws TemplateParseException
{
TemplateToken[] tokens = run("EmptyLocalization.html");
@@ -535,9 +545,8 @@
{
TemplateToken[] tokens = run("LocalizationAttributes.html");
- Map attributes = buildMap(new String[]
- { "alpha", "beta", "Fred", "Wilma" });
-
+ Map attributes = buildMap(new String[] { "alpha", "beta", "Fred",
"Wilma" });
+
assertLocalizationToken(tokens[1], "localization.with.attributes",
attributes, 3);
}
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestLocalizedStringRender.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestLocalizedStringRender.java?view=auto&rev=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestLocalizedStringRender.java
(added)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestLocalizedStringRender.java
Thu Dec 7 21:43:16 2006
@@ -0,0 +1,126 @@
+// Copyright 2004, 2005 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry.services.impl;
+
+import static org.easymock.EasyMock.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hivemind.Location;
+import org.apache.hivemind.Messages;
+import org.apache.tapestry.BaseComponentTestCase;
+import org.apache.tapestry.IComponent;
+import org.apache.tapestry.IMarkupWriter;
+import org.apache.tapestry.IRequestCycle;
+import org.apache.tapestry.parse.LocalizationToken;
+import org.testng.annotations.Test;
+
+
+/**
+ * Tests functionality of [EMAIL PROTECTED] LocalizedStringRender} .
+ *
+ * @author jkuhnert
+ */
[EMAIL PROTECTED]
+public class TestLocalizedStringRender extends BaseComponentTestCase
+{
+ protected LocalizationToken newToken(String tag, String key, boolean raw,
Map attributes)
+ {
+ Location l = newLocation();
+ return new LocalizationToken(tag, key, raw, attributes, l);
+ }
+
+ public void test_No_Attributes()
+ {
+ IRequestCycle cycle = newCycle(false);
+ IMarkupWriter writer = newWriter();
+ IComponent c = newComponent();
+ LocalizationToken tok = newToken(null, "hello", false, null);
+ Messages m = newMock(Messages.class);
+
+ LocalizedStringRender render = new LocalizedStringRender(c, tok);
+
+ expect(c.getMessages()).andReturn(m);
+ expect(m.getMessage("hello")).andReturn("World");
+
+ writer.print("World", false);
+
+ replay();
+
+ render.render(writer, cycle);
+
+ verify();
+ }
+
+ public void test_Attributes()
+ {
+ IRequestCycle cycle = newCycle(false);
+ IMarkupWriter writer = newWriter();
+ IComponent c = newComponent();
+
+ Map attr = new HashMap();
+ attr.put("class", "feely mcfeels");
+ attr.put("joo", "talkin to me?");
+
+ LocalizationToken tok = newToken(null, "hello", false, attr);
+ Messages m = newMock(Messages.class);
+
+ LocalizedStringRender render = new LocalizedStringRender(c, tok);
+
+ expect(c.getMessages()).andReturn(m);
+ expect(m.getMessage("hello")).andReturn("World");
+
+ writer.begin("span");
+ writer.attribute("joo", (String)attr.get("joo"));
+ writer.attribute("class", (String)attr.get("class"));
+ writer.print("World", false);
+ writer.end();
+
+ replay();
+
+ render.render(writer, cycle);
+
+ verify();
+ }
+
+ public void test_Attributes_Tag()
+ {
+ IRequestCycle cycle = newCycle(false);
+ IMarkupWriter writer = newWriter();
+ IComponent c = newComponent();
+
+ Map attr = new HashMap();
+ attr.put("class", "feely mcfeels");
+
+ LocalizationToken tok = newToken("div", "hello", false, attr);
+ Messages m = newMock(Messages.class);
+
+ LocalizedStringRender render = new LocalizedStringRender(c, tok);
+
+ expect(c.getMessages()).andReturn(m);
+ expect(m.getMessage("hello")).andReturn("World");
+
+ writer.begin("div");
+ writer.attribute("class", (String)attr.get("class"));
+ writer.print("World", false);
+ writer.end();
+
+ replay();
+
+ render.render(writer, cycle);
+
+ verify();
+ }
+}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
Thu Dec 7 21:43:16 2006
@@ -100,7 +100,7 @@
verify();
}
- public void testNoField()
+ public void test_Null_Field()
{
IValidationDelegate delegate = new MockDelegate();
IForm form = newForm(delegate);
@@ -113,21 +113,21 @@
expect(cycle.renderStackPush(fl)).andReturn(fl);
trainGetForm(cycle, form);
-
+
trainIsRewinding(cycle, false);
-
+
expect(cycle.renderStackPop()).andReturn(fl);
replay();
fl.render(writer, cycle);
-
assertBuffer("{LABEL-PREFIX}<label>{BEFORE-TEXT}FredFlintstone{AFTER-TEXT}</label>{LABEL-SUFFIX}");
+ assertBuffer("<label>{BEFORE-TEXT}FredFlintstone{AFTER-TEXT}</label>");
verify();
}
- public void testNoFieldRaw()
+ public void test_Null_Field_Raw()
{
IValidationDelegate delegate = new MockDelegate();
IForm form = newForm(delegate);
@@ -149,7 +149,7 @@
fl.render(writer, cycle);
-
assertBuffer("{LABEL-PREFIX}<label>{BEFORE-TEXT}<b>FredFlintstone</b>{AFTER-TEXT}</label>{LABEL-SUFFIX}");
+
assertBuffer("<label>{BEFORE-TEXT}<b>FredFlintstone</b>{AFTER-TEXT}</label>");
verify();
}
Modified: tapestry/tapestry4/trunk/tapestry-portlet/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/pom.xml?view=diff&rev=483838&r1=483837&r2=483838
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/pom.xml Thu Dec 7 21:43:16 2006
@@ -37,6 +37,10 @@
<artifactId>easymockclassextension</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>