Interface | Description |
---|---|
IERXRouteComponent |
If you return a component from ERXRouteController that implements the IERXRouteComponent interface, the route
controller will attempt to find set-methods on your component that correspond to the current route keys.
|
Class | Description |
---|---|
ERXDefaultRouteController |
ERXDefaultRouteController defines abstract methods for the standard default routes that are registered.
|
ERXMissingRouteController |
ERXMissingRouteController is the controller that is used when no route can be found.
|
ERXReadOnlyRouteController |
Just like ERXDefaultRouteController but only defines read-only methods.
|
ERXRoute |
ERXRoute encapsulates a URL path with matching values inside of it.
|
ERXRoute.Key |
ERXRoute.Key encapsulates a key name and an expected value type.
|
ERXRoute.RouteParameterMethod | |
ERXRouteController |
ERXRouteController is equivalent to a Rails controller class.
|
ERXRouteRequestHandler |
ERXRouteRequestHandler is the request handler that can process rails-style route mappings and convert them to
ERXRestController action methods.
|
ERXRouteRequestHandler.NameFormat |
NameFormat specifies how routes and controller names should be capitalized by default.
|
ERXRouteResults |
ERXRouteResults encapsulates the data necessary to produce a RESTful response.
|
ERXRouteUrlUtils |
Utilities for generating URLs to ERXRouteController routes (quicky impl).
|
ERXUnsafeReadOnlyRouteController<T extends EOEnterpriseObject> |
If you just want to quickly drop in a controller to test your entities, you can use or extend
ERXUnsafeReadOnlyRouteController.
|
ERXUnsafeReadWriteRouteController<T extends EOEnterpriseObject> |
If you just want to quickly drop in a controller to test your entities, you can use or extend
ERXUnsafeReadWriteRouteController.
|
Enum | Description |
---|---|
ERXRoute.Method | |
ERXRouteRequestHandler.NameFormat.Case |
An enumerated type specifying the case of your routes.
|
Annotation Type | Description |
---|---|
ERXRouteParameter |
ERXRouteParameter is an annotation that should be applied to a method on an IERXRouteComponent, which will be
automatically set from the route keys specified in a URL.
|
public class Application extends ERXApplication {
public Application() {
...
ERXRouteRequestHandler routeRequestHandler = new ERXRouteRequestHandler();
routeRequestHandler.addRoutes(Reminder.ENTITY_NAME); // addRoutes looks for an addRoutes method on RemindersController
routeRequestHandler.addRoutes(Person.ENTITY_NAME); // addRoutes looks for an addRoutes method on PeopleController
routeRequestHandler.addDefaultRoutes(Task.ENTITY_NAME);
ERXRouteRequestHandler.register(routeRequestHandler);
}
...
}
public class PeopleController extends ERXDefaultRouteController {
public PeopleController(WORequest request) {
super(request);
}
public static void addRoutes(String entityName, ERXRouteRequestHandler requestHandler) {
requestHandler.addRoute(new ERXRoute("/person/{userName}/login", PeopleController.class, "login"));
requestHandler.addRoute(new ERXRoute("/person/{person:Person}/reminders", ERXRoute.Method.Post, PeopleController.class, "createReminder"));
requestHandler.addRoute(new ERXRoute("/person/{person:Person}/reminders/{date:String:\\d\\d\\d\\d-\\d\\d-\\d\\d}", PeopleController.class, "reminders"));
requestHandler.addDefaultRoutes(entityName);
}
public Person person() {
Person person = (Person) routeObjectForKey("person");
return person;
}
public static ERXKeyFilter showFilter() {
ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
filter.exclude(Person.PASSWORD);
filter.include(Person.COMPANY);
filter.exclude(Person.AUTH_TOKEN);
return filter;
}
public static ERXKeyFilter updateFilter() {
ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
filter.exclude(Person.PASSWORD);
filter.include(Person.COMPANY);
filter.exclude(Person.AUTH_TOKEN);
filter.include(Person.COMPANY);
return filter;
}
protected void checkCurrentPerson(Person person) {
/* check that the given person is the logged in person */
}
protected void checkAdminAccess() {
/* check for administrator access */
}
public WOActionResults loginAction() throws Exception {
String userName = routeStringForKey("userName");
String password = request().stringFormValueForKey("password");
IPerson person = /* authenticate your user */ ((Session)session()).accessManager().authenticate(userName, password);
return response(person, showFilter());
}
public WOActionResults createAction() throws Exception {
checkAdminAccess();
ERXKeyFilter personFilter = showFilter();
personFilter.include(Person.COMPANY);
Person person = (Person) create(Person.ENTITY_NAME, personFilter);
editingContext().saveChanges();
return response(person, showFilter());
}
public WOActionResults updateAction() throws Exception {
checkAdminAccess();
Person person = person();
update(person, updateFilter());
editingContext().saveChanges();
return response(person, showFilter());
}
public WOActionResults showAction() {
Person person = person();
return response(person, showFilter());
}
public WOActionResults indexAction() throws Exception {
ERXRestFetchSpecification fetchSpec = new ERXRestFetchSpecification(Person.ENTITY_NAME, null, null, showFilter(), Person.LAST_NAME.ascInsensitive().then(Person.FIRST_NAME.ascInsensitive()), -1);
return response(editingContext(), Person.ENTITY_NAME, fetchSpec.objects(editingContext(), request()), showFilter());
}
public WOActionResults createReminderAction() throws Exception {
Person person = person();
Reminder reminder = Reminder.createReminder(person, null);
update(reminder, RemindersController.updateFilter());
editingContext().saveChanges();
return response(reminder, RemindersController.showFilter());
}
public WOActionResults remindersAction() throws Exception {
return controller(RemindersController.class).indexAction(); // Reminders controller looks for an optional {person} request object and an optional {date}
}
public WOActionResults destroyAction() throws Throwable {
checkAdminAccess();
Person person = person();
person.delete();
editingContext().saveChanges();
return response(person, showFilter());
}
public WOActionResults newAction() throws Throwable {
checkAdminAccess();
ERXKeyFilter personFilter = showFilter();
personFilter.include(Person.COMPANY);
Person person = Person.createPerson(editingContext(), "Unknown Name");
// don't save here we're just returning a blank one for them to fill in
return response(person, showFilter());
}
}
Copyright © 2002 – 2024 Project Wonder.