I have a form on my site that asks for users information (like name, address, etc..) mostly Strings,one int and one ArrayList. I'm using a Spring webflow mainly to allow a review view-state so that the user can go back and edit fields and because a few other forms I have also use webflow, so I'm trying to keep my code consistent.
The issue I'm having is with my Arraylist. I want the user to be able to add up to 10 physicians (name, policynumber,specialty) but I keep getting a BeanException and error messages indicating my List is empty. When I click on the review button to go to the next view, the page will just reload and throw the error I posted at the bottom.
Here is part of my spring webflow: In view PracticeReviewRequest I instantiate my arrayList with a new Arraylist
<set name="flowScope.pageDescription" value="'Please complete the form below to submit your request for a practice review.'"/>
</on-start>
<view-state id="practiceReviewRequest" view="/components/risk/practiceReview" model="practiceReviewForm">
<on-entry>
<set name="flowScope.practiceReviewForm.physicians" value="new java.util.ArrayList()"/>
</on-entry>
<transition on="review" to="practiceReviewRequestReview"/>
<transition on-exception="org.tmlt.data.dao.DataAccessException" to="practiceReviewRequest">
<set name="flowScope.exception" value="rootCauseException"/>
</transition>
</view-state>
<view-state id="practiceReviewRequestReview" view="/components/risk/email">
<transition on="submit" to="practiceReviewRequestSubmit"/>
<transition on-exception="org.tmlt.data.dao.DataAccessException" to="practiceReviewRequest">
<set name="flowScope.exception" value="rootCauseException"/>
</transition>
</view-state>
Here is art of my Object practiceReviewRequest
@XmlAccessorType(XmlAccessType.FIELD) public class PracticeReviewRequestImpl implements IPracticeReviewRequest, Serializable {
private static final long serialVersionUID = 1L;
private String submitName;
private String policyType;
private String groupName;
private String policyNumber;
private int physNum;
private List<IPracticeReviewRequest> physicians = new ArrayList<>(15);
@Override
public List<IPracticeReviewRequest> getPhysicians() {
return physicians;
}
@Override
public void setPhysicians(List<IPracticeReviewRequest> physicians) {
this.physicians = physicians;
}
@Override
public int getPhysNum() {
return physNum;
}
...
here is my Physician object: public class PracticeReviewRequestPhysicianImpl implements IPracticeReviewRequestPhysician, Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String policyNumber;
private String specialty;
@Override
public String getName() {
return name;
}
@Override
public String getPolicyNumber() {
return policyNumber;
}
@Override
public String getSpecialty() {
return specialty;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public void setPolicyNumber(String policyNumber) {
this.policyNumber = policyNumber;
}
@Override
public void setSpecialty(String specialty) {
this.specialty = specialty;
}
...
And here is part of my .ftl (for the sake of solving this issue Im hardcoding only one field physicians[0].name instead using of my JS function loop physicians[i].name, etc...) (this is all within a form tag with the hidden input type flowExecutionKey included)
Here is the error message that i see in my tomcat.
2018-04-12 11:00:15,916 DEBUG springframework.binding.mapping.impl.DefaultMapper: Beginning mapping between source [org.springframework.webflow.core.collection.LocalParameterMap] and target [org.tmlt.data.model.impl.PracticeReviewRequestImpl]
2018-04-12 11:00:15,923 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [TargetAccessError@c60ad7 mapping = parameter:'execution' -> execution, code = 'propertyNotFound', error = true, errorCause = org.springframework.binding.expression.PropertyNotFoundException: Property not found, originalValue = 'e7s1', mappedValue = [null]]
2018-04-12 11:00:15,924 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [Success@122d6f5 mapping = parameter:'submitName' -> submitName, code = 'success', error = false, originalValue = 'Test', mappedValue = 'Test']
2018-04-12 11:00:15,924 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [Success@6ced27 mapping = parameter:'policyType' -> policyType, code = 'success', error = false, originalValue = 'Yes', mappedValue = 'Yes']
2018-04-12 11:00:15,925 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [Success@769c4 mapping = parameter:'groupName' -> groupName, code = 'success', error = false, originalValue = 'Tset', mappedValue = 'Tset']
2018-04-12 11:00:15,925 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [Success@ae3690 mapping = parameter:'policyNumber' -> policyNumber, code = 'success', error = false, originalValue = 'SEt1', mappedValue = 'SEt1']
2018-04-12 11:00:15,925 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [Success@1ded18e mapping = parameter:'physNum' -> physNum, code = 'success', error = false, originalValue = '1', mappedValue = '1']
2018-04-12 11:00:15,925 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [TargetAccessError@1c1147 mapping = parameter:'physicians[0].name' -> physicians[0].name, code = 'evaluationException', error = true, errorCause = org.springframework.binding.expression.EvaluationException: A BeansException occurred setting the value of expression 'physicians[0].name' on context [class org.tmlt.data.model.impl.PracticeReviewRequestImpl] to [Ttest], originalValue = 'Ttest', mappedValue = [null]]
2018-04-12 11:00:15,926 DEBUG pringframework.binding.mapping.impl.DefaultMapping: Adding mapping result [TargetAccessError@1461909 mapping = null -> eventId_review, code = 'propertyNotFound', error = true, errorCause = org.springframework.binding.expression.PropertyNotFoundException: Property not found, originalValue = [null], mappedValue =enter code here [null]]
2018-04-12 11:00:15,927 DEBUG springframework.binding.mapping.impl.DefaultMapper: Completing mapping between source [org.springframework.webflow.core.collection.LocalParameterMap] and target [org.tmlt.data.model.impl.PracticeReviewRequestImpl]; total mappings = 8; total errors = 3
2018-04-12 11:00:15,927 DEBUG g.springframework.webflow.mvc.view.AbstractMvcView: Model binding resulted in errors; adding error messages to context
2018-04-12 11:00:15,931 DEBUG ingframework.binding.message.DefaultMessageContext: Resolving message using [DefaultMessageResolver@dc00ab source = 'physicians[0].name', severity = ERROR, codes = array['practiceReviewForm.physicians[0].name.evaluationException', 'practiceReviewForm.physicians.name.evaluationException', 'physicians[0].name.evaluationException', 'physicians.name.evaluationException', 'name.evaluationException', 'evaluationException'], args = array[[MessageBuilder.ResolvableArgument@cd5bdf arg = 'physicians[0].name']], defaultText = 'evaluationException on physicians[0].name']
2018-04-12 11:00:15,932 DEBUG ingframework.binding.message.DefaultMessageContext: Adding resolved message [Message@17402e3 source = 'physicians[0].name', severity = ERROR, text = 'evaluationException on physicians[0].name']
2018-04-12 11:00:15,932 DEBUG g.springframework.webflow.mvc.view.AbstractMvcView: Validating model
2018-04-12 11:00:15,934 DEBUG org.springframework.webflow.engine.ViewState : Rendering + [ServletMvcView@152a4e0 view = info.magnolia.module.blossom.view.TemplateView: name '/components/risk/practiceReview'; URL [/MyTMLT/templates/components/mytmlt/myTMLTComponent.ftl]]
2018-04-12 11:00:15,934 DEBUG org.springframework.webflow.engine.ViewState : Flash scope = map[[empty]]
2018-04-12 11:00:15,934 DEBUG org.springframework.webflow.engine.ViewState : Messages = [DefaultMessageContext@19f94a4 sourceMessages = map[[null] -> list[[empty]], 'physicians[0].name' -> list[[Message@17402e3 source = 'physicians[0].name', severity = ERROR, text = 'evaluationException on physicians[0].name']]]]
2018-04-12 11:00:15,935 DEBUG g.springframework.webflow.mvc.view.AbstractMvcView: Rendering MVC [info.magnolia.module.blossom.view.TemplateView: name '/components/risk/practiceReview'; URL [/MyTMLT/templates/components/mytmlt/myTMLTComponent.ftl]] with model map [{currentUser=null, viewScope=map[[empty]], componentTemplatePath=/MyTMLT/templates/components/risk/practiceReview.ftl, flowExecutionKey=e7s1, flowExecutionUrl=/riskpracticereviewrequest-flow?execution=e7s1, pageDescription=Please complete the form below to submit your request for a practice review., flashScope=map[[empty]], flowRequestContext=[RequestControlContextImpl@1eb4074 externalContext = org.springframework.webflow.mvc.servlet.MvcExternalContext@1f446e1, currentEvent = [null], requestScope = map[[empty]], attributes = map[[empty]], messageContext = [DefaultMessageContext@19f94a4 sourceMessages = map[[null] -> list[[empty]], 'physicians[0].name' -> list[[Message@17402e3 source = 'physicians[0].name', severity = ERROR, text = 'evaluationException on physicians[0].name']]]], flowExecution = [FlowExecutionImpl@25b8a3 flow = 'riskpracticereviewrequest-flow', flowSessions = list[[FlowSessionImpl@ec7f63 flow = 'riskpracticereviewrequest-flow', state = 'practiceReviewRequest', scope = map['viewScope' -> map[[empty]], 'componentTemplatePath' -> '/MyTMLT/templates/components/risk/practiceReview.ftl', 'pageDescription' -> 'Please complete the form below to submit your request for a practice review.', 'practiceReviewForm' -> org.tmlt.data.model.impl.PracticeReviewRequestImpl@174ec05]]]]], org.springframework.validation.BindingResult.practiceReviewForm=org.springframework.webflow.mvc.view.BindingModel: 1 errors
Field error in object 'practiceReviewForm' on field 'physicians[0].name': rejected value [null]; codes []; arguments []; default message [evaluationException on physicians[0].name], practiceReviewForm=org.tmlt.data.model.impl.PracticeReviewRequestImpl@174ec05}]
2018-04-12 11:00:15,944 DEBUG ion.repository.impl.DefaultFlowExecutionRepository: Putting flow execution '[FlowExecutionImpl@25b8a3 flow = 'riskpracticereviewrequest-flow', flowSessions = list[[FlowSessionImpl@ec7f63 flow = 'riskpracticereviewrequest-flow', state = 'practiceReviewRequest', scope = map['viewScope' -> map[[empty]], 'componentTemplatePath' -> '/MyTMLT/templates/components/risk/practiceReview.ftl', 'pageDescription' -> 'Please complete the form below to submit your request for a practice review.', 'practiceReviewForm' -> org.tmlt.data.model.impl.PracticeReviewRequestImpl@174ec05]]]]' into repository
Please let me know if you have any questions. I have been stuck on this all week. Thank you for your time.