| 1 |
|
package org.trails.page; |
| 2 |
|
|
| 3 |
|
import java.util.ArrayList; |
| 4 |
|
import java.util.List; |
| 5 |
|
|
| 6 |
|
import ognl.Ognl; |
| 7 |
|
import ognl.OgnlException; |
| 8 |
|
import org.apache.tapestry.annotations.Persist; |
| 9 |
|
import org.trails.TrailsRuntimeException; |
| 10 |
|
import org.trails.callback.SearchCallback; |
| 11 |
|
import org.trails.descriptor.IClassDescriptor; |
| 12 |
|
|
| 13 |
3 |
public abstract class SearchPage extends TrailsPage |
| 14 |
|
{ |
| 15 |
|
|
| 16 |
|
@Persist |
| 17 |
|
public abstract Class getType(); |
| 18 |
|
|
| 19 |
|
public abstract void setType(Class type); |
| 20 |
|
|
| 21 |
|
|
| 22 |
|
@Override |
| 23 |
|
public void pushCallback() |
| 24 |
|
{ |
| 25 |
0 |
getCallbackStack().push(new SearchCallback(getPageName(), getType())); |
| 26 |
0 |
} |
| 27 |
|
|
| 28 |
|
public IClassDescriptor getClassDescriptor() |
| 29 |
|
{ |
| 30 |
1 |
return getDescriptorService().getClassDescriptor(getType()); |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
public String[] getSearchableProperties() |
| 34 |
|
{ |
| 35 |
|
try |
| 36 |
|
{ |
| 37 |
|
|
| 38 |
1 |
ArrayList<String> stringList = new ArrayList<String>(); |
| 39 |
2 |
stringList.addAll( |
| 40 |
1 |
(List) Ognl.getValue("propertyDescriptors.{? searchable}.{name}", getClassDescriptor())); |
| 41 |
1 |
return stringList.toArray(new String[]{}); |
| 42 |
|
} |
| 43 |
0 |
catch (OgnlException oe) |
| 44 |
|
{ |
| 45 |
0 |
throw new TrailsRuntimeException(oe); |
| 46 |
|
} |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
} |