Announcement Announcement Module
Collapse
No announcement yet.
Beans and TreeMap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Heiko Ortmann
    started a topic Beans and TreeMap

    Beans and TreeMap

    Hello,

    I want to setup a bean and I am not sure, weather it is possible in the following way:

    <util:map map-class="java.util.TreeMap" id="idModel">
    <entry>
    <key>
    <bean class="business.CategoryTO">
    <property name="description" value="Userdaten" />
    </bean>
    </key>
    <list>
    <bean class="business.FieldTO">
    <property name="title" value="Name" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title" value="Rechnungslegung" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title" value="Telefon" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title" value="E-Mail" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title"
    value="Erwartetes Lieferdatum" />
    </bean>
    </list>
    </entry>
    </util:map>

    Is it possible to use not String objects as key and value in a Map Bean?

    Thank you and Best Regards
    Heiko

  • Heiko Ortmann
    replied
    I solved the problem. I separated the values and created 2 maps with references to the values: code example:

    Code:
    	<util:list id="userdaten">
    		<bean class="business.FieldTO">
    			<property name="title" value="Name" />
    		</bean>
    		<bean class="business.FieldTO">
    			<property name="title" value="Rechnungslegung" />
    		</bean>
    		<bean class="business.FieldTO">
    			<property name="title" value="Telefon" />
    		</bean>
    		<bean class="business.FieldTO">
    			<property name="title" value="E-Mail" />
    		</bean>
    		<bean class="business.FieldTO">
    			<property name="title"
    				value="Erwartetes Lieferdatum" />
    		</bean>
    	</util:list>
    
    	<util:map map-class="java.util.TreeMap" id="idModel">
    		<entry key="userdaten" value-ref="userdaten" />
    	</util:map>
    
    	<util:map map-class="java.util.TreeMap" id="idModelEmail">
    		<entry>
    			<key>
    				<bean class="business.CategoryTO">
    					<property name="description" value="Userdaten" />
    				</bean>
    			</key>
    			<ref bean="userdaten"/>
    		</entry>
    </util:map>
    I use the maps at the position that I need.

    Spring is a very flexible framework

    Thx alot and BR
    Heiko

    Leave a comment:


  • Heiko Ortmann
    replied
    Originally posted by al0 View Post
    Please, use CODE tags when you post code and/or XML here. It makes it so much more readable!
    Thank you for the advice, I will use the tags next time.

    Originally posted by al0 View Post
    And back to your question, sure it is possible. Your snippet looks ziemlich gut.

    Did you encounter some problem with it?
    Indeed the next error message regarding the JSTL view and the foreach command. Now the keys are not a String anymore and

    Code:
    <c:forEach items = "${model.userInformation}" var = "userinfo">
    doesn't work.

    BR
    Heiko

    Leave a comment:


  • al0
    replied
    Please, use CODE tags when you post code and/or XML here. It makes it so much more readable!

    And back to your question, sure it is possible. Your snippet looks ziemlich gut.

    Did you encounter some problem with it?

    Regards,
    Oleksandr

    Originally posted by Heiko Ortmann View Post
    Hello,

    I want to setup a bean and I am not sure, weather it is possible in the following way:

    <util:map map-class="java.util.TreeMap" id="idModel">
    <entry>
    <key>
    <bean class="business.CategoryTO">
    <property name="description" value="Userdaten" />
    </bean>
    </key>
    <list>
    <bean class="business.FieldTO">
    <property name="title" value="Name" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title" value="Rechnungslegung" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title" value="Telefon" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title" value="E-Mail" />
    </bean>
    <bean class="business.FieldTO">
    <property name="title"
    value="Erwartetes Lieferdatum" />
    </bean>
    </list>
    </entry>
    </util:map>

    Is it possible to use not String objects as key and value in a Map Bean?

    Thank you and Best Regards
    Heiko

    Leave a comment:

Working...
X