I have a need to check in the MethodAdvice whether any of the persistent fields
are not null, something like below...
How would I go about doing that?
-------------------------------
@Override
public void transform(final PlasticClass plasticClass,
TransformationSupport support, final MutableComponentModel model)
{
final List<PlasticField> fields =
plasticClass.getFieldsWithAnnotation(Persist.class);
for(final PlasticMethod method :
plasticClass.getMethodsWithAnnotation(AJAX.class))
{
final AJAX annotation = method.getAnnotation(AJAX.class);
if(method.isVoid() == false)
{
method.addAdvice(new MethodAdvice()
{
@Override
public void advise(MethodInvocation invocation)
{
boolean isNull = true;
for(PlasticField field : fields)
{
Object value = field.readValue(); // THIS IS WHAT
I WANT
if(value != null)
{
isNull = false;
break;
}
}
if(request.isXHR() && isNull)
{
// do not invoke on bad sessions
}
else
{
invocation.proceed();
}
}
});
}
else
{
throw new RuntimeException(
"@AJAX can be applied to non-void event handlers only");
}
}