You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by te...@apache.org on 2009/08/08 23:38:43 UTC
svn commit: r802459 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/services/
main/java/org/apache/tapestry5/services/
test/java/org/apache/tapestry5/internal/services/
test/java/org/apache/tapestry5/internal/t...
Author: tedst
Date: Sat Aug 8 21:38:42 2009
New Revision: 802459
URL: http://svn.apache.org/viewvc?rev=802459&view=rev
Log:
TAP5-807: PageRenderLinkSource should add additional methods for creating a Link when you have the page's activation context as an EventContext
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java?rev=802459&r1=802458&r2=802459&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java Sat Aug 8 21:38:42 2009
@@ -17,6 +17,7 @@
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.ComponentClassResolver;
import org.apache.tapestry5.Link;
+import org.apache.tapestry5.EventContext;
public class PageRenderLinkSourceImpl implements PageRenderLinkSource
{
@@ -50,8 +51,23 @@
return createPageRenderLinkWithContext(toPageName(pageClass), context);
}
+ public Link createPageRenderLinkWithContext(Class pageClass, EventContext eventContext)
+ {
+ return createPageRenderLinkWithContext(toPageName(pageClass), eventContext);
+ }
+
public Link createPageRenderLinkWithContext(String pageName, Object... context)
{
return linkSource.createPageRenderLink(pageName, true, context);
}
+
+ public Link createPageRenderLinkWithContext(String pageName, EventContext eventContext)
+ {
+ int numberOfValues = eventContext.getCount();
+ Object[] pageActivationContext = new Object[numberOfValues];
+ for(int i = 0; i < numberOfValues; i++)
+ pageActivationContext[i] = eventContext.get(Object.class, i);
+ return linkSource.createPageRenderLink(pageName, true, pageActivationContext);
+ }
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java?rev=802459&r1=802458&r2=802459&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java Sat Aug 8 21:38:42 2009
@@ -15,6 +15,7 @@
package org.apache.tapestry5.services;
import org.apache.tapestry5.Link;
+import org.apache.tapestry5.EventContext;
/**
* A service that allows other services to create page render links (which are otherwise created by components, via
@@ -36,12 +37,21 @@
* Creates a page render link using an override of the page's passivation context (possibly an empty one).
*
* @param pageName name of page to create link to
- * @param context zero or more values to encode as the passiviation context
+ * @param context zero or more values to encode as the passiviation context
* @return render link for the page
*/
Link createPageRenderLinkWithContext(String pageName, Object... context);
/**
+ * Creates a page render link using an override of the page's passivation context.
+ *
+ * @param pageName name of page to create link to
+ * @param eventContext the EventContext to encode as the passiviation context
+ * @return render link for the page
+ */
+ public Link createPageRenderLinkWithContext(String pageName, EventContext eventContext);
+
+ /**
* Creates a page render link using the page's class to identify the target page, and using the pages normal
* passivation context (if it has one).
*
@@ -55,9 +65,19 @@
* page's passivation context (possibly an empty one).
*
* @param pageClass
- * @param context zero or more values to encode as the passiviation context
+ * @param context zero or more values to encode as the passiviation context
* @return render link for the page
*/
Link createPageRenderLinkWithContext(Class pageClass, Object... context);
+ /**
+ * Creates a page render link using the page's class to identify the target page, and using an override of the
+ * page's passivation context
+ *
+ * @param pageClass
+ * @param eventContext the EventContext to encode as the passiviation context
+ * @return render link for the page
+ */
+ Link createPageRenderLinkWithContext(Class pageClass, EventContext eventContext);
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImplTest.java?rev=802459&r1=802458&r2=802459&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImplTest.java Sat Aug 8 21:38:42 2009
@@ -19,6 +19,8 @@
import org.apache.tapestry5.services.ComponentClassResolver;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.Link;
+import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.ioc.services.TypeCoercer;
import org.testng.annotations.Test;
public class PageRenderLinkSourceImplTest extends InternalBaseTestCase
@@ -53,18 +55,32 @@
ComponentClassResolver resolver = mockComponentClassResolver();
LinkSource source = mockLinkSource();
Link link = mockLink();
+ EventContext eventContext = mockEventContext();
train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
expect(source.createPageRenderLink(PAGE_NAME, true, "fred", "barney")).andReturn(link);
+ train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
+
+ train_getCount(eventContext, 2);
+
+ train_get(eventContext, Object.class, 0, "ted");
+
+ train_get(eventContext, Object.class, 1, "barney");
+
+ expect(source.createPageRenderLink(PAGE_NAME, true, "ted", "barney")).andReturn(link);
+
replay();
PageRenderLinkSource service = new PageRenderLinkSourceImpl(source, resolver);
assertSame(service.createPageRenderLinkWithContext(PAGE_CLASS, "fred", "barney"), link);
+ assertSame(service.createPageRenderLinkWithContext(PAGE_CLASS, eventContext), link);
+
verify();
}
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java?rev=802459&r1=802458&r2=802459&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java Sat Aug 8 21:38:42 2009
@@ -433,7 +433,7 @@
* Reads the content of a file into a string. Each line is trimmed of line separators and leading/trailing
* whitespace.
*
- * @param trim trim each line of whitespace
+ * @param file trim each line of whitespace
*/
protected final String readFile(String file) throws Exception
{
Re: svn commit: r802459 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/services/ main/java/org/apache/tapestry5/services/
test/java/org/apache/tapestry5/internal/services/ test/java/org/apache/tapestry5/internal/t...
Posted by Ulrich Stärk <ul...@spielviel.de>.
Hi Ted,
I've got some remarks regarding code style. Quoting
http://tapestry.apache.org/tapestry5.1/dev/bible.html: "please try to make your code blend in when
modifying existing source". See below.
Cheers,
Uli
On 08.08.2009 23:38 schrieb tedst@apache.org:
> Author: tedst
> Date: Sat Aug 8 21:38:42 2009
> New Revision: 802459
>
> URL: http://svn.apache.org/viewvc?rev=802459&view=rev
> Log:
> TAP5-807: PageRenderLinkSource should add additional methods for creating a Link when you have the page's activation context as an EventContext
>
> Modified:
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImplTest.java
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java?rev=802459&r1=802458&r2=802459&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java (original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderLinkSourceImpl.java Sat Aug 8 21:38:42 2009
> @@ -17,6 +17,7 @@
> import org.apache.tapestry5.services.PageRenderLinkSource;
> import org.apache.tapestry5.services.ComponentClassResolver;
> import org.apache.tapestry5.Link;
> +import org.apache.tapestry5.EventContext;
>
> public class PageRenderLinkSourceImpl implements PageRenderLinkSource
> {
> @@ -50,8 +51,23 @@
> return createPageRenderLinkWithContext(toPageName(pageClass), context);
> }
>
> + public Link createPageRenderLinkWithContext(Class pageClass, EventContext eventContext)
> + {
> + return createPageRenderLinkWithContext(toPageName(pageClass), eventContext);
> + }
> +
> public Link createPageRenderLinkWithContext(String pageName, Object... context)
> {
> return linkSource.createPageRenderLink(pageName, true, context);
> }
> +
> + public Link createPageRenderLinkWithContext(String pageName, EventContext eventContext)
> + {
> + int numberOfValues = eventContext.getCount();
> + Object[] pageActivationContext = new Object[numberOfValues];
> + for(int i = 0; i < numberOfValues; i++)
> + pageActivationContext[i] = eventContext.get(Object.class, i);
> + return linkSource.createPageRenderLink(pageName, true, pageActivationContext);
> + }
please add line breaks between statements.
> +
> }
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java?rev=802459&r1=802458&r2=802459&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java (original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PageRenderLinkSource.java Sat Aug 8 21:38:42 2009
> @@ -15,6 +15,7 @@
> package org.apache.tapestry5.services;
>
> import org.apache.tapestry5.Link;
> +import org.apache.tapestry5.EventContext;
>
> /**
> * A service that allows other services to create page render links (which are otherwise created by components, via
> @@ -36,12 +37,21 @@
> * Creates a page render link using an override of the page's passivation context (possibly an empty one).
> *
> * @param pageName name of page to create link to
> - * @param context zero or more values to encode as the passiviation context
> + * @param context zero or more values to encode as the passiviation context
> * @return render link for the page
> */
> Link createPageRenderLinkWithContext(String pageName, Object... context);
>
> /**
> + * Creates a page render link using an override of the page's passivation context.
> + *
> + * @param pageName name of page to create link to
> + * @param eventContext the EventContext to encode as the passiviation context
> + * @return render link for the page
@since missing.
> + */
> + public Link createPageRenderLinkWithContext(String pageName, EventContext eventContext);
> +
> + /**
> * Creates a page render link using the page's class to identify the target page, and using the pages normal
> * passivation context (if it has one).
> *
> @@ -55,9 +65,19 @@
> * page's passivation context (possibly an empty one).
> *
> * @param pageClass
> - * @param context zero or more values to encode as the passiviation context
> + * @param context zero or more values to encode as the passiviation context
> * @return render link for the page
> */
> Link createPageRenderLinkWithContext(Class pageClass, Object... context);
>
> + /**
> + * Creates a page render link using the page's class to identify the target page, and using an override of the
> + * page's passivation context
> + *
> + * @param pageClass
> + * @param eventContext the EventContext to encode as the passiviation context
> + * @return render link for the page
@since missing
> + */
> + Link createPageRenderLinkWithContext(Class pageClass, EventContext eventContext);
> +
> }
>
...
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org