You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/04/05 22:10:25 UTC
svn commit: r645168 - in /tapestry/tapestry5/trunk:
tapestry-core/src/main/java/org/apache/tapestry/corelib/base/
tapestry-core/src/main/java/org/apache/tapestry/corelib/components/
tapestry-core/src/main/java/org/apache/tapestry/internal/services/ tap...
Author: hlship
Date: Sat Apr 5 13:10:20 2008
New Revision: 645168
URL: http://svn.apache.org/viewvc?rev=645168&view=rev
Log:
TAPESTRY-2294: The various link components should only generate an id attribute if the id parameter is bound
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app2/mixins/
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app2/mixins/ForceId.java
Removed:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/PageLinkTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentEventLink.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderQueueImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FlashDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/base/AbstractLinkTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForActionLink.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForLocale.tml
tapestry/tapestry5/trunk/tapestry-hibernate/src/test/java/org/apache/tapestry/hibernate/integration/TapestryHibernateIntegrationTests.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentEventLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentEventLink.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentEventLink.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentEventLink.java Sat Apr 5 13:10:20 2008
@@ -14,11 +14,12 @@
package org.apache.tapestry.corelib.base;
-import org.apache.tapestry.*;
+import org.apache.tapestry.Link;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.TapestryConstants;
import org.apache.tapestry.annotations.Environmental;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.internal.services.ClientBehaviorSupport;
-import org.apache.tapestry.ioc.annotations.Inject;
import java.util.List;
@@ -42,12 +43,6 @@
@Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
private String _zone;
- @Inject
- private ComponentResources _resources;
-
- @Environmental
- private PageRenderSupport _support;
-
@Environmental
private ClientBehaviorSupport _clientBehaviorSupport;
@@ -55,15 +50,13 @@
{
if (isDisabled()) return;
- String clientId = _support.allocateClientId(_resources);
-
Object[] contextArray = _context == null ? new Object[0] : _context.toArray();
Link link = createLink(contextArray);
- writeLink(writer, clientId, link);
+ writeLink(writer, link);
- if (_zone != null) _clientBehaviorSupport.linkZone(clientId, _zone);
+ if (_zone != null) _clientBehaviorSupport.linkZone(getClientId(), _zone);
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java Sat Apr 5 13:10:20 2008
@@ -14,12 +14,10 @@
package org.apache.tapestry.corelib.base;
-import org.apache.tapestry.ClientElement;
-import org.apache.tapestry.ComponentResources;
-import org.apache.tapestry.Link;
-import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.*;
import static org.apache.tapestry.TapestryConstants.LITERAL_BINDING_PREFIX;
import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.annotations.SetupRender;
import org.apache.tapestry.annotations.SupportsInformalParameters;
import org.apache.tapestry.dom.Element;
import org.apache.tapestry.internal.services.ComponentInvocationMap;
@@ -50,8 +48,13 @@
@Inject
private ComponentResources _resources;
+ @Inject
+ private PageRenderSupport _pageRenderSupport;
+
private Link _link;
+ private Element _element;
+
private String _clientId;
private String buildHref(Link link)
@@ -64,28 +67,33 @@
}
+ @SetupRender
+ void resetElementAndClientId()
+ {
+ _element = null;
+ _clientId = null;
+ }
+
/**
* Writes an <a> element with the provided link as the href attribute. A call to {@link
* org.apache.tapestry.MarkupWriter#end()} is <em>not</em> provided. Automatically appends an anchor if
* the component's anchor parameter is non-null. Informal parameters are rendered as well.
*
* @param writer to write markup to
- * @param clientId value written as the id attribute
* @param link the link that will form the href
* @param namesAndValues additional attributes to write
*/
- protected final void writeLink(MarkupWriter writer, String clientId, Link link, Object... namesAndValues)
+ protected final void writeLink(MarkupWriter writer, Link link, Object... namesAndValues)
{
- Element e = writer.element("a", "href", buildHref(link), "id", clientId);
+ _element = writer.element("a", "href", buildHref(link));
writer.attributes(namesAndValues);
_resources.renderInformalParameters(writer);
- _componentInvocationMap.store(e, link);
+ _componentInvocationMap.store(_element, link);
_link = link;
- _clientId = clientId;
}
/**
@@ -102,10 +110,22 @@
/**
* Returns the unique client id for this element. This is valid only after the component has rendered (its start
- * tag), and then only if the component is {@linkplain #isDisabled() enabled}.
+ * tag). A client id is generated the first time this method is invoked, after the link renders its start tag.
*/
- public String getClientId()
+ public final String getClientId()
{
+ if (_clientId == null)
+ {
+ if (_element == null)
+ throw new IllegalStateException(
+ String.format("Client id for %s is not available as it did not render yet (or was disabled).",
+ _resources.getCompleteId()));
+
+ _clientId = _pageRenderSupport.allocateClientId(_resources);
+
+ _element.forceAttributes("id", _clientId);
+ }
+
return _clientId;
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java Sat Apr 5 13:10:20 2008
@@ -14,8 +14,9 @@
package org.apache.tapestry.corelib.components;
-import org.apache.tapestry.*;
-import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.Link;
+import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.corelib.base.AbstractLink;
import org.apache.tapestry.ioc.annotations.Inject;
@@ -30,7 +31,7 @@
* Pages are not required to have an activation context. When a page does have an activation context, the value
* typically represents the identity of some object displayed or otherwise manipulated by the page.
*/
-public class PageLink extends AbstractLink implements ClientElement
+public class PageLink extends AbstractLink
{
/**
* The logical name of the page to link to.
@@ -41,18 +42,6 @@
@Inject
private ComponentResources _resources;
- @Environmental
- private PageRenderSupport _support;
-
- /**
- * If true, then then no link element is rendered (and no informal parameters as well). The body is, however, still
- * rendered.
- */
- @Parameter("false")
- private boolean _disabled;
-
- private String _clientId;
-
/**
* If provided, this is the activation context for the target page (the information will be encoded into the URL).
* If not provided, then the target page will provide its own activation context.
@@ -64,31 +53,19 @@
void beginRender(MarkupWriter writer)
{
- if (_disabled) return;
-
- _clientId = _support.allocateClientId(_resources);
+ if (isDisabled()) return;
Object[] activationContext = _context != null ? _context.toArray() : _emptyContext;
Link link = _resources.createPageLink(_page, _resources.isBound("context"), activationContext);
- writeLink(writer, _clientId, link);
+ writeLink(writer, link);
}
void afterRender(MarkupWriter writer)
{
- if (_disabled) return;
+ if (isDisabled()) return;
writer.end(); // <a>
- }
-
- public String getClientId()
- {
- return _clientId;
- }
-
- void setDisabled(boolean disabled)
- {
- _disabled = disabled;
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderQueueImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderQueueImpl.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderQueueImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderQueueImpl.java Sat Apr 5 13:10:20 2008
@@ -88,7 +88,7 @@
long elapsedNanos = endNanos - startNanos;
double elapsedSeconds = ((float) elapsedNanos) / 1000000000F;
- _logger.debug(String.format("Executed %,d rendering commands in %.2f seconds",
+ _logger.debug(String.format("Executed %,d rendering commands in %.3f seconds",
commandCount,
elapsedSeconds));
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FlashDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FlashDemo.tml?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FlashDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FlashDemo.tml Sat Apr 5 13:10:20 2008
@@ -1,18 +1,18 @@
<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-
+
<h1>Flash Demo</h1>
<p>
The message: [${message}]
- </p>
-
+ </p>
+
<p>
- Click <a t:type="ActionLink" t:id="show">here</a> to show the message.
+ <a t:type="ActionLink" t:id="show">show the message</a>
</p>
-
+
<p>
- Click <a t:id="refresh" t:type="PageLink" page="FlashDemo">here</a> to refresh the page.
+ <a t:id="refresh" t:type="PageLink" page="FlashDemo">refresh the page</a>
</p>
-
+
</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/base/AbstractLinkTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/base/AbstractLinkTest.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/base/AbstractLinkTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/base/AbstractLinkTest.java Sat Apr 5 13:10:20 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 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.
@@ -52,7 +52,7 @@
_linkFixture.inject(null, map, resources);
- _linkFixture.writeLink(writer, "fred", link);
+ _linkFixture.writeLink(writer, link);
verify();
@@ -61,7 +61,7 @@
writer.write("link text");
writer.end();
- assertEquals(writer.toString(), "<a href=\"/foo/bar.baz\" id=\"fred\">link text</a>");
+ assertEquals(writer.toString(), "<a href=\"/foo/bar.baz\">link text</a>");
assertSame(map.get(e), invocation);
}
@@ -84,7 +84,7 @@
_linkFixture.inject("wilma", map, resources);
- _linkFixture.writeLink(writer, "barney", link);
+ _linkFixture.writeLink(writer, link);
verify();
@@ -93,7 +93,7 @@
writer.write("link text");
writer.end();
- assertEquals(writer.toString(), "<a href=\"/foo/bar.baz#wilma\" id=\"barney\">link text</a>");
+ assertEquals(writer.toString(), "<a href=\"/foo/bar.baz#wilma\">link text</a>");
assertSame(map.get(e), invocation);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Sat Apr 5 13:10:20 2008
@@ -449,11 +449,11 @@
assertTextPresent("[]");
- clickAndWait("show");
+ clickAndWait("link=show the message");
assertTextPresent("[You clicked the link!]");
- clickAndWait("refresh");
+ clickAndWait("link=refresh the page");
assertTextPresent("[]");
}
@@ -485,7 +485,7 @@
{
start(linkLabel);
- clickAndWait("reset");
+ clickAndWait("link=reset the database");
assertFieldValue("title", "End World Hunger");
assertFieldValue("title_0", "Develop Faster-Than-Light Travel");
@@ -501,7 +501,7 @@
assertFieldValue("title_0", "Develop Faster-Than-Light Travel - immediately");
assertFieldValue("title_1", "Cure Common Cold - post haste");
- clickAndWait("addNew");
+ clickAndWait("//input[@value='Add new ToDo']");
type("title_2", "Conquer World");
@@ -731,7 +731,7 @@
{
start("Kicker");
- clickAndWait("actionlink");
+ clickAndWait("link=kick target");
assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
assertTextPresent("No component context.");
@@ -747,11 +747,11 @@
{
start("Kicker");
- clickAndWait("actionlink");
+ clickAndWait("link=kick target");
assertTextSeries("//li[%d]", 1, "betty", "wilma", "betty/wilma", "\u82B1\u5B50");
- clickAndWait("nocontext");
+ clickAndWait("link=Target base, no context");
assertTextPresent("No activation context.");
}
@@ -874,23 +874,23 @@
clickAndWait(clear);
- clickAndWait("wilma");
+ clickAndWait("link=No Context");
assertTextPresent(
"[parent.eventHandlerZero(), parent.onAction(), child.eventHandlerZeroChild(), child.onAction()]");
clickAndWait(clear);
- clickAndWait("barney");
+ clickAndWait("link=Single context value");
assertTextPresent(
"[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerOneChild(), child.eventHandlerZeroChild(), child.onAction(String), child.onAction()]");
clickAndWait(clear);
- clickAndWait("betty");
+ clickAndWait("link=Two value context");
assertTextPresent(
"[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerOneChild(), child.eventHandlerZeroChild(), child.onAction(String), child.onAction()]");
clickAndWait(clear);
- clickAndWait("fred");
+ clickAndWait("link=Two value context (from fred)");
assertTextPresent(
"[parent.eventHandlerOne(String), parent.eventHandlerZero(), parent.onAction(String), parent.onAction(), child.eventHandlerForFred(), child.eventHandlerOneChild(), child.eventHandlerZeroChild(), child.onAction(String), child.onAction(), child.onActionFromFred(String), child.onActionFromFred()]");
@@ -1665,7 +1665,7 @@
assertText("usingGet", "false");
assertText("usingIs", "false");
- clickAndWait("set");
+ clickAndWait("link=set");
assertText("usingGet", "true");
assertText("usingIs", "true");
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app2/mixins/ForceId.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app2/mixins/ForceId.java?rev=645168&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app2/mixins/ForceId.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app2/mixins/ForceId.java Sat Apr 5 13:10:20 2008
@@ -0,0 +1,29 @@
+// Copyright 2008 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.integration.app2.mixins;
+
+import org.apache.tapestry.ClientElement;
+import org.apache.tapestry.annotations.InjectContainer;
+
+public class ForceId
+{
+ @InjectContainer
+ private ClientElement container;
+
+ void afterRender()
+ {
+ container.getClientId();
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForActionLink.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForActionLink.tml?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForActionLink.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForActionLink.tml Sat Apr 5 13:10:20 2008
@@ -1,5 +1,5 @@
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-<p>
-<a t:id="link1" t:type="ActionLink" context="123">abc</a>
-</p>
+ <p>
+ <a t:id="link1" t:type="ActionLink" context="123" t:mixins="forceid">abc</a>
+ </p>
</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForLocale.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForLocale.tml?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForLocale.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForLocale.tml Sat Apr 5 13:10:20 2008
@@ -1,4 +1,4 @@
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-<p id="id1">English page</p>
-<p t:type="ActionLink" t:id="changeLocale">Change locale</p>
+ <p id="id1">English page</p>
+ <p t:type="ActionLink" t:id="changeLocale" t:mixins="forceid">Change locale</p>
</html>
Modified: tapestry/tapestry5/trunk/tapestry-hibernate/src/test/java/org/apache/tapestry/hibernate/integration/TapestryHibernateIntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-hibernate/src/test/java/org/apache/tapestry/hibernate/integration/TapestryHibernateIntegrationTests.java?rev=645168&r1=645167&r2=645168&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-hibernate/src/test/java/org/apache/tapestry/hibernate/integration/TapestryHibernateIntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-hibernate/src/test/java/org/apache/tapestry/hibernate/integration/TapestryHibernateIntegrationTests.java Sat Apr 5 13:10:20 2008
@@ -17,7 +17,7 @@
import org.apache.tapestry.test.AbstractIntegrationTestSuite;
import org.testng.annotations.Test;
-@Test(sequential=true,groups="integration")
+@Test(sequential = true, groups = "integration")
public class TapestryHibernateIntegrationTests extends AbstractIntegrationTestSuite
{
public TapestryHibernateIntegrationTests()
@@ -25,58 +25,63 @@
super("src/test/webapp");
}
- public void valueencode_all_entity_types() throws Exception {
- open("/encodeentities");
-
- assertEquals(0, getText("//span[@id='name']").length());
-
- // need to create an entity in order to link with one
- clickAndWait("//a[@id='createentity']");
- assertEquals("name", getText("//span[@id='name']"));
-
- // should return null for missing objects
- open("/encodeentities/9999");
- assertEquals(0, getText("//span[@id='name']").length());
- }
-
- public void persist_entities() {
- open("/persistentity");
- assertEquals(0, getText("//span[@id='name']").length());
-
- clickAndWait("link=create entity");
- assertText("//span[@id='name']", "name");
-
- // shouldn't save the change to the name because it's reloaded every time
- clickAndWait("link=change the name");
- assertText("//span[@id='name']", "name");
-
- // can set back to null
- clickAndWait("link=set to null");
- assertEquals(getText("//span[@id='name']").length(), 0);
-
- // deleting an entity that is still persisted. just remove the entity from the session if it's not found.
- clickAndWait("link=create entity");
- assertText("//span[@id='name']", "name");
- clickAndWait("link=delete");
- assertEquals(getText("//span[@id='name']").length(), 0);
-
- // transient objects cannot be persisted
- clickAndWait("link=set to transient");
- assertTextPresent("Error persisting");
- }
-
- /** TAPESTRY-2244 */
- public void using_cached_with_form() {
- open("/cachedform");
+ public void valueencode_all_entity_types() throws Exception
+ {
+ open("/encodeentities");
+
+ assertEquals(0, getText("//span[@id='name']").length());
+
+ // need to create an entity in order to link with one
+ clickAndWait("link=create an entity");
+ assertEquals("name", getText("//span[@id='name']"));
+
+ // should return null for missing objects
+ open("/encodeentities/9999");
+ assertEquals(0, getText("//span[@id='name']").length());
+ }
+
+ public void persist_entities()
+ {
+ open("/persistentity");
+ assertEquals(0, getText("//span[@id='name']").length());
+
+ clickAndWait("link=create entity");
+ assertText("//span[@id='name']", "name");
+
+ // shouldn't save the change to the name because it's reloaded every time
+ clickAndWait("link=change the name");
+ assertText("//span[@id='name']", "name");
+
+ // can set back to null
+ clickAndWait("link=set to null");
+ assertEquals(getText("//span[@id='name']").length(), 0);
+
+ // deleting an entity that is still persisted. just remove the entity from the session if it's not found.
+ clickAndWait("link=create entity");
+ assertText("//span[@id='name']", "name");
+ clickAndWait("link=delete");
+ assertEquals(getText("//span[@id='name']").length(), 0);
+
+ // transient objects cannot be persisted
+ clickAndWait("link=set to transient");
+ assertTextPresent("Error persisting");
+ }
+
+ /**
+ * TAPESTRY-2244
+ */
+ public void using_cached_with_form()
+ {
+ open("/cachedform");
assertTextSeries("name_%d", 0);
-
+
type("name", "name1");
clickAndWait(SUBMIT);
assertTextSeries("name_%d", 0, "name1");
type("name", "name2");
clickAndWait(SUBMIT);
- assertTextSeries("name_%d", 0, "name1", "name2");
+ assertTextSeries("name_%d", 0, "name1", "name2");
}
}