Weird, does you Index page extends a base class ? 2010/9/8 Markus Feindler <markus.feind...@gmx.de>
> Sorry to bother you, but Im stuck with a DuplicateMemberException: > Caused by: java.lang.RuntimeException: > javassist.bytecode.DuplicateMemberException: duplicate method: > extractRequestParameters in de.wiv.tapestryportlet2.pages.Index > at > org.apache.tapestry5.internal.services.InternalClassTransformationImpl.addOverrideOfSuperclassMethod(InternalClassTransformationImpl.java:1458) > at > org.apache.tapestry5.internal.services.InternalClassTransformationImpl.findOrOverrideMethod(InternalClassTransformationImpl.java:1412) > at > org.apache.tapestry5.internal.services.InternalClassTransformationImpl.findOverrideOrCreateMethod(InternalClassTransformationImpl.java:1397) > at > org.apache.tapestry5.internal.services.InternalClassTransformationImpl.getOrCreateMethod(InternalClassTransformationImpl.java:1392) > at > org.apache.tapestry5.portlet.services.PortletRequestParameterWorker.transform(PortletRequestParameterWorker.java:48) > at > $ComponentClassTransformWorker_12af2cfc4c4.transform($ComponentClassTransformWorker_12af2cfc4c4.java) > at > $ComponentClassTransformWorker_12af2cfc4c5.transform($ComponentClassTransformWorker_12af2cfc4c5.java) > at > $ComponentClassTransformWorker_12af2cfc4b6.transform($ComponentClassTransformWorker_12af2cfc4b6.java) > at > org.apache.tapestry5.internal.services.ComponentClassTransformerImpl$1.run(ComponentClassTransformerImpl.java:194) > ... 250 more > Caused by: javassist.bytecode.DuplicateMemberException: duplicate method: > extractRequestParameters in de.wiv.tapestryportlet2.pages.Index > at javassist.bytecode.ClassFile.testExistingMethod(ClassFile.java:637) > at javassist.bytecode.ClassFile.addMethod(ClassFile.java:613) > at javassist.CtClassType.addMethod(CtClassType.java:1320) > at > org.apache.tapestry5.internal.services.InternalClassTransformationImpl.addOverrideOfSuperclassMethod(InternalClassTransformationImpl.java:1444) > ... 258 more > > This is my worker: > > public class PortletRequestParameterWorker implements > ComponentClassTransformWorker { > > private final ValueEncoderSource valueEncoderSource; > private final ComponentClassCache classCache; > private final RequestParameterContext requestParameterContext; > private final ComponentSource componentSource; > > public PortletRequestParameterWorker(ValueEncoderSource > valueEncoderSource, > ComponentClassCache classCache, RequestParameterContext > requestParameterContext, > ComponentSource componentSource) { > this.valueEncoderSource = valueEncoderSource; > this.classCache = classCache; > this.requestParameterContext = requestParameterContext; > this.componentSource = componentSource; > } > > public void transform(final ClassTransformation transformation, > MutableComponentModel model) { > > > transformation.addImplementedInterface(RequestParameterExtractor.class); > TransformMethodSignature extractMethod = new > TransformMethodSignature(Modifier.PUBLIC, > "Map<String, String>", "extractRequestParameters", null, > null); > // if (transformation.isDeclaredMethod(extractMethod)) { > // return; > // } > transformation.getOrCreateMethod(extractMethod).addAdvice(new > ComponentMethodAdvice(){ > > public void advise(ComponentMethodInvocation invocation) { > Map<String, String> requestParameters = new > HashMap<String, String>(); > for (TransformField field : > transformation.matchFieldsWithAnnotation(ActivationRequestParameter.class)) > { > String parameterName = getParameterName(field, > field.getAnnotation(ActivationRequestParameter.class)); > Class fieldType = > classCache.forName(field.getType()); > FieldAccess access = field.getAccess(); > ValueEncoder encoder = > valueEncoderSource.getValueEncoder(fieldType); > Object value = > access.read(invocation.getInstance()); > if (value == null) > continue; > String clientValue = encoder.toClient(value); > requestParameters.put(parameterName, clientValue); > } > invocation.overrideResult(requestParameters); > } > > }); > } > > private String getParameterName(TransformField field, > ActivationRequestParameter annotation) > { > if (annotation.value().equals("")) > return field.getName(); > > return annotation.value(); > } > > } > > Any ideas? > > Hi ! >> >> Tapestry 5.2 has a brand new API for class manipulation in worker, you >> have >> to provide the method signature and implement the logic in a >> ComponentMethodAdvice (see PropertyWorker sources to have a simple >> example) >> >> HTH >> >> 2010/9/7 Markus Feindler<markus.feind...@gmx.de> >> >> So, I tried to follow your advice, but I don't see how to add a new >>> method >>> after calling >>> "transformation.addImplementedInterface(MyInterface.class)". >>> The documentation states to use transformation.getOrCreateMethod, but >>> where >>> to define the message body? >>> >>> Actually, >>> >>>> I would implement a ClassTransformation and add it to >>>> contributeComponentClassTransformWorker (see Tapestry Module), This >>>> worker >>>> should add and implement an interface that contains the method to >>>> extract >>>> useful information from the page >>>> >>>> Then in your PageResponseRenderer, you can use ComponentSource to get >>>> the >>>> page instance, cast it to your interface and call the method. >>>> >>>> 2010/9/6 Markus Feindler<markus.feind...@gmx.de> >>>> >>>> Thats the class I discovered earlier at work. >>>> >>>>> Now my question is how to get ClassTransformation and >>>>> MutableComponentModel >>>>> from the Page Object in the PageResponseRenderer? >>>>> >>>>> Thanks for you help/hints. >>>>> >>>>> Regards markus >>>>> >>>>> Hi >>>>> >>>>> Logic is enclosed in ActivationRequestParameterWorker, i think you can >>>>>> adapt >>>>>> this to your needs and extract values. At the moment, I don't see any >>>>>> other >>>>>> way to identify ActivationRequestParameters during link creation. >>>>>> >>>>>> 2010/9/6 Markus Feindler<markus.feind...@gmx.de> >>>>>> >>>>>> i would say you can get them from >>>>>> >>>>>> Request directly >>>>>>> >>>>>>>> This only works for the current request. I need to get the >>>>>>>> parameters, >>>>>>>> >>>>>>>> which will be set for the next request/redirect. It would be >>>>>>> possible >>>>>>> to >>>>>>> write get methods for the ActivationRequestParameters, but that would >>>>>>> not >>>>>>> be >>>>>>> the right way. I need to find out how that is solved internally. >>>>>>> >>>>>>> >>>>>>> Oh sorry, i had mis-read your first message. I didn't get deep into >>>>>>> this >>>>>>> >>>>>>> new >>>>>>> >>>>>>>> feature at the time, but at first glance, i would say you can get >>>>>>>> them >>>>>>>> from >>>>>>>> Request directly. Maybe, you can implement a worker that will be in >>>>>>>> charge >>>>>>>> of implementing an interface that will contain the method that >>>>>>>> return >>>>>>>> the >>>>>>>> values. >>>>>>>> >>>>>>>> I will go deeper to see if there is not a more simple way of doing >>>>>>>> this. >>>>>>>> >>>>>>>> 2010/9/6 Markus Feindler<markus.feind...@gmx.de> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Thats what Im doing right now for the PageActivationContext, but I >>>>>>>> also >>>>>>>> >>>>>>>> need the values for the ActivationRequestParameters (introduced in >>>>>>>>> 5.2: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> http://tapestry.apache.org/tapestry5.2-dev/apidocs/org/apache/tapestry5/annotations/ActivationRequestParameter.html >>>>>>>>> ). >>>>>>>>> >>>>>>>>> Hi >>>>>>>>> >>>>>>>>> >>>>>>>>> So why not passivate the page, see PageActivationContextCollector >>>>>>>>> ? >>>>>>>>> >>>>>>>>> This >>>>>>>>>> is >>>>>>>>>> how it works to create links. >>>>>>>>>> >>>>>>>>>> 2010/9/5 Markus Feindler<markus.feind...@gmx.de> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> No, Im trying to upgrade "my" portlet implementation from 5.1 to >>>>>>>>>> 5.2 >>>>>>>>>> >>>>>>>>>> and >>>>>>>>>>> up to now the activationrequestparameters aren't put in the url, >>>>>>>>>>> cause >>>>>>>>>>> I >>>>>>>>>>> have to adjust my former 5.1 custom response renderer. If the >>>>>>>>>>> Request >>>>>>>>>>> is >>>>>>>>>>> an >>>>>>>>>>> ActionRequest (see Portlet lifecycle) you can't write output into >>>>>>>>>>> a >>>>>>>>>>> stream >>>>>>>>>>> instead a redirect is done internally in the portlet container. >>>>>>>>>>> Therefore >>>>>>>>>>> I >>>>>>>>>>> have to add the parameters to the ActionReponse >>>>>>>>>>> (_actionResponse.setRenderParameter). In order to do so I need to >>>>>>>>>>> get >>>>>>>>>>> the >>>>>>>>>>> parameters. >>>>>>>>>>> >>>>>>>>>>> That's not enough details. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- Josh >>>>>>>>>>> >>>>>>>>>>> On Sep 5, 2010, at 9:51 AM, Markus Feindler< >>>>>>>>>>>> markus.feind...@gmx.de> >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>>>>>>>>>>> Need it for portlet implementation. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Hi >>>>>>>>>>>> >>>>>>>>>>>>> What is the purpose ? I guess you are dealing with some kind of >>>>>>>>>>>>>> dynamic >>>>>>>>>>>>>> stuff, please can you give more details ? >>>>>>>>>>>>>> >>>>>>>>>>>>>> 2010/9/5 Markus Feindler<markus.feind...@gmx.de> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hey folks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> I need to access page field values annotated with >>>>>>>>>>>>>> >>>>>>>>>>>>>> ActivationRequestParameters in order to retrieve the values. >>>>>>>>>>>>>>> Reflection >>>>>>>>>>>>>>> doesnt work, because the fields are private and a >>>>>>>>>>>>>>> java.lang.IllegalAccessException is thrown. Whats the right >>>>>>>>>>>>>>> way >>>>>>>>>>>>>>> to >>>>>>>>>>>>>>> retrieve >>>>>>>>>>>>>>> the values / activation request parameters? >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Regards >>>>>>>>>>>>>>> Markus >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> --------------------------------------------------------------------- >>>>>>>>>>>>>>> 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 >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> --------------------------------------------------------------------- >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> 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 >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> --------------------------------------------------------------------- >>>>>>>>>> >>>>>>>>>> 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 >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> >>>>>> 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 >>> >>> >>> >> > -- Regards, Christophe Cordenier. Committer on Apache Tapestry 5 Co-creator of wooki @wookicentral.com