RE: [coldbox:8320] Retain data, set next event and show errors

Set the errors into the messagebox plugin, and setNextEvent to category.edit while placing the information you wish to keep in flash RAM?

~Brad

I knew the first 2 but I haven’t used the flash ram yet, I will do some reading up on it.

ok so I was able to get it to work making an adjustment to my edit method… would you make any changes to the following code?

public void function edit(event){
var rc = event.getCollection();
rc.id = structKeyExists(rc,“id”) ? rc.id : 0;

if( !structKeyExists(rc,“category”) ) {
rc.category = categoryService.get(rc.id);
}
}

public void function save(){
var rc = event.getCollection();
var cat = populateModel(model=categoryService.get(rc.id),exclude=“id”);

if( validationService.validate(cat) ){
categoryService.save(cat);
getPlugin(“messagebox”).setMessage(“info”,“Category saved!”);
setNextEvent(‘category/list’);
} else {
flash.put(“category”,cat);
getPlugin(“messagebox”).setMessage(“error”,“there were errors”);
setNextEvent(“category.edit”);
}
}