Announcement Announcement Module
Collapse
No announcement yet.
Trying to create bean with Hashmap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to create bean with Hashmap

    I'm trying to create a class that looks like this

    Class MyClass
    {
    String pageName;
    Map pageMap

    }

    The pageMap Map is a <String,List> where the list is just a list of Strings. Basically, I want to provide a string and get a list of strings from the map.

    My bean is defined below...

    <bean id="beanName" class="com.MyClass">
    <property name="pageName">
    <value>pageName</value></property>
    <property name="pageMap">
    <map>
    <entry key="fiscalYear">
    <ref bean="groupList" /> <-- I want a list here or a bean that points to a list, ideally
    </entry>
    </map>
    </property>
    </bean>

    <bean id="groupList" class="????">
    <property name="name">
    <list>
    <value>Group1</value>
    <value>Group2</value>
    <value>Group3</value>
    </list>
    </property>
    </bean>

    But, it doesn't work.

    Is there anyway I can put a list directly into the value of the map, without creating a new class that just holds a list of Strings?

  • #2
    Code:
    <bean id="beanName" class="com.MyClass">
      <property name="pageName">
        <value>pageName</value>
      </property>
      <property name="pageMap">
        <map>
          <entry key="fiscalYear">
             <list>
               <value>Group1</value>
               <value>Group2</value>
               <value>Group3</value>
             </list> 
          </entry>
        </map>
      </property>
    </bean>

    Comment


    • #3
      Damn! That's fast! Thank you, Colin.

      Guys, I hope you never tire of hearing this, but this entire project is simply incredible. Frankly, I am in awe of this entire effort.

      I just started playing with dynamic proxies in the last quarter of last year thanks to a great article on onjava.com. Afterwards, I thought, "This is profound." My first crack was adding security to a system via DPs. It occured to me that this is the beginning of an excellent way of adding services. The article helped me better understand where AOP came in.

      Imagine my surprise as a read about Spring that you were building AOP support in. Further imagine, when I saw how advanced your support was.

      One the one hand I thought, "These are some sharp guys and I had some of the same ideas." Then I thought "Sheesh! These guys are WAY ahead at least my curve."

      I just spent a few ours deprecating my dynamic proxies for Springs because frankly, the Spring AOP support is just plain superior. I'm also taking advantage of Spring to unify all our various configuration files under a single umbrella.

      Keep up the good work and I eagerly anticipate December's book!

      Comment


      • #4
        Hi Colin, and David

        I am a newbie in Spring World and I will appriciate your help. my problem is i am creating a page whose some fields are static while some text fields are dynamic ex

        static fiels -> number of args : 3

        dynamic field : arg1
        arg2
        arg3

        that means based upon my input to "number of args" field next textfileds will be created. for the obvious option for me is Javascript function.

        but these dynamically generated felds i need to bind with the List variable called "arguments" of the Bean. how can i do that ?


        thanks

        Abi

        Comment

        Working...
        X