Details

    • Type: Feature Request
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: XML Configuration
    • Labels:
      None
    • Affects:
      Release Notes

      Description

      Currently, it is quite verbose to populate a collection with configured object instances using the XML module.

      For example:

      Foo is a class having a collection (bars) of Bars

      <e:Foo>
      <e:bars>
      <s:value>
      <e:Bar id="1"/>
      </s:value>
      <s:value>
      <e:Bar id="2"/>
      </s:value>
      <s:value>
      <e:Bar id="3"/>
      </s:value>
      <s:value>
      <e:Bar id="4"/>
      </s:value>
      </e:bars>
      </e:Foo>

      If the s:values tag is introduced, it'll make the configuration less verbose

      <e:Foo>
      <e:bars>
      <s:values>
      <e:Bar id="1"/>
      <e:Bar id="2"/>
      <e:Bar id="3"/>
      <e:Bar id="4"/>
      </s:values>
      </e:bars>
      </e:Foo>

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            jharting Jozef Hartinger added a comment -

            Assigning to get some attention as this would be very nice for seam-rest. Feel free to postpone if needed, though.

            Show
            jharting Jozef Hartinger added a comment - Assigning to get some attention as this would be very nice for seam-rest. Feel free to postpone if needed, though.
            Hide
            jharting Jozef Hartinger added a comment -

            or is it possible to leave out the <s:value> tag completely for collections? (according to docs this can be done for a String field)

            <e:Foo>
            <e:bars>
            <e:Bar id="1"/>
            <e:Bar id="2"/>
            <e:Bar id="3"/>
            <e:Bar id="4"/>
            </e:bars>
            </e:Foo>

            Show
            jharting Jozef Hartinger added a comment - or is it possible to leave out the <s:value> tag completely for collections? (according to docs this can be done for a String field) <e:Foo> <e:bars> <e:Bar id="1"/> <e:Bar id="2"/> <e:Bar id="3"/> <e:Bar id="4"/> </e:bars> </e:Foo>
            Hide
            jharting Jozef Hartinger added a comment - - edited

            I implemented both approaches. To demonstrate the problem better, here's the code you currently need to write to configure a cavalry with two knights:

            <test:Cavalry>
                <test:knights>
                    <value>
                        <test:Knight>
                            <test:horse>
                                <value>
                                    <test:Horse name="Ace" />
                                </value>
                            </test:horse>
                            <test:sword>
                                <value>
                                    <test:Sword type="sharp" />
                                </value>
                            </test:sword>
                        </test:Knight>
                    </value>
                    <value>
                        <test:Knight>
                            <test:horse>
                                <value>
                                    <test:Horse name="Apples" />
                                </value>
                            </test:horse>
                            <test:sword>
                                <value>
                                    <test:Sword type="blunt" />
                                </value>
                            </test:sword>
                        </test:Knight>
                    </value>
                </test:knights>
            </test:Cavalry>
            

            With the first approach, the <values> element is introduced, which can be used when an initial value of a collection is set making the configuration file a little less verbose. This change is implemented at https://github.com/jharting/seam-config/tree/SEAMXML-25-values

            <test:Cavalry>
                <test:knights>
                    <values>
                        <test:Knight>
                            <test:horse>
                                <value>
                                    <test:Horse name="Ace" />
                                </value>
                            </test:horse>
                            <test:sword>
                                <value>
                                    <test:Sword type="sharp" />
                                </value>
                            </test:sword>
                        </test:Knight>
                        <test:Knight>
                            <test:horse>
                                <value>
                                    <test:Horse name="Apples" />
                                </value>
                            </test:horse>
                            <test:sword>
                                <value>
                                    <test:Sword type="blunt" />
                                </value>
                            </test:sword>
                        </test:Knight>
                    </values>
                </test:knights>
            </test:Cavalry>
            

            Alternatively, the <value> element can be omitted completely, making the configuration a lot more similar to the Seam 2 components.xml file. (Actually, the only case when the <value> is needed is when setting a collection / array field with primitive / String types, since you need to be able to separate the values within the text of an element somehow)
            This approach is implemented at https://github.com/jharting/seam-config/tree/SEAMXML-25
            Note that although this change is quite radical, it is completely backward-compatible and one can still use the <value> element if needed. This change only makes the element optional in most of the possible some cases.

            <test:Cavalry>
                <test:knights>
                    <test:Knight>
                        <test:horse>
                            <test:Horse name="Ace" />
                        </test:horse>
                        <test:sword>
                            <test:Sword type="sharp" />
                        </test:sword>
                    </test:Knight>
                    <test:Knight>
                        <test:horse>
                            <test:Horse name="Apples" />
                        </test:horse>
                        <test:sword>
                            <test:Sword type="blunt" />
                        </test:sword>
                    </test:Knight>
                </test:knights>
            </test:Cavalry>
            

            Stuart, please review the code and let me know which alternative you prefer.

            Show
            jharting Jozef Hartinger added a comment - - edited I implemented both approaches. To demonstrate the problem better, here's the code you currently need to write to configure a cavalry with two knights: < test :Cavalry> < test :knights> < value > < test :Knight> < test :horse> < value > < test :Horse name = "Ace" /> </ value > </ test :horse> < test :sword> < value > < test :Sword type = "sharp" /> </ value > </ test :sword> </ test :Knight> </ value > < value > < test :Knight> < test :horse> < value > < test :Horse name = "Apples" /> </ value > </ test :horse> < test :sword> < value > < test :Sword type = "blunt" /> </ value > </ test :sword> </ test :Knight> </ value > </ test :knights> </ test :Cavalry> With the first approach, the <values> element is introduced, which can be used when an initial value of a collection is set making the configuration file a little less verbose. This change is implemented at https://github.com/jharting/seam-config/tree/SEAMXML-25-values < test :Cavalry> < test :knights> < values > < test :Knight> < test :horse> < value > < test :Horse name = "Ace" /> </ value > </ test :horse> < test :sword> < value > < test :Sword type = "sharp" /> </ value > </ test :sword> </ test :Knight> < test :Knight> < test :horse> < value > < test :Horse name = "Apples" /> </ value > </ test :horse> < test :sword> < value > < test :Sword type = "blunt" /> </ value > </ test :sword> </ test :Knight> </ values > </ test :knights> </ test :Cavalry> Alternatively, the <value> element can be omitted completely, making the configuration a lot more similar to the Seam 2 components.xml file. (Actually, the only case when the <value> is needed is when setting a collection / array field with primitive / String types, since you need to be able to separate the values within the text of an element somehow) This approach is implemented at https://github.com/jharting/seam-config/tree/SEAMXML-25 Note that although this change is quite radical, it is completely backward-compatible and one can still use the <value> element if needed. This change only makes the element optional in most of the possible some cases. < test :Cavalry> < test :knights> < test :Knight> < test :horse> < test :Horse name = "Ace" /> </ test :horse> < test :sword> < test :Sword type = "sharp" /> </ test :sword> </ test :Knight> < test :Knight> < test :horse> < test :Horse name = "Apples" /> </ test :horse> < test :sword> < test :Sword type = "blunt" /> </ test :sword> </ test :Knight> </ test :knights> </ test :Cavalry> Stuart, please review the code and let me know which alternative you prefer.

              People

              • Assignee:
                Unassigned
                Reporter:
                jharting Jozef Hartinger
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Development