I have nothing but pain every time I touch web flow, I thought things might be more simple and understanable in the world of grails as apposed to Spring MVC but it seems not.
I have a simple situation where I want to start off a web flow with a prepopulated command object already in the flow scope when the first page of the web flow displays. The command object is basically going to hold copies of values form a domain object
heres my command object:
@grails.validation.Validateable(nullable=false)
class PatientEditFlowCommand implements Serializable{
StepOneCommand stepOneCommand
PatientEditFlowCommand(Patient patient){
stepOneCommand = new StepOneCommand(
patientName : "${patient.appUser?.firstName} ${patient.appUser?.lastName}",
patientDoctorId : patient.doctor?.id,
patientNurseId : patient.nurse?.id,
patientStartDate : patient.startDate,
patientEndDate : patient.endDate,
patientDrugRegimeId: patient.regime?.id
)
}
static constraints = {
}
}
@grails.validation.Validateable(nullable=false)
class StepOneCommand implements Serializable{
String patientName //wont be editable
Long patientDoctorId //user id of assigned doctor
Long patientNurseId //user id of assigned doctor
Date patientStartDate
Date patientEndDate
Long patientDrugRegimeId
static constraints = {
patientDoctorId(nullable: false)
patientNurseId(nullable: false)
patientStartDate(nullable: false)
patientEndDate(nullable: false)
patientDrugRegimeId(nullable: false)
}
}
@grails.validation.Validateable(nullable=false)
class StepTwoCommand implements Serializable{
static constraints = {
}
}
Heres my flow inside my controller:
def newEditFlow = {
init {
//start the flow by transferring domain obj into a command object
action {
Patient patient = Patient.get(params.id)
[patientEditFlowCommand:new PatientEditFlowCommand(patient)]
success()
}
on ("success"){
}.to "stepOne"
}
stepOne{
on("next") {
}.to("stepTwo")
on("cancel").to("finish")
}
stepTwo{
on("next") {
}.to("stepThree")
on("previous").to("stepOne")
}
stepThree{
on("next") {
}.to("stepFour")
on("previous").to("stepTwo")
}
stepFour{
on("next") {
}.to("finish")
on("previous").to("stepThree")
}
finish{
redirect(controller:'patient',action: "list")
}
}
but when i navigate to the first transtion I get this
Error 500: Internal Server Error
URI /ivfportal/patient/newEdit/3 Class java.lang.NullPointerException Message null Around line 74 of GrailsFlowExecutorImpl.java
71: }72:73: try {74: return super.resumeExecution(flowExecutionKey, context);75: }76: catch (FlowExecutionRestorationFailureException e) {77: if (e.getCause() instanceof SnapshotUnmarshalException) { Around line 53 of GrailsFlowHandlerAdapter.java
50: request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controllerInstance);51: }52:53: return super.handle(request, response, handler);54: }55:56: public void setGrailsApplication(GrailsApplication grailsApplication) { Around line 189 of PageFragmentCachingFilter.java
186: if (method == null) {187: log.debug("No cacheable method found for {}:{} {}",188: new Object[] { request.getMethod(), request.getRequestURI(), getContext() });189: chain.doFilter(request, response);190: return;191: }192: Collection cacheOperations = cacheOperationSource.getCacheOperations( Around line 63 of AbstractFilter.java
60: try {61: // NO_FILTER set for RequestDispatcher forwards to avoid double gzipping62: if (filterNotDisabled(request)) {63: doFilter(request, response, chain);64: }65: else {66: chain.doFilter(req, res); Around line 45 of DevModeSanityFilter.groovy
42: response.contentType = "text/html"43: response.writer << RELOADING_DOC44: } else {45: chain.doFilter(request, response)46:47: if (request.getAttribute('resources.need.layout')) {48: def dispositionsLeftOver = DispositionsUtils.getRequestDispositionsRemaining(request) Around line 53 of GrailsAnonymousAuthenticationFilter.java
50:51: applyAnonymousForThisRequest((HttpServletRequest)req);52:53: chain.doFilter(req, res);54: }55:56: protected void applyAnonymousForThisRequest(HttpServletRequest request) { Around line 139 of RestAuthenticationFilter.groovy
anyone se where I'm going wrong ? Is there a simpler but still tidy way of collecting data over a multi page flow in Grails ?
Aucun commentaire:
Enregistrer un commentaire