Announcement Announcement Module
No announcement yet.
Map complex objects in a webflow Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Map complex objects in a webflow


    I'm getting nullpointerexception when flow is rendering the first jsp in the start state.

    My model object in the flow is Car.
    public class Car implements Serializable {
       private Long id;
       private Engine engine;
       private Wheels wheels;
       private Body body;
       //getter and setters
    On the start of the flow I'm presenting a form which captures engine information.

    <form:form  method = "post" modelAttribute = "car">
         Select engine: <form:input path="engine.engineType"/>
        //rest of the form.....
    When the flow starts to render this view, it throws following exception
    Caused by: ognl.OgnlException: source is null for getProperty(null, "engineType")
    	at ognl.OgnlRuntime.getProperty(
    	at ognl.ASTProperty.getValueBody(
    	at ognl.SimpleNode.evaluateGetValueBody(
    	at ognl.SimpleNode.getValue(
    	at ognl.ASTChain.getValueBody(
    	at ognl.SimpleNode.evaluateGetValueBody(
    	at ognl.SimpleNode.getValue(
    	at ognl.Ognl.getValue(
    	at org.springframework.binding.expression.ognl.OgnlExpression.getValue(

  • #2
    Instantiating engine object in Car's default constructor resolved the NullPointerException issue.

      public car(){
         this.engine = new Engine();
    However, now on form submission form values are not updated and hence not carried over to the next state in the flow?

    Any suggestions?


    • #3
      I'm not sure, my approach of using one model for the entire flow is incorrect and may be that's why I'm not getting expected results!

      Here is my flow.
      1. Get Engine information, move to next state
      2. Get Wheels information, move to next state
      3. Get Body information, move to next state
      4. Show complete car assembly and then submit request.

      I'm attempting to use Car object as a model for the entire flow right from beginning so that when end state is reached it will persist the model and request will be processed.

      Does anyone know if I've to use individual object in each state and then keep them in flowScope and then assemble in the final step to be submitted???????


      • #4
        Thank you for looking. As of now I've found the solution to ONE Model ONE FLOW issues that I was facing. Soon, I will try to publish a step-by-step instructions for the same for those who might face similar issues in future.

        However, I would still like to understand if it is a good practice to use ONE MODEL FOR ONE FLOW?


        • #5
          Only if it makes sense to do so?

          For a complex multipart model like in the example, probably. It would probably simplify your design, especially if you made this a convention for most of your flows.

          But where it doesn't make sense to reach into the main model and alter its components directly, then use the smallest piece that makes sense, then attach it when it's ready.

          Of course, if you're working with models that don't have anything to do with the main model, or any of your other models, then don't group them into one model object JUST to follow this convention.


          • #6

            I'm doing exactly the same thing as you do.
            I'm not facing any null pointer exception because either i'm using "select" to let the user choose the option or if it's input text fields, i'm forcing it to be filled in.

            Do you know how to make N-N relations possible ?
            For example, if your car have possible "Options" and these options could be integrated in different cars.. ?