Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Kalle Korhonen
On Mon, Dec 14, 2009 at 6:51 PM, Thiago H. de Paula Figueiredo
 wrote:
> Em Tue, 15 Dec 2009 00:34:25 -0200, Geoff Callender
>  escreveu:
(Bravo Geoff!)

> You can be happy with relational persistence now, but maybe not tomorrow. ;)
> Just to be very clear: when I say "JPA is not my DAO", I say "any class
> outside my persistence layer doesn't use JPA directly". As long as you
> define DAO interfaces that are technology-agnostic and your business rules
> classes use them, I'm happy with any DAO implementation. :)

That's just a typical overengineered design
(http://en.wikipedia.org/wiki/Overengineering). You've changed
languages and the hell has frozen many times over before you change
your persistence layer *if* you started with a relational database.

> I don't like anemic models, but I don't like entity classes that talk to
> DAOs or business rules classes, like the domain-driven model people love to
> do. I never have an entity class with a save() or findById() method. I like
> to think that an object must implement anything it can do inside its data
> structure, but never access anything beyond it (data store, external
> systems).

Surely transaction management is none of domain model's business, but
if you can represent a pure business rule in your domain model, why
not? You are not going to use that business logic anywhere else
anyway. Exactly how many layers of indirection do there need to be?
Most of the Java applications today are way over-engineered for their
purpose - while RoR and php folks are running circles around us.

Kalle

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



Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Tue, 15 Dec 2009 00:34:25 -0200, Geoff Callender  
 escreveu:


However, if you're happy to stick with relational, then JPA can be your  
DAO. You choose your relational persister at runtime, eg. Hibernate,  
TopLink, OpenJPA, etc.


You can be happy with relational persistence now, but maybe not tomorrow.  
;)
Just to be very clear: when I say "JPA is not my DAO", I say "any class  
outside my persistence layer doesn't use JPA directly". As long as you  
define DAO interfaces that are technology-agnostic and your business rules  
classes use them, I'm happy with any DAO implementation. :)


I'm building a system right now with almost all business logic  
encapsulated in the entities. Most of the entity methods represent state  
changes (eg. toAccepted(..), toRejected(..), toBilling(..),  
toBilled(..)) and many of those methods either create related entities  
or call state change methods on related entities. This kind of  
encapsulation is exactly what OO was all about before EJB 1 and 2 came  
along and stuffed us back into a procedural world with an anaemic domain  
model ( http://martinfowler.com/bliki/AnemicDomainModel.html ). The  
total effect is like a myriad of state machines interacting with each  
other, just like the real world, and so far I'm really liking it.


I don't like anemic models, but I don't like entity classes that talk to  
DAOs or business rules classes, like the domain-driven model people love  
to do. I never have an entity class with a save() or findById() method. I  
like to think that an object must implement anything it can do inside its  
data structure, but never access anything beyond it (data store, external  
systems).


If your entities represent the real world entities and the developer can  
clearly see they implement the same behaviours as the real world  
entities then it seems to me that it is the "right" coupling!


I think we agree, but we didn't realize it yet. :)

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Geoff Callender

On 14/12/2009, at 11:05 PM, Thiago H. de Paula Figueiredo wrote:

> Em Mon, 14 Dec 2009 07:55:21 -0200, Alessandro Bottoni 
>  escreveu:

>> 3) In his Jumpstart's FAQ, Geoff Callender says:
>> 
>> "Why did the Data Access Object pattern ever exist? As I recall it had
>> two purposes: to abstract away the data sources, and to hide the
>> implementation of accessing the data.
> 
> I agree!
> 
>> That is exactly what JPA (Java
>> Persistence Architecture, also known as EJB3 Persistence) does too. So I
>> argue that JPA has taken the place of the DAO and there's no need for us
>> to write our own. JumpStart uses JPA as its DAO."
> 
> I disagree. If a DAO exists the abstract away the data source and the 
> *implementation of accessing the data*, JPA is one implementation, Hibernate 
> is another, purde JDBC is another, etc. What if you want to change your 
> persistence to Google's BigTable (low-level API) or HBase or MongoDB or DB4O? 
> You have to change business rule code (they use JPA directly), and the DAO 
> pattern was created exactly to avoid this kind of sistuation.

You got me - JPA targets relational databases, so if you think that one day you 
might need to re-engineer your project to use a non-relational database then 
maybe it would be worth writing DAOs now as an extra layer of abstraction.

However, if you're happy to stick with relational, then JPA can be your DAO. 
You choose your relational persister at runtime, eg. Hibernate, TopLink, 
OpenJPA, etc. 

>> What do you think about this? Would you use the JPA entity also for
>> hosting some business logic?
> 
> I put in an entity all the logic that can be implemented just by using its 
> fields values. Example: if I have an Order entity that has Items, the 
> getTotalValue() method is placed in Order. Anything else goes to the business 
> logic classes.

I'm building a system right now with almost all business logic encapsulated in 
the entities. Most of the entity methods represent state changes (eg. 
toAccepted(..), toRejected(..), toBilling(..), toBilled(..)) and many of those 
methods either create related entities or call state change methods on related 
entities. This kind of encapsulation is exactly what OO was all about before 
EJB 1 and 2 came along and stuffed us back into a procedural world with an 
anaemic domain model ( http://martinfowler.com/bliki/AnemicDomainModel.html ). 
The total effect is like a myriad of state machines interacting with each 
other, just like the real world, and so far I'm really liking it.

> 
>> Would not this approach represent a net
>> lost of flexibilty (because of a lack of "loose coupling")?
> 
> IMHO, yes.

If your entities represent the real world entities and the developer can 
clearly see they implement the same behaviours as the real world entities then 
it seems to me that it is the "right" coupling!

> 
>> 4) Is there any good tutorial or any good working demo regarding the use
>> of Hibernate and/or Jpa with Tapestry5? At the moment I'm studying/using
>> the following tutorials and demos/apps.
> 
> http://tapestry.apache.org/tapestry5.1/tapestry-hibernate/userguide.html
> http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
> instructor
> Owner, software architect and developer, Ars Machina Tecnologia da Informação 
> Ltda.
> http://www.arsmachina.com.br
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org

Cheers,

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



Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 23:02:41 -0200, Ashwanth Kumar  
 escreveu:


Well, if you want Mouse and Text field (key press events), use Java  
Script on the client side, its very useful and efficient. If you're very
particular, use DWR to map JS events to a Java Class @ server side, but  
with in-built ajax support, Tapestry doesn't require it though.


I don't see the need for DWR for implementing something that Tapestry  
doesn't implement out-of-the-box. I have one example, but its written in  
Portuguese.


Solution outline:

1) Define an event name.

2) In your page, component or mixin class, @Inject ComponentResources and  
use its createEventLink() to create a link that will trigger that event.


3) Still in the same class, create a method with @OnEvent("yourEventName")  
that handles the event and returns a JSONObject or JSONArray.


4) @Inject RenderSupport and use its addScript() method to generate any  
needed initialization for your JavaScript code, including the event URL.


5) If you use Prototype, use Event.observe('elementId', 'eventName',  
function() { implement your handling here ; }) to listen to the event and  
invoke the event method usint its URL. You'll probably use Ajax.Request.  
transport.responseJSON is exactly the JSONObject or JSONArray you returned  
in your event handler method.


A simple template you can use, based in real code, follows. It reacts to a  
change in a select tag, posts its value, gets the response as a JSON  
object and the changes the value of some s with the object  
properties.


/* This URL is the one created by ComponentResources.createEventLink().
This is the function which is invoked by the JavaScript line added via  
RenderSupport.addScript().

*/
function initialize(url) {

Event.observe('selectId', 'change', function() {

new Ajax.Request(url, {
method : 'post',
parameters: { value: $F('selectId') },
onSuccess: function(transport) {
var result = transport.responseJSON;
$('span1').innerHTML = result.property1;
$('span2').innerHTML = result.property2;
$('span3').innerHTML = result.property3;
}
});

});

}

I hope it helps.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread Ashwanth Kumar
Well, if you want Mouse and Text field (key press events), use Java Script
on the client side, its very useful and efficient. If you're very
particular, use DWR to map JS events to a Java Class @ server side, but with
in-built ajax support, Tapestry doesn't require it though.

Protoype can help u with JS: http://www.prototypejs.org/api/event

 - Ashwanth Kumar

On Mon, Dec 14, 2009 at 7:25 PM, marioosh.net wrote:

>
>
>
> Olle Hallin-2 wrote:
> >
> > I forgot to paste in the JavaDocs link:
> >
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/annotations/OnEvent.html
> >
>
> Yes, I know this annotation but...
> i think it doesn't work for events like: mouseover, mouseout, change
> (textfield)...
>
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/EventConstants.html
>
>
> --
> View this message in context:
> http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4164188.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Dmitry Gusev
Why don't just use spring to manage EntityManager and transactions?
This worked very well for me.

I've just published my "ping-service" project to github so that you can see
how JPA/Spring can be implemented in T5 app:

http://github.com/dmitrygusev/ping-service

I already mentioned this project here on mail list earlier and showed how
simple is this to inject EntityManager into my T5 services, just like this:

public class JobResultDAOImpl implements JobResultDAO {

@PersistenceContext
private EntityManager em;

@Override
public void persistResult(JobResult result) {
em.persist(result);
}

...


and you're done.



On Mon, Dec 14, 2009 at 22:21, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> Em Mon, 14 Dec 2009 17:05:03 -0200, Piero Sartini 
> escreveu:
>
>
>  That's what I meant with re-inventing the wheel ;-)
>>
>
> You're right. :)
>
>
>  There are already lots of working implementations of JavaEE
>> persistence but every single web framework needs to build one
>> implementation of its own, simulating the specification. Maybe I am
>> the only one, but I find this is lost developer power that should be
>> used to make the web parts of these frameworks better...
>>
>
> Maybe we could use some light EJB 3.x implementation integrated with
> Tapestry-IoC (EJB-defined beans injectable as Tapestry-IoC services). This
> is something that will be done eventually.
> I've never used EJB, so I don't know what's the necessary effort to do
> that.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Res: Res: Specific CSS files for each browser

2009-12-14 Thread Everton Agner
Okay, thanks.

One of the weirdest problems I'm having is the DateField component Javascript 
calendar... It's "absolute" position didn't work fine here on IE8 (it's DIV 
jumps out on weird spots on screen).



Everton




De: Thiago H. de Paula Figueiredo 
Para: Tapestry users 
Enviadas: Segunda-feira, 14 de Dezembro de 2009 17:28:40
Assunto: Re: Res: Specific CSS files for each browser

Em Mon, 14 Dec 2009 17:23:25 -0200, Everton Agner  
escreveu:

> It's perfect! Thank you! :)

You're welcome!

> What about my other question?
>  Tapestry generated html/css code is fine to run in which IE version?

I guess it's fine even with IE6, but do your own tests with your own CSS files.

--Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
instructor
Owner, software architect and developer, Ars Machina Tecnologia da Informação 
Ltda.
http://www.arsmachina.com.br

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


  

Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

[Tapestry Central] Upcoming Public Training: London and Paris

2009-12-14 Thread Howard
This is a big announcement ... something I've been working on pretty
much since I left Formos. I've partnered up with SkillsMatter to
provide my three-day, hands-on Tapestry training as a public enrollment
course!
This is the exact same course I provide as on-site training, but we'll
be doing it at the SkillsMatter offices in London on February 10th, and
then in Paris on the 15th.
This is a big experiment for me and for SkillsMatter in terms of
growing the size of the Tapestry community. In fact, SkillsMatter has
really upped the ante here by offering 2-for-1 on the London
training ... that's a great way to kick things off!
I can't emphasize enough what a great opportunity this is for people to
get accelerated Tapestry training at a discount (even before factoring
in the 2-for-1 offer). I'm really looking forward to bringing many new
developers into the fold!
In addition, there will be a special, free evening event at each
location. Details on that to follow. I look forward to meeting even
more of you there!

--
Posted By Howard to Tapestry Central at 12/14/2009 11:19:00 AM

Re: Res: Specific CSS files for each browser

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 17:23:25 -0200, Everton Agner  
 escreveu:



It's perfect! Thank you! :)


You're welcome!


What about my other question?
 Tapestry generated html/css code is fine to run in which IE version?


I guess it's fine even with IE6, but do your own tests with your own CSS  
files.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Res: Specific CSS files for each browser

2009-12-14 Thread Everton Agner
It's perfect! Thank you! :)

What about my other question?

 Tapestry generated html/css code is fine to run in which IE version?


Thanks!

Everton





De: Thiago H. de Paula Figueiredo 
Para: Tapestry users 
Enviadas: Segunda-feira, 14 de Dezembro de 2009 16:45:52
Assunto: Re: Specific CSS files for each browser

Em Mon, 14 Dec 2009 16:39:31 -0200, Everton Agner  
escreveu:

> Hi,

Hi!

> I'm having problems with tapestry generated html/css code (plus my html/css 
> layout), and I want to fix it for each browser issue...
> There is any way I can make the @IncludeStylesheet value Dynamic?

No, but you can @Inject RenderSupport and include CSS programatically in your 
template component. ;)

--Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
instructor
Owner, software architect and developer, Ars Machina Tecnologia da Informação 
Ltda.
http://www.arsmachina.com.br

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


  

Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 17:05:03 -0200, Piero Sartini   
escreveu:



That's what I meant with re-inventing the wheel ;-)


You're right. :)


There are already lots of working implementations of JavaEE
persistence but every single web framework needs to build one
implementation of its own, simulating the specification. Maybe I am
the only one, but I find this is lost developer power that should be
used to make the web parts of these frameworks better...


Maybe we could use some light EJB 3.x implementation integrated with  
Tapestry-IoC (EJB-defined beans injectable as Tapestry-IoC services). This  
is something that will be done eventually.
I've never used EJB, so I don't know what's the necessary effort to do  
that.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Piero Sartini
> I would say that Tapestry-IoC is not able to handle JPA fully
> (@PersistenceContext) now, but someone can step up and implement this. :)

That's what I meant with re-inventing the wheel ;-)
One time we will have a working tapestry-jpa2 module. But then the
next step is to support more than one persistence context... and I
don't see we will catch up with the specification anytime soon.

There are already lots of working implementations of JavaEE
persistence but every single web framework needs to build one
implementation of its own, simulating the specification. Maybe I am
the only one, but I find this is lost developer power that should be
used to make the web parts of these frameworks better...

 Piero

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



Re: Specific CSS files for each browser

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 16:39:31 -0200, Everton Agner  
 escreveu:



Hi,


Hi!

I'm having problems with tapestry generated html/css code (plus my  
html/css layout), and I want to fix it for each browser issue...

There is any way I can make the @IncludeStylesheet value Dynamic?


No, but you can @Inject RenderSupport and include CSS programatically in  
your template component. ;)


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 16:32:03 -0200, Piero Sartini   
escreveu:



Struts2, Wicket and many others do have the same problem. All of them
need to reinvent the wheel when it comes to persistence... tapestry
did the best job imho, but is not able to use JPA instead of the
hibernate APIs.


I would say that Tapestry-IoC is not able to handle JPA fully  
(@PersistenceContext) now, but someone can step up and implement this. :)


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Specific CSS files for each browser

2009-12-14 Thread Everton Agner
Hi,

I'm having problems with tapestry generated html/css code (plus my html/css 
layout), and I want to fix it for each browser issue...

There is any way I can make the @IncludeStylesheet value Dynamic? So I can look 
for the Browser's request info and refer the correct CSS file?

Or... There is any other elegant way I can do that?

And finally... Tapestry generated html/css code is fine to run in which IE 
version?

Thanks!

Everton



  

Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Piero Sartini
>  For both JPA/Hibernate, you have two ways to go:
>
>    1. Container-Managed EntityManagers and transactions.
>
> By this I mean that you're using @PersistenceContext and such in your classes 
> so that your web application container (i.e. GlassFish) manages the
> EntityManagers and the transactions. The Tapestry jumpstart uses this 
> approach.

It would be really great if this possibility would be available.
Unfortunately, @PersistenceContext does not work in Tapestry pages or
services. This whole JavaEE DI stuff is only available within servlets
or EJBs. That's why tapestry-jpa is neccessary.

Some time ago people said it is better to not depend on the servlet
api. They argumented it's bad if your controller classes need to
extend some base classes. Frameworks ignored the specification and now
they do not get all the great stuff for free that gets better and
better with each release of JavaEE.

Struts2, Wicket and many others do have the same problem. All of them
need to reinvent the wheel when it comes to persistence... tapestry
did the best job imho, but is not able to use JPA instead of the
hibernate APIs. That's where tapestry-jpa tries to help..


 Piero

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



Re: Tapestry 5 and Selenium

2009-12-14 Thread Robert Zeigler

//input[contains(@id,'mpo')]

Cheers,

Robert

On Dec 14, 2009, at 12/1411:41 AM , Ville Virtanen wrote:



Yep, that's what I was afraid of.

I don't have anything to base my opinion to, but I have a feeling  
that the
tests will be really easily broken if and when someone decides to  
change the

page layout etc.

This of course is not related to T5 at any level, but rather common  
problem.
And that's the only thing afaik that is holding us back from making  
more
business minded consultants to make n' bake their own tests. Well,  
that was
the dream anyway.. ;) (I suppose that given the nature of the best  
tools
today you have to be somewhat technology-aware to actually make  
meaning full

tests.)

- Ville


Howard Lewis Ship wrote:


Identify the fields using XPath instead of id.

On Sun, Dec 13, 2009 at 11:05 PM, Ville Virtanen
 wrote:


Hi,

I've googled around but couldn't find solution for this one. The  
problem

is
that we have to test a form that is loaded using progressive display
which
makes all the ids to be generated for each request.

Now, how can I use selenium.type to locate the correct input, when  
the

input
name changes like this:

request one: mpo-1258bc89493_0
request two: mpo-1258bcae418_0
request three: mpo-1258dfea345_0

Has anyone solved this?

 - Ville
--
View this message in context:
http://old.nabble.com/Tapestry-5-and-Selenium-tp26773754p26773754.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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






--
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me  
to

learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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





--
View this message in context: 
http://old.nabble.com/Tapestry-5-and-Selenium-tp26773754p26779936.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



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



Re: Tapestry 5 and Selenium

2009-12-14 Thread Ville Virtanen

Yep, that's what I was afraid of.

I don't have anything to base my opinion to, but I have a feeling that the
tests will be really easily broken if and when someone decides to change the
page layout etc.

This of course is not related to T5 at any level, but rather common problem.
And that's the only thing afaik that is holding us back from making more
business minded consultants to make n' bake their own tests. Well, that was
the dream anyway.. ;) (I suppose that given the nature of the best tools
today you have to be somewhat technology-aware to actually make meaning full
tests.)

 - Ville


Howard Lewis Ship wrote:
> 
> Identify the fields using XPath instead of id.
> 
> On Sun, Dec 13, 2009 at 11:05 PM, Ville Virtanen
>  wrote:
>>
>> Hi,
>>
>> I've googled around but couldn't find solution for this one. The problem
>> is
>> that we have to test a form that is loaded using progressive display
>> which
>> makes all the ids to be generated for each request.
>>
>> Now, how can I use selenium.type to locate the correct input, when the
>> input
>> name changes like this:
>>
>> request one: mpo-1258bc89493_0
>> request two: mpo-1258bcae418_0
>> request three: mpo-1258dfea345_0
>>
>> Has anyone solved this?
>>
>>  - Ville
>> --
>> View this message in context:
>> http://old.nabble.com/Tapestry-5-and-Selenium-tp26773754p26773754.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Tapestry-5-and-Selenium-tp26773754p26779936.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Pierce T. Wetter III

On Dec 14, 2009, at 2:55 AM, Alessandro Bottoni wrote:

> Hi All,
> I'm looking at the alternatives that are available for building the
> persistence layer of a application in Tapestry 5 and I would be happy to
> hear your opinion about a couple of topics:
> 
> 1) I see that there is a support library for JPA and JPA2
> (http://kenai.com/projects/tapestry-jpa) but the description page at
> Kenai says that the project was started on september 2009 so I wonder:
> Is this library already mature and usable, even for production?

  The project was started then, but piero had been using his library in 
production for while. 

  Neither tapestry-jpa or taptestry-hibernate are a lot of code. Tapestry-jpa 
comes in two flavors. All the work is being done on tapestry-jpa2, which is 
using the new stuff in JPA2 to make tapestry-jpa2 mostly feature complete with 
tapestry-hibernate in terms of having EntityValueEncoders and a GridDataSource. 

  So:

   tapestry-jpa: Stable, not going to change, uses JPA 1.0

   tapestry-jpa2: Slightly in flux. Has some new stuff which uses JPA 2.0, 
which is the only way to build some of the things that tapestry-hibernate 
provided. It wasn't working with EclipseLink a while back due to what looked 
liked a bug in EclipseLink-2.0-SNAPSHOT, but I haven't tried it recently. It's 
working ok for me using Hibernate-3.5.0-SNAPSHOT as my JPA persistence 
provider. 

> 
> 2) Is it better to use JPA/JPA2 or Hibernate3 with Tapestry 5? Why?
> (I would probably stick with Hibernate but I'm open to suggestions.)

  I'm kind of a noob, even though I'm one of the people working on 
tapestry-jpa. 

  Here's my opinion, which may be partially misinformed, hopefully people will 
correct me as necessary.

  For both JPA/Hibernate, you have two ways to go:

1. Container-Managed EntityManagers and transactions.

By this I mean that you're using @PersistenceContext and such in your classes 
so that your web application container (i.e. GlassFish) manages the 
EntityManagers and the transactions. The Tapestry jumpstart uses this approach. 

   Advantages: 
You can access more than one persistence unit.
Possibly the Container can do smart stuff like EntityManager pools?
Transaction stuff happens automatically and mysteriously for you. 
Very much standardized.


   Disadvantages:
No EntityValueEncoder that "remembers" entities in the session by just 
remembering their primary key. (Though you could make one easy enough I 
suspect). 
No GridDataSource 

2. Tapestry-Managed 

2a. tapestry-hibernate
2b. tapestry-jpa

 In this case, you're using @Inject to inject Sessions/EntityManagers as 
needed. You annotate methods with @CommitAfter when you want transactions 
committed. 

   Advantages:
Because you tell Tapestry up front about your single database 
connection, it can build EntityValueEncoder and GridDataSources that can pull 
in your objects as necessary. 

   Disadvantages:
You can only use one database connection. 
You have to be more explicit about what does what in your application. 
You'll have to do one thing for Tapestry, one thing for standalone 
code. 

  Summary:
You can just use the JPA annotations as is with Tapestry, and the 
container does the work. 

If you want, you can use tapestry-jpa and tapestry-hibernate. They have 
a few more features you might find useful, but they lock you into one database 
connection. Then the Tapestry container is doing the work instead. 


 Pierce

The boundaries of my ignorance:

  While I'm relatively new to Tapestry/JPA/Hibernate, I've been a WebObjects 
guy for 12+ years now. I'm just now moving into T/J/H because in my opinion, 
its just now that the existing tools have passed WebObjects which figured out 
most of these problems years ago. It's just that WO is getting stale, and the 
containers have gotten better such that its now really obvious that 
GlassFish/Tapestry/JPA is the best technology out there. 

  But its all relatively new to me. I started working on tapestry-jpa2 because 
it seemed to me that it was the best way to integrate JPA with Tapestry. Now 
I'm not so sure that cloning tapestry-hibernate was the right approach. 
Tapestry-hibernate is an IoC provider to build Hibernate sessions as needed, 
but the JPA guys already thought of this issue, so why not use the IoC stuff 
built into the container?

 That is, I'm starting to think that the existing @PersistenceContext stuff is 
preferable to @Inject because its more flexible. So what makes more sense is to 
implement JPAGridDataSource as something that uses the JPA annotations instead, 
but to do that I have to understand the JPA/Container IOC vs. the Tapestry IOC 
a bit better, because one problem with @PersistenceContext is that it takes a 
static string for the name to inject. So JPAGridDataSource would have to be an 
abstract superclass and you would then h

Re: Tapestry 5 and Selenium

2009-12-14 Thread Howard Lewis Ship
Identify the fields using XPath instead of id.

On Sun, Dec 13, 2009 at 11:05 PM, Ville Virtanen
 wrote:
>
> Hi,
>
> I've googled around but couldn't find solution for this one. The problem is
> that we have to test a form that is loaded using progressive display which
> makes all the ids to be generated for each request.
>
> Now, how can I use selenium.type to locate the correct input, when the input
> name changes like this:
>
> request one: mpo-1258bc89493_0
> request two: mpo-1258bcae418_0
> request three: mpo-1258dfea345_0
>
> Has anyone solved this?
>
>  - Ville
> --
> View this message in context: 
> http://old.nabble.com/Tapestry-5-and-Selenium-tp26773754p26773754.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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



Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread marioosh.net



Olle Hallin-2 wrote:
> 
> I forgot to paste in the JavaDocs link:
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/annotations/OnEvent.html
> 

Yes, I know this annotation but...
i think it doesn't work for events like: mouseover, mouseout, change
(textfield)...
http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/EventConstants.html


-- 
View this message in context: 
http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4164188.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread Olle Hallin
I forgot to paste in the JavaDocs link:

http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/annotations/OnEvent.html

Olle Hallin
Senior Java Developer and Architect
olle.hal...@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin



2009/12/14 Olle Hallin 

> It is.
>
> Add this to your page/component class:
>
>   @OnEvent @Log public void onEvent() {}
>
> and watch the log file for the stream of events that are fired against this
> (catch-all) event handler.
>
> Olle Hallin
> Senior Java Developer and Architect
> olle.hal...@crisp.se
> www.crisp.se
> http://www.linkedin.com/in/ollehallin
>
>
>
> 2009/12/14 marioosh.net 
>
>
>>
>> Inge Solvoll wrote:
>> >
>> > Check out this one!
>> >
>> >
>> http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
>> >
>>
>> Thanks:)
>> But... I see, that is a addition to tapestry. Why is not in native
>> Tapestry
>> 5 ? :(
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4163622.html
>> Sent from the Tapestry Users mailing list archive at Nabble.com.
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>


Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread Olle Hallin
It is.

Add this to your page/component class:

  @OnEvent @Log public void onEvent() {}

and watch the log file for the stream of events that are fired against this
(catch-all) event handler.

Olle Hallin
Senior Java Developer and Architect
olle.hal...@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin



2009/12/14 marioosh.net 

>
>
> Inge Solvoll wrote:
> >
> > Check out this one!
> >
> >
> http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
> >
>
> Thanks:)
> But... I see, that is a addition to tapestry. Why is not in native Tapestry
> 5 ? :(
>
> --
> View this message in context:
> http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4163622.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Tapestry 5, JPA and Hibernate

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 07:55:21 -0200, Alessandro Bottoni  
 escreveu:



Hi All,


Hi!


3) In his Jumpstart's FAQ, Geoff Callender says:

"Why did the Data Access Object pattern ever exist? As I recall it had
two purposes: to abstract away the data sources, and to hide the
implementation of accessing the data.


I agree!


That is exactly what JPA (Java
Persistence Architecture, also known as EJB3 Persistence) does too. So I
argue that JPA has taken the place of the DAO and there's no need for us
to write our own. JumpStart uses JPA as its DAO."


I disagree. If a DAO exists the abstract away the data source and the  
*implementation of accessing the data*, JPA is one implementation,  
Hibernate is another, purde JDBC is another, etc. What if you want to  
change your persistence to Google's BigTable (low-level API) or HBase or  
MongoDB or DB4O? You have to change business rule code (they use JPA  
directly), and the DAO pattern was created exactly to avoid this kind of  
sistuation.



What do you think about this? Would you use the JPA entity also for
hosting some business logic?


I put in an entity all the logic that can be implemented just by using its  
fields values. Example: if I have an Order entity that has Items, the  
getTotalValue() method is placed in Order. Anything else goes to the  
business logic classes.



Would not this approach represent a net
lost of flexibilty (because of a lack of "loose coupling")?


IMHO, yes.


4) Is there any good tutorial or any good working demo regarding the use
of Hibernate and/or Jpa with Tapestry5? At the moment I'm studying/using
the following tutorials and demos/apps.


http://tapestry.apache.org/tapestry5.1/tapestry-hibernate/userguide.html
http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Re: Custom ordering of fields

2009-12-14 Thread Thiago H. de Paula Figueiredo
Em Mon, 14 Dec 2009 06:45:59 -0200, Inge Solvoll   
escreveu:



Hi!


Hi!

Why don't you use BeanEditor (or BeanEditForm) and handle the fields by  
creating and manipulating a BeanModel and its PropertyModels?


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

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



Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread marioosh.net


Inge Solvoll wrote:
> 
> Check out this one!
> 
> http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
> 

Thanks:)
But... I see, that is a addition to tapestry. Why is not in native Tapestry
5 ? :( 

-- 
View this message in context: 
http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4163622.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



Re: [newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread Inge Solvoll
Check out this one!

http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html

On Mon, Dec 14, 2009 at 11:34 AM, marioosh.net wrote:

> Is something like that:
> http://tapestry.apache.org/tapestry4.1/ajax/EventListener.html
> in Tapestry 5 ?
>
> I can't see @EventListener annotation in Tapesty5.
>
> --
> Pozdrawiam,
> Mariusz
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


[newbie] EventListener in Tapestry 5 ?

2009-12-14 Thread marioosh.net
Is something like that:
http://tapestry.apache.org/tapestry4.1/ajax/EventListener.html
in Tapestry 5 ?

I can't see @EventListener annotation in Tapesty5.

-- 
Pozdrawiam,
Mariusz

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



Tapestry 5, JPA and Hibernate

2009-12-14 Thread Alessandro Bottoni
Hi All,
I'm looking at the alternatives that are available for building the
persistence layer of a application in Tapestry 5 and I would be happy to
hear your opinion about a couple of topics:

1) I see that there is a support library for JPA and JPA2
(http://kenai.com/projects/tapestry-jpa) but the description page at
Kenai says that the project was started on september 2009 so I wonder:
Is this library already mature and usable, even for production?

2) Is it better to use JPA/JPA2 or Hibernate3 with Tapestry 5? Why?
(I would probably stick with Hibernate but I'm open to suggestions.)

3) In his Jumpstart's FAQ, Geoff Callender says:

"Why did the Data Access Object pattern ever exist? As I recall it had
two purposes: to abstract away the data sources, and to hide the
implementation of accessing the data. That is exactly what JPA (Java
Persistence Architecture, also known as EJB3 Persistence) does too. So I
argue that JPA has taken the place of the DAO and there's no need for us
to write our own. JumpStart uses JPA as its DAO."

(see: http://jumpstart.doublenegative.com.au/faq.html)

What do you think about this? Would you use the JPA entity also for
hosting some business logic? Would not this approach represent a net
lost of flexibilty (because of a lack of "loose coupling")?

4) Is there any good tutorial or any good working demo regarding the use
of Hibernate and/or Jpa with Tapestry5? At the moment I'm studying/using
the following tutorials and demos/apps.

a) HLS "quickstart" Maven archetype and "quickstart" tutorial at
http://tapestry.apache.org/ . (This does not cover any persistence topic
at all).
b) "Tapestry for non believers"
(http://www.infoq.com/articles/tapestry5-intro) (No persistence/ORM
covering)
c) AppFuse 2.1 (http://appfuse.org/display/APF/Home) (very good
"example" - covering persistence, security and a lot of other topics -
but also quite large and complex)
d) Tapestry Jumpstart (http://jumpstart.doublenegative.com.au/) (very
good but not covering Hibernate/JPA)

Is there anything else around worth mentioning?

TIA
-- 

Alessandro Bottoni
Website: http://www.alessandrobottoni.it/

"Beauty is a form of genius - is higher, indeed, than genius, as it
needs no explanation."
 -- Oscar Wilde


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

Re: Custom ordering of fields

2009-12-14 Thread Inge Solvoll
One more thing

I managed to solve this by parsing the DOM in afterRender and moving the
elements around there. But I don't find this approach very attractive, and
would like to find a way to do it with blocks.

On Mon, Dec 14, 2009 at 9:45 AM, Inge Solvoll wrote:

> Hi!
>
> In Struts, I implemented a way to let the customer decide the ordering of
> form fields. It is done by specifying a list of keywords that each identify
> a part of the form (most often a field) to include. These keywords are put
> in a comma separated configuration string, that looks something like this:
>
> firstName,lastName,address,phoneNumber,zip,city
>
> I implemented it in struts by putting each form section inside a bean with
> id=, defining but not rendering the content.
> Then I put a loop at the bottom that goes through the keywords and renders
> the bean with the current keyword. The content then appears in the order
> specified in the configuration. This approach works very well for us, we are
> able to easily customize our forms by reordering, adding and removing fields
> in a rather transparent way. It also works nicely for data output, where
> content needs to be printed in a specific order, sometimes leaving something
> out.
>
> I've tried to implement this in T5, but it is one of the few things we
> haven't yet managed to figure out. The obvious choice is to use blocks,
> which seems almost equivalent to bean:define in struts. But there is a
> catch: Our app has support for dynamic form fields. Meaning that our
> customers can "build" parts of their forms themselves. This means that these
> "custom fields" is rendered by retrieving information about these fields
> from our database, and looping over the info in the tml, creating the
> markup.
>
> I tried doing this, but generated ids for blocks isn't allowed:
>
> {t:block id="${currentCustomFieldKey}">
>   {t:label for="currentCustomField"}
>   {input type="text" t:id="currentCustomField"
> value="currentCustomField.value"}
> {/t:block}
>
> I then tried to do this:
>
> {{t:block t:id="customField">}
>
> hoping that the t:id part would make T5 generate blocks named
> "customField", "customField_0", "customField_1". But when I do a lookup on
> these blocks in the page class, I only find the "customField" one,
> "customField_0" and "customField_1" are null.
>
> Does this description make sense to you, do you understand my problem and
> what I'm trying to do? Some of you (me included) would probably say that it
> seems a bit overkill to have forms that is customizable in 2 ways like I'm
> describing here. The latter one could probably be left out, it was created
> before we got the other idea. But short term, we have to keep it this way.
> But I would really like to migrate the pages using the system to T5, I don't
> want to wait for the bigger refactoring that may never happen.
>
> If anyone is still reading, I would LOVE some input :)
>
> Inge
>


Custom ordering of fields

2009-12-14 Thread Inge Solvoll
Hi!

In Struts, I implemented a way to let the customer decide the ordering of
form fields. It is done by specifying a list of keywords that each identify
a part of the form (most often a field) to include. These keywords are put
in a comma separated configuration string, that looks something like this:

firstName,lastName,address,phoneNumber,zip,city

I implemented it in struts by putting each form section inside a bean with
id=, defining but not rendering the content.
Then I put a loop at the bottom that goes through the keywords and renders
the bean with the current keyword. The content then appears in the order
specified in the configuration. This approach works very well for us, we are
able to easily customize our forms by reordering, adding and removing fields
in a rather transparent way. It also works nicely for data output, where
content needs to be printed in a specific order, sometimes leaving something
out.

I've tried to implement this in T5, but it is one of the few things we
haven't yet managed to figure out. The obvious choice is to use blocks,
which seems almost equivalent to bean:define in struts. But there is a
catch: Our app has support for dynamic form fields. Meaning that our
customers can "build" parts of their forms themselves. This means that these
"custom fields" is rendered by retrieving information about these fields
from our database, and looping over the info in the tml, creating the
markup.

I tried doing this, but generated ids for blocks isn't allowed:

{t:block id="${currentCustomFieldKey}">
  {t:label for="currentCustomField"}
  {input type="text" t:id="currentCustomField"
value="currentCustomField.value"}
{/t:block}

I then tried to do this:

{{t:block t:id="customField">}

hoping that the t:id part would make T5 generate blocks named "customField",
"customField_0", "customField_1". But when I do a lookup on these blocks in
the page class, I only find the "customField" one, "customField_0" and
"customField_1" are null.

Does this description make sense to you, do you understand my problem and
what I'm trying to do? Some of you (me included) would probably say that it
seems a bit overkill to have forms that is customizable in 2 ways like I'm
describing here. The latter one could probably be left out, it was created
before we got the other idea. But short term, we have to keep it this way.
But I would really like to migrate the pages using the system to T5, I don't
want to wait for the bigger refactoring that may never happen.

If anyone is still reading, I would LOVE some input :)

Inge