Hello all,

Here is my Tapestry 5.2 code for InjectSelectionModelWorker.
Its aim is to add these 2 methods 

        public GenericSelectionModel<Menu> getEntitiesSelectionModel () {
                return (new GenericSelectionModel<Menu>(getEntities (), "label",
_access));
        }

        public GenericValueEncoder<Menu> getEntitiesValueEncoder () {
                return (new GenericValueEncoder<Menu>(getEntities (), "id", 
_access));
        }

thanks to the annotation 
@InjectSelectionModel(fieldId = "id", fieldLabel = "label")

The problem is that lList is null.



public class InjectSelectionModelWorker implements
ComponentClassTransformWorker {

        private PropertyAccess mPropertyAccess;

        public InjectSelectionModelWorker (PropertyAccess pPropertyAccess) {
                mPropertyAccess = pPropertyAccess;
        }

        public void transform (ClassTransformation pClassTransformation,
MutableComponentModel pMutableComponentModel) {
                for (TransformField lTransformField : 
matchInjectSelectionModelFields
(pClassTransformation)) {
                        addCodeMethodsForInjectSelectionModelField 
(pClassTransformation,
pMutableComponentModel, lTransformField);
                }
        }

        private void addCodeMethodsForInjectSelectionModelField
(ClassTransformation pClassTransformation, MutableComponentModel
pMutableComponentModel, TransformField pTransformField) {
                InjectSelectionModel lAnnotation = pTransformField.getAnnotation
(InjectSelectionModel.class);
                String lInjectSelectionModelFieldName = 
InternalUtils.stripMemberName
(pTransformField.getName ());
                String lInjectSelectionModelFieldId = lAnnotation.fieldId ();
                String lInjectSelectionModelFieldLabel = lAnnotation.fieldLabel 
();
                addGetValueEncoderMethod (pClassTransformation, pTransformField,
lInjectSelectionModelFieldName, lInjectSelectionModelFieldId);
                addGetSelectionModelMethod (pClassTransformation, 
pTransformField,
lInjectSelectionModelFieldName, lInjectSelectionModelFieldLabel);
        }

        private void addGetValueEncoderMethod (ClassTransformation
pClassTransformation, TransformField pTransformField, String
pInjectSelectionModelFieldName, final String pInjectSelectionModelFieldId) {
                String lMethodName = "get" + InternalUtils.capitalize
(InternalUtils.stripMemberName (pInjectSelectionModelFieldName)) +
"ValueEncoder";
                TransformMethodSignature lTransformMethodSignature = new
TransformMethodSignature (Modifier.PUBLIC,
(GenericValueEncoder.class).getName (), lMethodName, null, null);
                ensureNotOverride (pClassTransformation, 
lTransformMethodSignature);
                final FieldAccess lFieldAccess = pTransformField.getAccess ();
                pClassTransformation.getOrCreateMethod
(lTransformMethodSignature).addAdvice (new ComponentMethodAdvice () {
                        public void advise (ComponentMethodInvocation 
lComponentMethodInvocation)
{
                                Object lList = lFieldAccess.read 
(lComponentMethodInvocation.getInstance
());

                                System.out.println 
("*******************************" + lList);
                                
                                lComponentMethodInvocation.overrideResult (new 
GenericValueEncoder
((List)lList, pInjectSelectionModelFieldId, mPropertyAccess));
                        }
                });
        }

}

Thanks a lot for your help.

Regards.

-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/FieldAccess-could-not-read-transformedField-tp3400430p3400430.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

Reply via email to