Component parameters events

2009-04-02 Thread Jason Tan
I must be going crazy.

On the 5.0.18 docs for component
renderinghttp://tapestry.apache.org/tapestry5/guide/rendering.html,
it clearly states that in setupRender(), This is a good place to read
component parameters and use them to set temporary instance variables..

So I did exactly that. I made a Foo page (with simple tml), with an embedded
Bar component (with simple tml) that takes a required parameter called
barParam of type String. I bound barParam in Foo's setupRender to
someString. In Bar's *setupRender*(), I set a breakpoint, and voila,
barParam is null. Amazingly, I set a breakpoint in *beginRender*(), and
barParam is properly set to someString. Am I missing something???

Second question -- if an embedded component handles an event, i.e.
onActionFromHello, it appears that bound parameters from initial page render
are lost on subsequent calls straight to the url, i.e
http://example.com/foo.bar:hello (as this would happen in AJAX). As I
understand it, the only way to keep this persistent between subsequent AJAX
calls would be using @Persist?

Third question: event methods can be placed on pages, not just components,
right? i.e if on page Foo i want to bind to the event Hello, i just add
void onActionFromHello() { //blah blah } and I should be able to trigger
that event by hitting http://example.com/foo:hello , right? That doesnt seem
to work, it complains with Request event 'hello' (on component foo) was not
handled; you must provide a matching event handler method in the component
or in one of its containers I don't have to do anything else, right?

Thanks,
Jason


Re: Component parameters events

2009-04-02 Thread Jason Tan
Sorry, should've been more specific -- the URLs that you POST and GET to
from within the javascript will usually have hardcoded URLs. Perhaps it is
broken than I am using event methods on embedded components to act as the
server-side AJAX handler, and maybe each ajax handler should be its own
page.

Thanks for the tip on printing parameter value vs. debugger, really good to
know. I thought I was going crazy!!!

Finally, I'm still baffed by the event method on page. If you have a simple
page, Foo.java, with just this:

void onActionFromHello()
{
log.debug(onActionFromHello);
}

Shouldn't you be able to execute that method by going to
http://example.com/foo:hello ? Except what I get is Request event 'hello'
(on component foo) was not handled; you must provide a matching event
handler method in the component or in one of its containers.

I am really scratching my head because this jumpstart
pagehttp://jumpstart.doublenegative.com.au:8080/jumpstart/examples/navigation/eventlinkshas
a perfectly working example, and I feel like I've copied it perfectly.


Thanks,
Jason


On Thu, Apr 2, 2009 at 5:21 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 Em Thu, 02 Apr 2009 21:03:54 -0300, Jason Tan jtan...@gmail.com
 escreveu:


  Unfortunately, in AJAX scenarios, the URL has to be hard-coded (though I
 suppose you could write use an EventLink to render the URL as a global
 variable inline in the TML, but that seems nasty).


 Not quite. You can use methods from ComponentResources and some Tapestry
 services to generate links for you. No need to hardcode URLs.

 This example is adapted from EventLink:

 @Inject
 private ComponentResources resources;

 @Override
 protected Link createMethodLink(Object[] contextArray) {
return resources.createEventLink(yourEventName, contextArray);
 }


  My original question though, is whether event methods on *pages* are
 acceptable,


 Yes, and we use it all the time. And the difference between pages and
 components in Tapestry 5 is very small: pages have URLs, components have
 parameters, some different lifecycle events. Internally, a page is a
 component.

  Also, I think my first and most baffling question wasn't answered, quoted
 again for reference. More specifcally, are component parameters expected
 to be bound by the time a an embedded component's setupRender() is called,
 or are they only bound when beginRender() is called? My debugging
 investigation indicated the latter, even though the documentation indicates
 the former.


 Try printing the parameter value instead of using the debugger. Tapestry
 modifies your class on-the-fly and fields with Tapestry annotations are not
 normal fields.

 --
 Thiago H. de Paula Figueiredo
 Independent Java consultant, developer, and instructor
 http://www.arsmachina.com.br/thiago


 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Tapestry and JPA/Spring transactions

2009-03-06 Thread Jason Tan
Is there a library/resource for opening and closing JPA EntityTransactions
per request like how tapestry-hibernate does? I discovered the wiki
pagehttp://wiki.apache.org/tapestry/Tapestry5_How_To_Integrate_Components_With_Spring_Transactionson
integrating Spring's @Transactional so you could place it on a
setupRender( ), but I'm still unsure how you'd use that to encapsulate the
request (instead of just one method) -- the core problem here is that we
have ORM objects with associations that aren't eagerly fetched (because
they're @OneToMany). Thus, outside of the DAO service call (which is
annotated with @Transactional), the associations are null. We could use
eager fetching per-query or per-class, but I think the most natural fix is
opening and closing a transaction per request. Ideas?

Thanks,
Jason


assets in src/main/resources (classpath?) vs. src/main/webapp (context?)

2009-02-24 Thread Jason Tan
I'm having trouble understanding the difference between classpath vs.
context assets -- when is it better to use one or the other? Right now I've
been putting Javascript and CSS under src/main/webapp/ , and referencing it
old-school using script src=foo.js type=text/javascript /script but
am learning about the new @IncludeJavaScriptLibrary annotation. It appears
to use classpath assets though, and if I understand it correctly, expects
files to be in src/main/resources. Another advantage of classpath assets
appears to be versioning for cache-busting (although it looks like 5.1 will
include this for context assets too?). Should I be putting my JS/CSS/static
images in src/main/resources, packaged with .tml files?

Anyway, any sort of clarification would be appreciated.

Thanks,
Jason


Grid: multiple tr within grid row

2009-02-23 Thread Jason Tan
Hi,

I'd like to render multiple tr elements within the same grid row.
Searching this mailing list seems to come up with a combination of
subclassing Grid and GridRows (i.e.
http://tapestry.markmail.org/search/?q=override+gridrows#query:override%20gridrows+page:1+mid:ztjjoksxggnbkstv+state:results_)
-- was wondering if there was a more elegant way to do this?

Thanks,
Jason