Results 1 to 4 of 4

Thread: simple question about using p schema shortcut

  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Default simple question about using p schema shortcut

    Hi, I couldnt find this in the doc. How would one declare list or arrays in the bean declaration using the p notation. For example I'm currently doing something like this:

    p:size="4"
    p:weight="55">
    <property name="kids">
    <list>
    <value>john</value>
    <value>susie</value>
    </list>
    </property>
    </bean>

    because this doesnt work: p:kids="john,susie"

    Is there a way to use the p shortcut with lists? thanks

  2. #2
    Join Date
    Nov 2005
    Posts
    113

    Default

    Unless something was added in 3.0 that I missed, there's no way to use the p-schema with collections. I typically just do the same thing you showed.

    Keep in mind, though, that Spring has the shortcut that lets you specify a single-element list as that element, so if I only had one kid, I could conceivably use p:kids="john".

    Hope this helps
    - Don

  3. #3
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    302

    Default

    Following is the only solution i can think of,

    Code:
    	<bean name="bean" class="com.example.Person" p:name="John Doe"
    		p:kids-ref="kids" />
    
    	<util:list id="kids" list-class="java.util.ArrayList">
    		<value>Smith</value>
    		<value>Mark</value>
    	</util:list>
    Amila Domingo

  4. #4
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    302

    Default

    because this doesnt work: p:kids="john,susie"

    Is there a way to use the p shortcut with lists? thanks
    If kids is a array it will work.
    Amila Domingo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •