if (isShowInForm(fields[j]))
{
// Il campo ha una annotazione @ShowInForm
ShowInForm annotation = fields[j].getAnnotation(ShowInForm.class);
attr.setImplementationType(annotation.type());
attr.setOrderInForm(annotation.order());
attr.setOnCreateIf(annotation.onCreateIf());
attr.setOnEditIf(annotation.onEditIf());
attr.setOnDisplayIf(annotation.onDisplayIf());
attr.setOnDeleteIf(annotation.onDeleteIf());
attr.setValidatorId(annotation.validatorId());
attr.setFormFormatOff(annotation.formatOff());
attr.setListFormatOff(annotation.listFormatOff());
attr.setAjaxEvent(annotation.ajaxEvent());
String ids[] = annotation.idsToRerenderOnAjaxEvent();
for (int i = 0; i < ids.length; i++)
attr.addIdToRerenderOnAjaxEvent(ids[i]);
if (annotation.type() == AttributeImplementationType.TEXTAREA || annotation.type() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
if (annotation.columns() == 0)
throw new MissingColumnsException(beanName, fields[j].getName());
if (annotation.rows() == 0)
throw new MissingRowsException(beanName, fields[j].getName());
attr.setColumns(annotation.columns());
attr.setRows(annotation.rows());
}
if (annotation.type() == AttributeImplementationType.LISTBOX)
{
for (int i = 0; i < annotation.labels().length; i++)
{
attr.addLabel(annotation.labels()[i]);
}
}
attr.setHelp(annotation.help());
attr.setRequired(annotation.required());
}
else
{
attr.setOrderInForm(0);
attr.setImplementationType(AttributeImplementationType.HIDEINFORM);
}
if (isAlternateOrderingAttribute(fields[j]))
{
// Il campo ha una annotazione @AlternateOrderingAttribute
AlternateOrderingAttribute annotation = fields[j].getAnnotation(AlternateOrderingAttribute.class);
attr.setAlternateOrderingAttribute(annotation.attribute());
}
tmp.add(attr);
}
}
// Inserisce i campi di tipo @Transient
// escludendo getSerialVersionUID
Method methods[] = cBean.getDeclaredMethods();
/** Ordinamento degli attributi per nome **/
java.util.Arrays.sort(methods, new JavaMethodComparator());
for (int i = 0; i < methods.length; i++)
{
if (methods[i].getName().startsWith("get") && !methods[i].getName().equals("getSerialVersionUID") && methods[i].getAnnotation(javax.persistence.Transient.class) != null && methods[i].getAnnotation(ShowTransientInForm.class) != null)
{
Attribute attr = new Attribute();
attr.setName(Utils.makeMethod2Field(methods[i].getName()));
attr.setType(methods[i].getReturnType().getName());
attr.setKey(false);
ShowTransientInForm annotation = methods[i].getAnnotation(ShowTransientInForm.class);
attr.setImplementationType(AttributeImplementationType.READONLY);
attr.setOrderInForm(annotation.order());
attr.setTrans(true);
tmp.add(attr);
}
}