Announcement Announcement Module
Collapse
No announcement yet.
Is this possible in Spring framework? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is this possible in Spring framework?

    I'd like to make 2 forms of which the first will open the second. The second form will then be used to enter some data which will then be passed to the first form. Data should be bean or list of beans. Off course both forms must be accessed through form controllers and validated with form validator. Is there any kind of support for this in Spring?

  • #2
    You might want to look at http://www.springframework.org/docs/...ontroller.html

    Comment


    • #3
      Thanks yatesco. I was already implementing something with wizard controller but I have some problems.
      I have 2 objects. First is DataTypeEnumerated and second is DataTypeEnumeratedValue. DataTypeEnumerated has a list of DataTypeEnumeratedValues. So on the first form user should be able to enter/view info for DataTypeEnumerated and if/when he clicks on button to add values he should be able to add/modify/delete values for the given type. What I'm not sure of is how to bind information entered on second form to instance of DataTypeEnumeratedValue. Have you any idea?

      Comment


      • #4
        Why are they not the same object? If you stored DataTypeEnumerated on the session then it can be accessed by the second controller.

        Am I missing something (haven't had my coffee yet )

        Comment


        • #5
          they cant be the same object because type has many values

          Comment


          • #6
            Sorry, I should have been clearer What cannot you have a single "parent" object which has a get/SetChildren, or in your case a DataTypeEnumerated.get/SetValues().

            So you have a single object on the session (DataTypeEnumerated) which both controllers access?

            Comment


            • #7
              Yes I have a single object and here it is
              Code:
              package model;
              
              import java.util.ArrayList;
              import java.util.List;
              
              public class DataTypeEnumerated extends DataType 
              {
              	private static final long serialVersionUID = 1L;
              	
              	private List dataTypeEnumeratedValues = new ArrayList();
              	public DataTypeEnumerated() 
              	{
              		super();
              	}
              	public void setDataTypeEnumeratedValues(List dataTypeEnumeratedValues)
              	{
              		this.dataTypeEnumeratedValues = dataTypeEnumeratedValues;
              	}
              	public List getDataTypeEnumeratedValues()
              	{
              		return dataTypeEnumeratedValues;
              	}
                  
              
              }
              But how can i access it from 2 controllers? The only way I can think of is HttpSession. On the first form there would be a button 'add value' which will submit first form with action='addValue'. Then, in the DataTypeEnumeratedFormController in processFormSubmission for that action value i would do this:
              Code:
              return new ModelAndView("dataTypeEnumeratedValueForm","dataTypeEnumeratedValue",value);
              And in second controller DataTypeEnumeratedValueFormController in form backing object I would get value from session and use it as a command object.
              Does that sound possible?
              I'm running out of ideas

              Comment


              • #8
                Finally some progress

                Alright, now I have something that works, half way though.
                Let's summarize. I have two types of objects, type and value. Type(DataTypeEnumerated) has list of values(DataTypeEnumeratedValue) and two form controllers, DataTypeEnumeratedFormUC and DataTypeEnumeratedValueFormUC with their respective command objects (type and value). And i also have two forms, for both objects. Type's form on click of a button 'addValue' or 'updateValue' calls value's form in which data can be added or changed depending on the action(addValue or updateValue).
                The trick i used is the following. When user selects one value from assigned values list and click on update button, value form is opened with it's data filled and ready to be changed. Just before that, i placed current 'type' object (from whose form we came) and value's index in type's list, into session as attributes. Those two i extracted in DataTypeEnumeratedValueFormUC's formBackingObject method and so I accessed selected value. But there is one problem here. Validation for second form is not working even though i declared it in appropriate xml. Has anyone experienced something similar?

                Comment


                • #9
                  Validation is working after all. I screwed up something in my code. If anyone cares I could post my source code. Thanks for your patience yatesco.

                  Comment


                  • #10
                    No probs

                    Not sure if it would help, but http://forum.springframework.org/sho...ght=checkboxes might be interesting for you

                    Comment

                    Working...
                    X