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

  • Map complex objects in a webflow

    Hi,

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

    My model object in the flow is Car.
    Code:
    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.

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

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

    Code:
      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?

    Comment


    • #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???????

      Comment


      • #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?

        Comment


        • #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.

          Comment


          • #6
            Dear,

            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.. ?

            Comment

            Working...
            X