-
-
Save bendalton/31da648df89c98c7307e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 ----------------------------------------- */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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