Re: onActivate() called twice

2009-03-28 Thread Davor Miku
First, all images urls in DB are relative, but I'll change this.

Second, what if I use some js plugin (i.e. for jQuery) witch uses relative
links (like ThickBox, fixed it).

Third, if you have any source of forum, blog ,etc it means if some user
enter relative link
in his post your app is knocked down.

Fourth, its seems little strange to ban something like relative links.

Anyway, why is this happening?  Is Tapestry using ../ for some sort of
dispaching between components?


On Fri, Mar 27, 2009 at 9:59 AM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Thu, Mar 26, 2009 at 5:02 PM, Davor Miku davorm...@gmail.com wrote:
  I know that, but I can't use it.

 Why not?

  I there any other way?

 Besides using assets and absolute URLs, I don't know.

 --
 Thiago

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




Re: onActivate() called twice

2009-03-27 Thread Thiago H. de Paula Figueiredo
On Thu, Mar 26, 2009 at 5:02 PM, Davor Miku davorm...@gmail.com wrote:
 I know that, but I can't use it.

Why not?

 I there any other way?

Besides using assets and absolute URLs, I don't know.

-- 
Thiago

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



onActivate() called twice

2009-03-26 Thread Davor Miku
I have onActivate(String name) called twice.

When called second time name=images.

I believe this is because there are some relative links. There is no way to
make all URLs absolute.

Is there any way to override this multiple calling?

Like telling Tapestry not to process anything from certain directory
(images) ?

Thanks in advance.


Re: onActivate() called twice

2009-03-26 Thread Thiago H. de Paula Figueiredo
Em Thu, 26 Mar 2009 15:49:11 -0300, Davor Miku davorm...@gmail.com  
escreveu:



I have onActivate(String name) called twice.
When called second time name=images.
I believe this is because there are some relative links.


Use src=${asset:context:images/image.jpg} instead of  
src=images/image.jpg.


--
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



Re: onActivate() called twice

2009-03-26 Thread Davor Miku
I know that, but I can't use it.

I there any other way?

On Thu, Mar 26, 2009 at 3:38 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 Em Thu, 26 Mar 2009 15:49:11 -0300, Davor Miku davorm...@gmail.com
 escreveu:

  I have onActivate(String name) called twice.
 When called second time name=images.
 I believe this is because there are some relative links.


 Use src=${asset:context:images/image.jpg} instead of
 src=images/image.jpg.

 --
 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




T5: onActivate called twice

2009-03-25 Thread Peter Kanze
Hello
I have a pagelink that point to this /products/computer/5

In my Products.java I have two onActivate methods. See below.
When I click the pageLink I can see that both onActivate are called.
Because this is printed to the output console:

onActivate(String categoryName, int pageNr)
onActivate: (String categoryName)

Can somebody explain this?
I would expect only public void onActivate(String categoryName, int pageNr)
to be called, because the context has 2 parameters.

greetz,
Peter


public void onActivate(String categoryName) {
System.out.println(onActivate: (String categoryName));
}
public void onActivate(String categoryName, int pageNr) {
System.out.println(onActivate(String categoryName, int pageNr));
}


RE: T5: onActivate called twice

2009-03-25 Thread Blower, Andy
Taken from http://tapestry.apache.org/tapestry5.1/guide/event.html and should 
answer your question I think.


Multiple Method Matches

In some cases, you may have multiple event methods match a single event.

The order is as follows:

* Base class methods before sub-class methods.
* Matching methods within a class in alphabetical order.
* For a single method name with multiple overrides, by number of 
parameters, descending.

There's only rare cases where it makes sense for more than one method to handle 
an event.

When a sub-class overrides an event handler method of a base class, the event 
handler method is only invoked once, along with any other base class methods. 
The subclass can change the implementation of the base class method via an 
override, but can't change the timing of when that method is invoked. See 
TAPESTRY-2311.


 -Original Message-
 From: Peter Kanze [mailto:peterka...@gmail.com]
 Sent: 25 March 2009 11:11
 To: Tapestry users
 Subject: T5: onActivate called twice
 
 Hello
 I have a pagelink that point to this /products/computer/5
 
 In my Products.java I have two onActivate methods. See below.
 When I click the pageLink I can see that both onActivate are called.
 Because this is printed to the output console:
 
 onActivate(String categoryName, int pageNr)
 onActivate: (String categoryName)
 
 Can somebody explain this?
 I would expect only public void onActivate(String categoryName, int
 pageNr)
 to be called, because the context has 2 parameters.
 
 greetz,
 Peter
 
 
 public void onActivate(String categoryName) {
 System.out.println(onActivate: (String categoryName));
 }
 public void onActivate(String categoryName, int pageNr) {
 System.out.println(onActivate(String categoryName, int pageNr));
 }


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



Re: T5: onActivate called twice

2009-03-25 Thread Thiago H. de Paula Figueiredo
As Andy already pointed, this is normal Tapestry behaviour.
When you have more than onActivate() method, I recommend the use of a
single method receiving an EventContext
(http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/EventContext.html):

onActivate(EventContext event) {

if (event.getCount() == 1) {
String categoryName = event.get(String.class, 0);
}
if (event.getCount() == 2) {
String categoryName = event.get(String.class, 0);
int pageNumber = event.get(Integer.class, 1);
}

}

-- 
Thiago

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



Re: T5: onActivate called twice

2009-03-25 Thread Robert Zeigler
Already pointed out that this is expected. But you can bypass this  
behavior.
Make your two-parameter method return true on successful processing;  
then your 1-parameter method won't be called.


Robert

On Mar 25, 2009, at 3/256:10 AM , Peter Kanze wrote:


Hello
I have a pagelink that point to this /products/computer/5

In my Products.java I have two onActivate methods. See below.
When I click the pageLink I can see that both onActivate are called.
Because this is printed to the output console:

onActivate(String categoryName, int pageNr)
onActivate: (String categoryName)

Can somebody explain this?
I would expect only public void onActivate(String categoryName, int  
pageNr)

to be called, because the context has 2 parameters.

greetz,
Peter


public void onActivate(String categoryName) {
System.out.println(onActivate: (String categoryName));
}
public void onActivate(String categoryName, int pageNr) {
System.out.println(onActivate(String categoryName, int pageNr));
}



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



t5: onActivate called twice

2009-02-17 Thread Angelo Chen

Hi,

I have following code, onActivate was called correctly 1st time, but it will
be called again during the rendering and obj[0] has 'images', obj[1]
has 'loading.gif', I do provide a onPassivate, any idea? thanks

   private Object[] _objs;

   @CommitAfter
   public Object onActivate(Object[] obj) {
   _objs = obj;
if (_objs.length  0) {
String id1 = (String) _obj[0];
String id2 = (String) _obj[1];
...
return null
} else return Other.class;
}

public Object[] onPassivate() {
return _objs;
}
 
-- 
View this message in context: 
http://www.nabble.com/t5%3A-onActivate-called-twice-tp22053148p22053148.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: t5: onActivate called twice

2009-02-17 Thread Angelo Chen

btw, it is 5.0.18.


Angelo Chen wrote:
 
 Hi,
 
  
 

-- 
View this message in context: 
http://www.nabble.com/t5%3A-onActivate-called-twice-tp22053148p22053292.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: onActivate called twice

2009-02-17 Thread dhning

You mean in rendering phase, onActivate is called twice? It is always called 
only one time in my experience.
I am interested in whether you called this page onActivate from other page?

DH


- Original Message - 
From: Angelo Chen angelochen...@yahoo.com.hk
To: users@tapestry.apache.org
Sent: Tuesday, February 17, 2009 5:02 PM
Subject: t5: onActivate called twice


 
 Hi,
 
 I have following code, onActivate was called correctly 1st time, but it will
 be called again during the rendering and obj[0] has 'images', obj[1]
 has 'loading.gif', I do provide a onPassivate, any idea? thanks
 
   private Object[] _objs;
 
   @CommitAfter
   public Object onActivate(Object[] obj) {
   _objs = obj;
 if (_objs.length  0) {
 String id1 = (String) _obj[0];
 String id2 = (String) _obj[1];
 ...
 return null
 } else return Other.class;
 }
 
 public Object[] onPassivate() {
return _objs;
}
 
 -- 
 View this message in context: 
 http://www.nabble.com/t5%3A-onActivate-called-twice-tp22053148p22053148.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: t5: onActivate called twice

2009-02-17 Thread Thiago H. de Paula Figueiredo
Most probably you're including images in your page using relative
paths. Use ${asset:context/images/loading.gif} instead and the problem
goes away. ;)

By the way, use EventContext instead of Object[] as the parameter of
your onActivate method. ;)

-- 
Thiago

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



Re: t5: onActivate called twice

2009-02-17 Thread Angelo Chen

Hi,

You are correct, in one of my javascript it has a ../images/.., i don't
know why it got called, in that particular page, there is no reference to
that js, commenting it out fixes the problem, but this does bring up another
question, how to put asset:context in a javascript?

//var tb_pathToImage = ../images/loading.gif;

// var tb_pathToImage = ${asset:context/images/loading.gif};  // this
does not work

what is event context? something like this:
Object onActivate(String s1, String s2)
how to write a matching onPassivate for this?

Thanks,

Angelo



Thiago H. de Paula Figueiredo wrote:
 
 Most probably you're including images in your page using relative
 paths. Use ${asset:context/images/loading.gif} instead and the problem
 goes away. ;)
 
 By the way, use EventContext instead of Object[] as the parameter of
 your onActivate method. ;)
 
 -- 
 Thiago
 
 -
 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://www.nabble.com/t5%3A-onActivate-called-twice-tp22053148p22056296.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: t5: onActivate called twice

2009-02-17 Thread Thiago H. de Paula Figueiredo
On Tue, Feb 17, 2009 at 9:30 AM, Angelo Chen angelochen...@yahoo.com.hk wrote:
 You are correct, in one of my javascript it has a ../images/.., i don't
 know why it got called, in that particular page, there is no reference to
 that js, commenting it out fixes the problem, but this does bring up another
 question, how to put asset:context in a javascript?

One of the options is generating this piece of Javascript in a page or
component template. The other is using absolute URLs.

 what is event context? something like this:

EventContext is an interface from Tapestry:
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/EventContext.html.
You can use it in any event handler method:

Object onActivate(EventContext context) {
 if (context.getCount() == 0) {
;
 }
}

 how to write a matching onPassivate for this?

Your onPassivate method can return an Object[] or a List.

-- 
Thiago

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



Re: t5: onActivate called twice

2009-02-17 Thread Angelo Chen

Hi Thiago,

Thanks for the tip, never knew there is this EventContext, is following
onPassivate correct:

private EventContext ec;

public Object onActivate(EventContext obj) {ec = obj;}

public EventContext onPassivate() { return ec; }

What's the advantage of using EventContext compared to Object[], I know it
is neat, any other reason?

Thanks,

Angelo



Thiago H. de Paula Figueiredo wrote:
 
 Most probably you're including images in your page using relative
 paths. Use ${asset:context/images/loading.gif} instead and the problem
 goes away. ;)
 
 By the way, use EventContext instead of Object[] as the parameter of
 your onActivate method. ;)
 
 -- 
 Thiago
 
 -
 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://www.nabble.com/t5%3A-onActivate-called-twice-tp22053148p22057115.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: t5: onActivate called twice

2009-02-17 Thread Thiago H. de Paula Figueiredo
On Tue, Feb 17, 2009 at 10:16 AM, Angelo Chen
angelochen...@yahoo.com.hk wrote:

 Hi Thiago,

Hi, Angelo!


 Thanks for the tip, never knew there is this EventContext, is following
 onPassivate correct:

You cannot return an EventContext in the onPassivate method. You don't
even need to return the same type you received in onActivate() in
onPassivate(). If you want to return more than one paramenter in
onPassivate(), return a List or an Object[].

 What's the advantage of using EventContext compared to Object[], I know it
 is neat, any other reason?

It is type safe: take a look at its get() method. It uses the Tapestry
coercion feature to convert the value to the type you want. With an
Object[], all its elements are Strings and you have to do the
conversions yourself.

-- 
Thiago

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



Re: t5: onActivate called twice

2009-02-17 Thread Angelo Chen

Hi Thiago,

I always make sure i have a onPassivate that returns same thing in the
onActivate, now, must be wrong, what is the rule of  thumb on this? why we
need a onPassivate?

Thanks,

Angelo


Thiago H. de Paula Figueiredo wrote:
 
 On Tue, Feb 17, 2009 at 10:16 AM, Angelo Chen
 
 You cannot return an EventContext in the onPassivate method. You don't
 even need to return the same type you received in onActivate() in
 onPassivate(). If you want to return more than one paramenter in
 onPassivate(), return a List or an Object[].
 
 -- 
 Thiago
 
 -
 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://www.nabble.com/t5%3A-onActivate-called-twice-tp22053148p22057321.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: t5: onActivate called twice

2009-02-17 Thread Thiago H. de Paula Figueiredo
On Tue, Feb 17, 2009 at 12:02 PM, Angelo Chen
angelochen...@yahoo.com.hk wrote:

 you need a onPassivate to persist the context on the client side if:

You need an onPassivate() method to tell Tapestry what is the
activation context for a given page. This is needed primarily because
of redirect-after-post, AFAIK, and every time Tapestry needs to
generate a link for a page.

-- 
Thiago

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



Re: t5: onActivate called twice

2009-02-17 Thread Peter Stavrinides
Hi Angelo, 

I am probably over simplifying things, but think of it like this, Activate is 
analogous to a Get request, so is invoked when a page first loads, passivate is 
called after a Post (to ensure the posted page retains those activation 
parameters)... passivate does not correspond to activate in a 1:1 cycle, as 
posts can occur for any number of components / form events.

Cheers,
Peter



- Original Message -
From: Thiago H. de Paula Figueiredo thiag...@gmail.com
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 17 February, 2009 17:06:44 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: t5: onActivate called twice

On Tue, Feb 17, 2009 at 12:02 PM, Angelo Chen
angelochen...@yahoo.com.hk wrote:

 you need a onPassivate to persist the context on the client side if:

You need an onPassivate() method to tell Tapestry what is the
activation context for a given page. This is needed primarily because
of redirect-after-post, AFAIK, and every time Tapestry needs to
generate a link for a page.

-- 
Thiago

-
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



onActivate() called twice when document.write is called in Javascript

2008-11-05 Thread Robert Vojta

Hi all,

onActivate() is called twice on my page when I have following Javascript
code included. When I remove document.write() call, onActivate() is called
once. Any idea how can I solve this?

Sample.tml

...
head
script type=text/javascript
src=${asset:context:/js/styleloader.js}/script
...

styleloader.js

function loadBrowserStyle()
{
   ... handling routines, where specialCSS is filled with proper style
(different style for different browsers)
document.open();
document.write(link rel=stylesheet type='text/css'
href='+specialCSS+' title='externe Styles');
document.close();
}
loadBrowserStyle();

onActivate() is called twice even if I replace link rel=... in
styleloader.js with something like this ...

link href=\${asset:context: + specialCSS + }\ rel=\stylesheet\
type=\text/css\ /

Any idea how can I write to page from Javascript without calling
onActivate() twice?

Regards,
Robert
-- 
View this message in context: 
http://www.nabble.com/onActivate%28%29-called-twice-when-document.write-is-called-in-Javascript-tp20341486p20341486.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: onActivate() called twice when document.write is called in Javascript

2008-11-05 Thread Thiago H. de Paula Figueiredo
Em Wed, 05 Nov 2008 10:16:52 -0300, Robert Vojta [EMAIL PROTECTED]  
escreveu:



onActivate() is called twice on my page when I have following Javascript
code included. When I remove document.write() call, onActivate() is  
called once. Any idea how can I solve this?


Just make sure that every resource (image, JavaScript, CSS, etc) is  
referenced via an absolute URL (i.e. one that begins with a slash):

/js/effects.js
/css/main.css

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

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



Re: onActivate() called twice when document.write is called in Javascript

2008-11-05 Thread Howard Lewis Ship
The first step to diagnosing problems with onActivate() is to check
the web log and see what URLs are coming in, and deduce why.

On Wed, Nov 5, 2008 at 6:45 AM, Thiago H. de Paula Figueiredo
[EMAIL PROTECTED] wrote:
 Em Wed, 05 Nov 2008 10:16:52 -0300, Robert Vojta [EMAIL PROTECTED]
 escreveu:

 onActivate() is called twice on my page when I have following Javascript
 code included. When I remove document.write() call, onActivate() is called
 once. Any idea how can I solve this?

 Just make sure that every resource (image, JavaScript, CSS, etc) is
 referenced via an absolute URL (i.e. one that begins with a slash):
 /js/effects.js
 /css/main.css

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

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





-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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



RE: T5: onActivate() called twice

2008-09-09 Thread Yeeswara Nadapana (HCL Financial Services)


Hi Leon,

I am facing the same problem with the onActivate() method calling twice.
Did you find any solution for this?

Thanks,
Yees.

-Original Message-
From: Leon Derks [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 21, 2008 6:56 PM
To: Tapestry users
Subject: Re: T5: onActivate() called twice

Hi Davor,

Indeed, I have a BasePage that implements the public void onActivate() 
{}method.

In my subpage I also have implemented the public void onActivate() {}.
The code in onActivate() of my subpage is executed twice.

BASEPAGE:
public void onActivate() {
String pageName = resources.getPageName();
breadCrumbHolder.checkBreadCrumbForRemove(pageName);
}

SUBCLASS:
public void onActivate() {
logger.debug(OnActivate );
products = productDAO.findAllByCategory(ProductCategory.Books);
if (logger.isDebugEnabled()) {
logger.debug(Nr of products:  + products.size());
}
}

This is the logging when I acces the page:

[DEBUG] Products OnActivate
[DEBUG] Products Nr of products:: 43
[DEBUG] Products OnActivate
[DEBUG] Products Nr of products:: 43

Leon

Davor Hrg wrote:
 you have to be more specific,

 same OnActivate method will not be called more than once in normal
 circumastances,

 but overriding onActivate from a base class I belive can cause this
...

 some code would be useful.

 Davor Hrg

 On Mon, Apr 21, 2008 at 12:41 PM, Leon Derks [EMAIL PROTECTED]
wrote:

   
 Hi,

 I noticed that my onActivate() is called twice.

 I solved the problem by changing onActivate() into
onActivate(Object[]
 parameters).

 Now it is only called once. But is this the way to do this or is
there a
 better way?

 greetings,
 Leon



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


 

   


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


DISCLAIMER:
---
The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only. 
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates. 
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have 
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and 
attachments please check them for viruses and defect.
---

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



Re: T5: onActivate() called twice

2008-09-09 Thread Howard Lewis Ship
What version of Tapestry?  This was addressed in 5.0.14, I believe, to
ensure that when overriding a base class event handler method, the
method is not invoked twice.

On Mon, Apr 21, 2008 at 6:25 AM, Leon Derks [EMAIL PROTECTED] wrote:
 Hi Davor,

 Indeed, I have a BasePage that implements the public void onActivate()
 {}method.

 In my subpage I also have implemented the public void onActivate() {}.
 The code in onActivate() of my subpage is executed twice.

 BASEPAGE:
 public void onActivate() {
   String pageName = resources.getPageName();
   breadCrumbHolder.checkBreadCrumbForRemove(pageName);
 }

 SUBCLASS:
 public void onActivate() {
   logger.debug(OnActivate );
   products = productDAO.findAllByCategory(ProductCategory.Books);
   if (logger.isDebugEnabled()) {
   logger.debug(Nr of products:  + products.size());
   }
   }

 This is the logging when I acces the page:

 [DEBUG] Products OnActivate
 [DEBUG] Products Nr of products:: 43
 [DEBUG] Products OnActivate
 [DEBUG] Products Nr of products:: 43

 Leon

 Davor Hrg wrote:

 you have to be more specific,

 same OnActivate method will not be called more than once in normal
 circumastances,

 but overriding onActivate from a base class I belive can cause this ...

 some code would be useful.

 Davor Hrg

 On Mon, Apr 21, 2008 at 12:41 PM, Leon Derks [EMAIL PROTECTED]
 wrote:



 Hi,

 I noticed that my onActivate() is called twice.

 I solved the problem by changing onActivate() into onActivate(Object[]
 parameters).

 Now it is only called once. But is this the way to do this or is there a
 better way?

 greetings,
 Leon



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







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





-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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



Re: onActivate called twice when overriding from abstract generic superclass

2008-07-29 Thread Filip S. Adamsen

Hi,

Both you and Thiago are of course right. I just remember Howard saying 
something about this being very difficult to do. Probably has something 
to do with Javassist.


-Filip

On 2008-07-29 05:30, Ivan Dubrov wrote:

Filip S. Adamsen wrote:

Hi,

As far as I know it's very difficult - if not impossible - for 
Tapestry to support generics in method parameters because of the way 
generics are implemented in Java (type erasure).


A lot of type information is still available through reflection. 
Assuming concrete component classes do not have generic parameters (they 
have all super class type parameters fulfilled), all type information 
will be available at runtime. You can’t deduct the “unerased” types from 
the instances, but you can deduct part of it from the classes.


For example, here is my own “TypeOracle” that is used in my code for 
following the property path (finding the “real”, “unerased” type of the 
next property in the property path):


http://nanorm.googlecode.com/svn/trunk/src/main/java/com/google/code/nanorm/internal/introspect/TypeOracle.java 



It just requires a lot of careful work.

For example, here is the deduction steps for base onActivate that could 
be made at runtime:


1) We have SubClass with all types known. We know that base class is 
actually ParameterizedType with raw class “SuperClass” and first actual 
type parameter “Bar” (SubClass.class.getGenericSuperclass()).
2) Looking at the onActivate(E param) method we see that its first 
parameter is some type variable (method.getGenericParameterTypes()).
3) We see that this type variable is equals to the first type variable 
of the “SuperClass” (array SuperClass.getTypeParameters()).
4) Since this first parameter is substituted by “Bar” (see 1)), we can 
deduct that this method has first parameter of type “Bar”.
5) Now we can see that our method onActivate(Bar bar) actually overrides 
base method onActivate(E e) (which at runtime has type onActivate(Foo 
foo). So we don’t need to invoke it.


Something like this.



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



onActivate called twice when overriding from abstract generic superclass

2008-07-28 Thread Moritz Gmelin

Hi,

if I have an abstract superclass of a page that has the abstract  
definition of  onActivate() defined


public abstract SuperClassE extends foo {

public abstract void onActivate(E value);

}

and a subclass

public SubClass Extends SuperClassBar {

 public void onActivate (Bar value) {
System.out.println (Here i am  + value);
}
}

For every request to the page (providing a context object) I can see  
two lines in the log


Here I am null
Here I am instanceofbar

If however I define the onActivate in SuperClass as

public abstract void onActivate (Bar value);

I only see the second log line.

Is that expected behaviour or some bug related to Java Generics and  
Tapestry?


Thanks

Moritz

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



Re: onActivate called twice when overriding from abstract generic superclass

2008-07-28 Thread Thiago H. de Paula Figueiredo
Em Mon, 28 Jul 2008 10:33:46 -0300, Moritz Gmelin [EMAIL PROTECTED]  
escreveu:



public abstract SuperClassE extends foo {
public abstract void onActivate(E value);
}



public SubClass Extends SuperClassBar {

  public void onActivate (Bar value) {
 System.out.println (Here i am  + value);
}


Tapestry 5 does not support generics in method parameters, just fields.  
So, for Tapestry, you're not overriding onActivate, you have two different  
versions of it. It would be awesome if Tapestry supported generics in  
method parameters . . .


Thiago

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



Re: onActivate called twice when overriding from abstract generic superclass

2008-07-28 Thread Filip S. Adamsen

Hi,

As far as I know it's very difficult - if not impossible - for Tapestry 
to support generics in method parameters because of the way generics are 
implemented in Java (type erasure).


-Filip

On 2008-07-28 15:44, Thiago H. de Paula Figueiredo wrote:
Em Mon, 28 Jul 2008 10:33:46 -0300, Moritz Gmelin [EMAIL PROTECTED] 
escreveu:



public abstract SuperClassE extends foo {
public abstract void onActivate(E value);
}



public SubClass Extends SuperClassBar {

  public void onActivate (Bar value) {
 System.out.println (Here i am  + value);
}


Tapestry 5 does not support generics in method parameters, just fields. 
So, for Tapestry, you're not overriding onActivate, you have two 
different versions of it. It would be awesome if Tapestry supported 
generics in method parameters . . .


Thiago


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



Re: onActivate called twice when overriding from abstract generic superclass

2008-07-28 Thread Thiago H. de Paula Figueiredo
Em Mon, 28 Jul 2008 13:13:21 -0300, Filip S. Adamsen [EMAIL PROTECTED]  
escreveu:


As far as I know it's very difficult - if not impossible - for Tapestry  
to support generics in method parameters because of the way generics are  
implemented in Java (type erasure).


Not every type information in generics is lost.
It's possible to get the type parameters of a superclass:

class abstract SuperclassA, B, C {

public Superclass() {
final Type genericSuperclass = 
getClass().getGenericSuperclass();
		final ParameterizedType parameterizedType = ((ParameterizedType)  
genericSuperclass);

final Class? parameterizedType.getActualTypeArguments();
}

public Class[] getActualTypeArguments() {
final Type genericSuperclass = 
getClass().getGenericSuperclass();
		final ParameterizedType parameterizedType = ((ParameterizedType)  
genericSuperclass);

final Class? parameterizedType.getActualTypeArguments();
}
public abstract A getA();

}

class Subclass extends SuperclassString, Integer, Double {

}

For Subclass, getActualTypeArguments() would return a Class array  
containing String.class, Integer.class and Double.class.


I just don't know how this could be sorted out with Javassist, but I think  
there should be some solution. :)


Thiago

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



Re: onActivate called twice when overriding from abstract generic superclass

2008-07-28 Thread Ivan Dubrov

Filip S. Adamsen wrote:

Hi,

As far as I know it's very difficult - if not impossible - for 
Tapestry to support generics in method parameters because of the way 
generics are implemented in Java (type erasure).


A lot of type information is still available through reflection. 
Assuming concrete component classes do not have generic parameters (they 
have all super class type parameters fulfilled), all type information 
will be available at runtime. You can’t deduct the “unerased” types from 
the instances, but you can deduct part of it from the classes.


For example, here is my own “TypeOracle” that is used in my code for 
following the property path (finding the “real”, “unerased” type of the 
next property in the property path):


http://nanorm.googlecode.com/svn/trunk/src/main/java/com/google/code/nanorm/internal/introspect/TypeOracle.java

It just requires a lot of careful work.

For example, here is the deduction steps for base onActivate that could 
be made at runtime:


1) We have SubClass with all types known. We know that base class is 
actually ParameterizedType with raw class “SuperClass” and first actual 
type parameter “Bar” (SubClass.class.getGenericSuperclass()).
2) Looking at the onActivate(E param) method we see that its first 
parameter is some type variable (method.getGenericParameterTypes()).
3) We see that this type variable is equals to the first type variable 
of the “SuperClass” (array SuperClass.getTypeParameters()).
4) Since this first parameter is substituted by “Bar” (see 1)), we can 
deduct that this method has first parameter of type “Bar”.
5) Now we can see that our method onActivate(Bar bar) actually overrides 
base method onActivate(E e) (which at runtime has type onActivate(Foo 
foo). So we don’t need to invoke it.


Something like this.

--
WBR,
Ivan S. Dubrov


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



Re: T5.0.11: onActivate() called twice, more questions

2008-05-12 Thread Tomasz Dziurko
Ok, I found solution, but I still would be grateful if someone could
put some light on this subject:

More investigation showed me that context.length is always +1 greater
than I should expect.
When I printed all elements from context while executing
http://localhost:8607/myApp/start/testmessage

11:59:25,219 [ INFO] Start - TEST LOG
thing in context=textmessage

11:59:25,219 [ INFO] Start - TEST LOG
thing in context=images
thing in context=pic.gif

After looking in my project for pic.gif it appeared that in my tml
file I have remains from default template.

Following line causes all the problems:
img src=images/pic.gif alt=default image /

Now question: How is it possible that this situation might occur?

-- 
Tomasz Dziurko

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



T5.0.11: onActivate() called twice, more questions

2008-05-12 Thread Tomasz Dziurko
Hi.
I read previous posts about problem with onActivate called twice, but
none of answers seems to suit my situation.

Here's the problem:

Abstract base page

public abstract class AbstractTopPage {

private String context[];

public abstract Object performActivation(String[] context);

Object onActivate(EventContext eventContext) {
context = new String[eventContext.getCount()];
for (int i = 0; i  context.length; i++) {
context[i] = eventContext.get(String.class, i);
}

return performActivation(context);

}

}

and real page:

public class Start {

@Override
public Object performActivation(String[] context) {
getLogger().info(TEST LOG);

return null;
}

String onPassivate() {
return testmessage;
}

}

and when I enter page http://localhost:8607/myApp/start/testmessage on
console I get:

11:59:25,219 [ INFO] Start - TEST LOG
11:59:25,919 [ INFO] Start - TEST LOG

so onActivate() is called two times. Anyone maybe could help?


Regards
-- 
Tomasz Dziurko

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



Re: T5.0.11: onActivate() called twice, more questions

2008-05-12 Thread Szemere Szemere
Your images/pic.gif  is relative to the current page url (which includes
your context parameters), so will get caught as a page request by Tapestry.
You should probably use src=${asset:context:images/pic.gif} instead.

Szemere

On Mon, May 12, 2008 at 11:23 AM, Tomasz Dziurko [EMAIL PROTECTED] wrote:

 [...]


 Following line causes all the problems:
 img src=images/pic.gif alt=default image /

 Now question: How is it possible that this situation might occur?

 --
 Tomasz Dziurko



T5: onActivate() called twice

2008-04-21 Thread Leon Derks

Hi,

I noticed that my onActivate() is called twice.

I solved the problem by changing onActivate() into onActivate(Object[] 
parameters).


Now it is only called once. But is this the way to do this or is there a 
better way?


greetings,
Leon



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



Re: T5: onActivate() called twice

2008-04-21 Thread Davor Hrg
you have to be more specific,

same OnActivate method will not be called more than once in normal
circumastances,

but overriding onActivate from a base class I belive can cause this ...

some code would be useful.

Davor Hrg

On Mon, Apr 21, 2008 at 12:41 PM, Leon Derks [EMAIL PROTECTED] wrote:

 Hi,

 I noticed that my onActivate() is called twice.

 I solved the problem by changing onActivate() into onActivate(Object[]
 parameters).

 Now it is only called once. But is this the way to do this or is there a
 better way?

 greetings,
 Leon



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




Re: T5: onActivate() called twice

2008-04-21 Thread Leon Derks

Hi Davor,

Indeed, I have a BasePage that implements the public void onActivate() 
{}method.


In my subpage I also have implemented the public void onActivate() {}.
The code in onActivate() of my subpage is executed twice.

BASEPAGE:
public void onActivate() {
   String pageName = resources.getPageName();
   breadCrumbHolder.checkBreadCrumbForRemove(pageName);
}

SUBCLASS:
public void onActivate() {
   logger.debug(OnActivate );
   products = productDAO.findAllByCategory(ProductCategory.Books);
   if (logger.isDebugEnabled()) {
   logger.debug(Nr of products:  + products.size());
   }
   }

This is the logging when I acces the page:

[DEBUG] Products OnActivate
[DEBUG] Products Nr of products:: 43
[DEBUG] Products OnActivate
[DEBUG] Products Nr of products:: 43

Leon

Davor Hrg wrote:

you have to be more specific,

same OnActivate method will not be called more than once in normal
circumastances,

but overriding onActivate from a base class I belive can cause this ...

some code would be useful.

Davor Hrg

On Mon, Apr 21, 2008 at 12:41 PM, Leon Derks [EMAIL PROTECTED] wrote:

  

Hi,

I noticed that my onActivate() is called twice.

I solved the problem by changing onActivate() into onActivate(Object[]
parameters).

Now it is only called once. But is this the way to do this or is there a
better way?

greetings,
Leon



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





  



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