package javango.contrib.jquery.fields;
import java.lang.annotation.Annotation;
import com.google.inject.Inject;
import javango.contrib.jquery.annotations.Lookup;
import javango.contrib.jquery.widgets.JqueryLookupWidget;
import javango.forms.fields.AbstractField;
import javango.forms.widgets.WidgetFactory;
public abstract class JqueryLookupField<T> extends AbstractField<T> {
@Inject
public JqueryLookupField(WidgetFactory widgetFactory) {
super(widgetFactory);
setWidget(JqueryLookupWidget.class);
}
Class<?> model;
/**
* The string used to format the value shown in the field, takes string of the format
* %{BILLTO}s - shows the BILLTO property of the object as a string. A null value will use the primary key.
*/
String display;
/**
* List of properties (comma seperated) that will be used to construct the search form, matches fields in the Model.
* A value of null will use all properties.
*/
String search;
/**
* List of properties (comma seperated) that will be used to construct the search results, matched fields in the model.
* A value of null will use all properties.
*/
String results;
/**
* List of properties (comma seperated) that will be used as the order by when displaying the search results.
*/
String orderBy;
@Override
public void handleAnnotation(Annotation annotation) {
super.handleAnnotation(annotation);
if (annotation instanceof Lookup) {
Lookup lookup = (Lookup)annotation;
model = lookup.model();
display = lookup.display();
search = lookup.search();
results = lookup.results();
}
}
public Class<?> getModel() {
return model;
}
public void setModel(Class<?> model) {
this.model = model;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public String getResults() {
return results;
}
public void setResults(String results) {
this.results = results;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
}