Re: Tapestry5: Passing parameters to pages

2007-02-17 Thread Carlos Curotto

Thanks for the quickly reply howard.  I will wait for the documentation.

Thanks!

--
Carlos Curotto


Re: Tapestry5: Passing parameters to pages

2007-02-16 Thread Dennis Kempin
Well that would be a nice solution I think.

Well I dont see any other way to make a simple content list / display
application. The onActivate Event seems to be really useful, entering the
URL manually works great, but i dont know any solution to link to such a
page.

I tried the following hack:
t:comp type=Loop source=prop:entries value=entry
a href=/view/${entry.id}${entry.title}/a
/t:comp
But well, expansions are not evaluated in tag attributes.

I will checkout the tapestry svn and try to add context support for
PageLinks. Maybe i get it working. 

regards
Dennis

Howard Lewis Ship wrote:

 I'm thinking that PageLink should support a context parameter that
 bypasses the target page's passivate event. This puts some
 responsibility on the programmer to ensure that any such use of
 PageLink provides the correct context that will be needed by the
 target page's activate event handler.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tapestry5: Passing parameters to pages

2007-02-16 Thread Dennis Kempin
Well I finally got it working, making some smaller changes to the
LinkFactory(Impl) and ComponentResource. 
I added a method Link createPageLink(Page page, Object... overrideContext)
and markes the Link createPageLink(Page page) one as deprecated (java
should accept calls to createPageLink(page) using 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tapestry5: Passing parameters to pages

2007-02-16 Thread Dennis Kempin
Sorry, i hit the wrong button, please ignore my previous mail.


Well I finally got it working, making some smaller changes to the
LinkFactory(Impl), ComponentResource and PageLink of course. 

PageLink now takes a context parameter just like actionLink does and passes
it to the LinkFactory. The LinkFactory uses this context. The Passivate
event is only send when not specifying a context.

Example:
t:comp type=Loop source=prop:entries value=entry
t:comp type=PageLink page=view
context=prop:entry.id${entry.title}/t:comp
/t:comp

Details:
I added a method Link createPageLink(Page page, Object... overrideContext)
and markes the Link createPageLink(Page page) one as deprecated (java
should accept calls to createPageLink(page) without the deprecated Method
but it makes some trouble using reflection. 

Test Cases:
All existing Test cases are working, but I have not added a new one to test
the new functionality because I was too confused by the existing page_link
test in LinkFactoryImplTest class.

Patch is attached, maybe someone has use for it, or maybe it can get into
tapestry as contribution, i dont know. 

regards
Dennis
Index: src/test/java/org/apache/tapestry/internal/services/NoOpPage.java
===
--- src/test/java/org/apache/tapestry/internal/services/NoOpPage.java	(revision 508395)
+++ src/test/java/org/apache/tapestry/internal/services/NoOpPage.java	(working copy)
@@ -117,7 +117,7 @@
 
 }
 
-public Link createPageLink(String pageName)
+public Link createPageLink(String pageName, Object... contextOverride)
 {
 return null;
 }
Index: src/main/java/org/apache/tapestry/corelib/components/PageLink.java
===
--- src/main/java/org/apache/tapestry/corelib/components/PageLink.java	(revision 508395)
+++ src/main/java/org/apache/tapestry/corelib/components/PageLink.java	(working copy)
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry.corelib.components;
 
+import java.util.List;
+
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.Link;
 import org.apache.tapestry.MarkupWriter;
@@ -32,6 +34,9 @@
 @Parameter(required = true, defaultPrefix = literal)
 private String _page;
 
+@Parameter
+private List? _context;
+
 @Inject
 private ComponentResources _resources;
 
@@ -43,7 +48,9 @@
 {
 String clientId = _support.allocateClientId(_resources.getId());
 
-Link link = _resources.createPageLink(_page);
+Object[] contextArray = _context == null ? new Object[0] : _context.toArray();
+
+Link link = _resources.createPageLink(_page, contextArray);
 
 writer.element(a, href, link, id, clientId);
 
Index: src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
===
--- src/main/java/org/apache/tapestry/ComponentResourcesCommon.java	(revision 508395)
+++ src/main/java/org/apache/tapestry/ComponentResourcesCommon.java	(working copy)
@@ -59,8 +59,10 @@
 /**
  * Creates a link that will case a page within the application to render.
  */
+Link createPageLink(String pageName, Object... overrideContext);
+
+@Deprecated
 Link createPageLink(String pageName);
-
 /**
  * Returns a string consisting of the fully qualified class name of the containing page, and the
  * [EMAIL PROTECTED] #getNestedId() nested id} of this component, separated by a colon. I.e.,
Index: src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
===
--- src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java	(revision 508395)
+++ src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java	(working copy)
@@ -137,33 +137,47 @@
 
 public Link createPageLink(final Page page)
 {
+return createPageLink(page, new Object[0]);
+}
+
+public Link createPageLink(final Page page, Object... overrideContext)
+{
 Defense.notNull(page, page);
 
 String pageName = page.getName();
 String logicalPageName = _componentClassResolver.resolvePageClassNameToPageName(pageName);
 
-final List context = newList();
-
-ComponentEventHandler handler = new ComponentEventHandler()
+String[] contextStrings;
+if(overrideContext.length  0)
 {
-@SuppressWarnings(unchecked)
-public boolean handleResult(Object result, Component component, String methodDescription)
+contextStrings = toContextStrings(overrideContext);
+}
+else
+{
+final List context = newList(); 
+
+ComponentEventHandler handler = new ComponentEventHandler()
 {
-PassivateContextHandler contextHandler = _registry.getByInstance(result);
+   

Re: Tapestry5: Passing parameters to pages

2007-02-16 Thread Carlos Curotto

Hello everyone!

Is there any documentation about what template we have to put in a page
template for the different controls of tapestry 5? I mean, i can only create
the components that are shown in the screencasts, but i want to create
others like: combobox, checkbox, password, tables, etc...
I see the code and some of them are implemented in tapestry 5 but i can´t
find what i have to include in a tapestry template page to see it rendered
in the page.

Thanks in advance,

--
Carlos Curotto


Re: Tapestry5: Passing parameters to pages

2007-02-16 Thread Howard Lewis Ship

I'm working on the tool to generate the component documentation right now.

On 2/16/07, Carlos Curotto [EMAIL PROTECTED] wrote:

Hello everyone!

Is there any documentation about what template we have to put in a page
template for the different controls of tapestry 5? I mean, i can only create
the components that are shown in the screencasts, but i want to create
others like: combobox, checkbox, password, tables, etc...
I see the code and some of them are implemented in tapestry 5 but i can´t
find what i have to include in a tapestry template page to see it rendered
in the page.

Thanks in advance,

--
Carlos Curotto




--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tapestry5: Passing parameters to pages

2007-02-15 Thread Dennis Kempin
Hi,

I am experimenting with the tapestry snapshot version and want to write a
little page class that takes an integer parameter to specify an content id
to show. Just like passing a context with an Action link, but just without
the HTTP redirect back to the Page URL.
I could make use of a persistent field to store the id passed with the
context of the ActionLink to show it after reloading, but well that seems
to a be very hacky solution.

Example:
/nopaste/4 is handled by the /nopaste page, but how do I get the integer
value after the slash?

(well i could use the good old ?id=4 GET parameters, but the above example
would look more consistent, IMHO)

regards
Dennis




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tapestry5: Passing parameters to pages

2007-02-15 Thread DJ Gredler

I'm interested in knowing the answer to this, as well. In fact, to take it
one step further:

Instead of parameters:

http://www.mysite.com/view?country=spain
http://www.mysite.com/view?country=usa
http://www.mysite.com/view?country=france

And instead of including the page name:

http://www.mysite.com/view/spain
http://www.mysite.com/view/usa
http://www.mysite.com/view/france

I'd like to have something like:

http://www.mysite.com/spain
http://www.mysite.com/usa
http://www.mysite.com/france


On 2/15/07, Dennis Kempin [EMAIL PROTECTED] wrote:


Hi,

I am experimenting with the tapestry snapshot version and want to write a
little page class that takes an integer parameter to specify an content id
to show. Just like passing a context with an Action link, but just without
the HTTP redirect back to the Page URL.
I could make use of a persistent field to store the id passed with the
context of the ActionLink to show it after reloading, but well that seems
to a be very hacky solution.

Example:
/nopaste/4 is handled by the /nopaste page, but how do I get the integer
value after the slash?

(well i could use the good old ?id=4 GET parameters, but the above example
would look more consistent, IMHO)

regards
Dennis




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Tapestry5: Passing parameters to pages

2007-02-15 Thread Howard Lewis Ship

Check out the documentation on the activate and passivate component events.

You can think of passivate and activate as a kind of very lightweight
persistent storage, where the values are stored positionally in the
render URL.

I'm still thinking about the relationship between PageLink component
and the LinkFactory.

Currently, PageLink doesn't have a context parameter, and the context
if any is collected by triggering the passivate event on the page
(this is inside LinkFactoryImpl).

That's great if the target page knows what its context should be, but
could involve repeatedly setting the value just before the PageLink
renders.

I'm thinking that PageLink should support a context parameter that
bypasses the target page's passivate event. This puts some
responsibility on the programmer to ensure that any such use of
PageLink provides the correct context that will be needed by the
target page's activate event handler.

On 2/15/07, DJ Gredler [EMAIL PROTECTED] wrote:

I'm interested in knowing the answer to this, as well. In fact, to take it
one step further:

Instead of parameters:

http://www.mysite.com/view?country=spain
http://www.mysite.com/view?country=usa
http://www.mysite.com/view?country=france

And instead of including the page name:

http://www.mysite.com/view/spain
http://www.mysite.com/view/usa
http://www.mysite.com/view/france

I'd like to have something like:

http://www.mysite.com/spain
http://www.mysite.com/usa
http://www.mysite.com/france


On 2/15/07, Dennis Kempin [EMAIL PROTECTED] wrote:

 Hi,

 I am experimenting with the tapestry snapshot version and want to write a
 little page class that takes an integer parameter to specify an content id
 to show. Just like passing a context with an Action link, but just without
 the HTTP redirect back to the Page URL.
 I could make use of a persistent field to store the id passed with the
 context of the ActionLink to show it after reloading, but well that seems
 to a be very hacky solution.

 Example:
 /nopaste/4 is handled by the /nopaste page, but how do I get the integer
 value after the slash?

 (well i could use the good old ?id=4 GET parameters, but the above example
 would look more consistent, IMHO)

 regards
 Dennis




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]