Skip to content

Instantly share code, notes, and snippets.

@bendalton
Created October 12, 2010 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendalton/31da648df89c98c7307e to your computer and use it in GitHub Desktop.
Save bendalton/31da648df89c98c7307e to your computer and use it in GitHub Desktop.
/**
* Trip handler
*/
component{
// Virtual service layer based on the User entity
property name="tripService" inject="model:TripService";
// OPTIONAL HANDLER PROPERTIES
this.prehandler_only = "";
this.prehandler_except = "";
this.posthandler_only = "";
this.posthandler_except = "";
// REST Allowed HTTP Methods Ex: this.allowedMethods = {delete='POST,DELETE',index='GET'}
this.allowedMethods = {};
/**
IMPLICIT FUNCTIONS: Uncomment to use
function preHandler(event,action){
var rc = event.getCollection();
}
function postHandler(event,action){
var rc = event.getCollection();
}
function onMissingAction(event,missingAction){
var rc = event.getCollection();
}
function onError(event,faultAction,exception){
var rc = event.getCollection();
}
*/
function index(event){
var rc = event.getCollection();
rc.trips = tripService.getAll();
event.setView("Trip/index");
}
function list(event){
var rc = event.getCollection();
rc.trips = tripService.getAll();
event.setView("Trip/index");
}
function create(event){
runEvent("Trip.edit");
}
function edit(event){
var rc = event.getCollection();
rc.service = tripService;
rc.trip = tripService.getTrip();// };//getTrip(event.getValue("tripID",""))
event.setView("Trip/edit");
}
}
/**
* a model for a trip
*/
component persistent="true" table="trips"{
// Properties
property name="tripID" column="trip_id" fieldtype="id" generator="uuid" setter="false";
property name="shortDescription";
property name="description";
property name="origin";
property name="destination";
property name="user";
// Relationships
//property name="user" cfc="model.users.User" fieldtype="many-to-one" fkcolumn="FK_userID" lazy="true";
//property name="comments" singularName="comment" fieldtype="one-to-many" type="array"
// cfc="model.comments.Comment" fkcolumn="entry_id" inverse="true" cascade="all-delete-orphan";
/* ----------------------------------------- PUBLIC ----------------------------------------- */
}
/**
* A ColdBox Enabled Templated entity service
*/
import coldbox.system.orm.hibernate.*;
component extends="VirtualEntityService"{
/**
* Constructor
*/
public any function init(){
super.init("Trip");
return this;
}
public any function getTrip(){
return new();
}
}
When accessing the Trip handler...
Error autowiring VirtualTMO.handlers.Trip. Could not find the ColdFusion component or interface VirtualEntityService. Ensure that the name is correct and that the component or interface exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment