Re: [T5] debugging in eclipse
On Wed, 26 May 2010 12:40:34 -0300, Dmitry Gusev wrote: No, because there's no field to be set. Not true. If there was no field eclipse wouldn't show it in debugger. I stand corrected. Please file a JIRA about it if you haven't done it yet. It seems like a nice addition to me. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, 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: [T5] debugging in eclipse
On Wed, May 26, 2010 at 16:10, Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > On Wed, 26 May 2010 02:31:34 -0300, Dmitry Gusev > wrote: > > May be during transformation in non-production mode T5 should assign value >> to corresponding field also, not just to conduit? >> > > No, because there's no field to be set. > > Not true. If there was no field eclipse wouldn't show it in debugger. What I mean is add some logic to PropertyConduit implementors to also change fields values they're wrapping. Here's what I did for UnclaimedFieldWorker: .../internal/transform/UnclaimedFieldWorker.java | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/UnclaimedFieldWorker.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/UnclaimedFieldWorker.java index 115c4e9..d2041bb 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/UnclaimedFieldWorker.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/UnclaimedFieldWorker.java @@ -14,6 +14,7 @@ package org.apache.tapestry5.internal.transform; +import java.lang.reflect.Field; import java.lang.reflect.Modifier; import org.apache.tapestry5.ComponentResources; @@ -41,13 +42,15 @@ public final class UnclaimedFieldWorker implements ComponentClassTransformWorker private final InternalComponentResources resources; private Object fieldValue, fieldDefaultValue; +private String fieldName; -private UnclaimedFieldConduit(InternalComponentResources resources, Object fieldDefaultValue) +private UnclaimedFieldConduit(InternalComponentResources resources, Object fieldDefaultValue, TransformField originalField) { this.resources = resources; this.fieldValue = fieldDefaultValue; this.fieldDefaultValue = fieldDefaultValue; +this.fieldName = originalField.getName(); resources.addPageLifecycleListener(new PageLifecycleAdapter() { @@ -70,6 +73,17 @@ public final class UnclaimedFieldWorker implements ComponentClassTransformWorker if (!resources.isLoaded()) fieldDefaultValue = newValue; + +try { +// XXX This code is for debugging purposes only, its very slow +Object component = resources.getComponent(); +Field field = component.getClass().getDeclaredField(fieldName); +field.setAccessible(true); +field.set(component, newValue); +field.setAccessible(false); +} catch (Exception ex) { +// Skip this exception and continue +} } public void reset() @@ -103,7 +117,7 @@ public final class UnclaimedFieldWorker implements ComponentClassTransformWorker field.replaceAccess(provider); } -private ComponentValueProvider createFieldValueConduitProvider(TransformField field) +private ComponentValueProvider createFieldValueConduitProvider(final TransformField field) { final String fieldType = field.getType(); @@ -113,7 +127,7 @@ public final class UnclaimedFieldWorker implements ComponentClassTransformWorker { Object fieldDefaultValue = classCache.defaultValueForType(fieldType); -return new UnclaimedFieldConduit((InternalComponentResources) resources, fieldDefaultValue); +return new UnclaimedFieldConduit((InternalComponentResources) resources, fieldDefaultValue, field); } }; } I think you got the idea. We may also do the same for InternalClassTransformationImpl lines 1694-1695: addToConstructor(String.format(" %s = (%s) (%s).get(%s);", > field.getName(), type.getName(), argReference, > resourcesFieldName)); > by changing the code to also update original field and also for line 668: addNewMethod(writeSig, String.format("%s.set(($w) $1);", > conduitFieldName)); > Of cource we should do this only if T5 runs in non-production mode. What do you think? > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, 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
Re: Res: [T5] debugging in eclipse
On Wed, 26 May 2010 11:21:40 -0300, Everton Agner wrote: What about Inspection Expressions? Do they work? I haven't tried yet (and can't try it now). No, because the field isn't there, being replaced by method invocations. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, 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: [T5] debugging in eclipse
What about Inspection Expressions? Do they work? I haven't tried yet (and can't try it now). - Everton Agner Ramos De: Thiago H. de Paula Figueiredo Para: Tapestry users Enviadas: Quarta-feira, 26 de Maio de 2010 9:10:04 Assunto: Re: [T5] debugging in eclipse On Wed, 26 May 2010 02:31:34 -0300, Dmitry Gusev wrote: > May be during transformation in non-production mode T5 should assign value to > corresponding field also, not just to conduit? No, because there's no field to be set. --Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, 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: [T5] debugging in eclipse
On Wed, 26 May 2010 02:31:34 -0300, Dmitry Gusev wrote: May be during transformation in non-production mode T5 should assign value to corresponding field also, not just to conduit? No, because there's no field to be set. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, 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: [T5] debugging in eclipse
I noticed that also, thats make debugging a hard process. May be during transformation in non-production mode T5 should assign value to corresponding field also, not just to conduit? Its not good to declare realXXX fields in a class while original field not used. On Wed, May 26, 2010 at 06:08, Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > On Tue, 25 May 2010 20:28:44 -0300, Dariusz Majewski < > dariuszmajew...@gmail.com> wrote: > > Hi All, >> > > Hi! > > @Parameter(value="120") >>private int maxWidth; >> >> Now my problem is that when I debug onMyCustomEvent method I can't see the >> real value of maxWidth parameter. >> > > That's Tapestry doing it heavy wizardry: when it loads your component > class, it replaces the @Parameter fields by invocations to methods that were > added to the class. This also happens for many annotations besides > @Parameter. For debugging, just create a variable. Something like > int realMaxWidth = maxWidth; > > realMaxWidth will have the current value of maxWidth, including in the > debugger. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, 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
Re: [T5] debugging in eclipse
On Tue, 25 May 2010 20:28:44 -0300, Dariusz Majewski wrote: Hi All, Hi! @Parameter(value="120") private int maxWidth; Now my problem is that when I debug onMyCustomEvent method I can't see the real value of maxWidth parameter. That's Tapestry doing it heavy wizardry: when it loads your component class, it replaces the @Parameter fields by invocations to methods that were added to the class. This also happens for many annotations besides @Parameter. For debugging, just create a variable. Something like int realMaxWidth = maxWidth; realMaxWidth will have the current value of maxWidth, including in the debugger. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, 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
[T5] debugging in eclipse
Hi All, I'm having problems debugging my tapestry application. I'm using Eclipse 3.5.0 and tapestry 5.2-SNAPSHOT. I have a custom component with parameter @Parameter(value="120") private int maxWidth; which is then set during my component invocation inside page now I have a eventListener in my component let's say sth like this public StreamResponse onMyCustomEvent(){ if(300 > maxWidth){ return new TextStreamResponse(responseRenderer.findContentType(this), "300 > "+maxWidth);// this is never executed } return new TextStreamResponse(responseRenderer.findContentType(this), "everything is OK - "+maxWidth);// } Now my problem is that when I debug onMyCustomEvent method I can't see the real value of maxWidth parameter. Debugger shows me this value as 0 but the response I get from my listener is "everything is OK - 1200". I can see that my component object has a field created by tapestry _$maxWidth$conduit that corresponds to maxWidth and this object has a value field that contains my 1200 value. I'm writing because maybe someone had a similar problem or knows how to setup eclipse to show real value of maxWidth without looking inside _$maxWidth$conduit. The same thing happens to fields inside my pages. I can see their values only by inspecting the conduit but corresponding fields are null. Best regards, Dariusz