I am getting to grips with Coldbox, so please bear with me as I get a grib on the basics.
I am trying out a very simple scenario with the framework, a CRUD for a PATIENT user object. Upon saving, I want to set a message (for now just something generic like “Successful”, and then pass that along to the LIST event, so that it displays that somewhere above the renderView(). I tried to persist the prc, the prc.message but I can’t get it to work. Also, I have seen a plugin called MessageBox, if I am not wrong, which may only come with ColdBox - can I use that and perhaps an example?
Here is my patient.cfc handler (I use the INDEX function name to be the entry point which then points to another event to make it simpler to switch to something else in the future - something taken from Grails). I set a prc.message inside the SAVE event and I want to pass that along to the INDEX, which then gets passed to the LIST.
`
component{
property name=“patientService” inject=“entityService:patient”;
function index(event,rc,prc){
setNextEvent( event=“patient.list” );
}
function list(event,rc,prc){
prc.patients = patientService.list( sortOrder=“lastName”, asQuery=false );
}
function save(event,rc,prc){
event.paramValue( “patientID”, 0 );
patientService.save( populateModel( patientService.get( rc.patientID ) ) );
prc.message = “Saved successfully!”;
setNextEvent( event=“patient” );
}
function add(event,rc,prc){
event.paramValue( “patientID”, 0 );
prc.patient = patientService.get( rc.patientID );
prc.pageTitle = “Add New”;
event.setView( “patient/edit” );
}
function edit(event,rc,prc){
event.paramValue( “patientID”, 0 );
prc.patient = patientService.get( rc.patientID );
prc.pageTitle = “Edit”;
event.setView( “patient/edit” );
}
function delete(event,rc,prc){
event.paramValue( “patientID”, 0 );
patientService.deleteByID( rc.patientID );
setNextEvent( “patient” );
}
}
`
And here’s where I add it to my layout:
`
`
Am I even going about this the right way?