Announcement Announcement Module
Collapse
No announcement yet.
On multiple message files/ image files/ rule source class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • On multiple message files/ image files/ rule source class

    Hi,

    I don't find the petclinic show how to use mutilple message property files and image property files.

    While our project is growing and we don't want to throw all messages and images definition in a single place -- we want to separate them according to individual modules. So could we do it, and how to do it? And for the rule source class, could we use multiple classes as well?

    Thanks a lot in advance.

  • #2
    Sorry, just made a silly mistake.

    What I want to do is, I can add the messages/images/rulesource definitions in multiple context xml files. For example, I have a main context file:

    Code:
    <bean id="imageResourcesFactory" 		class="org.springframework.context.support.ResourceMapFactoryBean">
    	<property name="locations">
    	<list>
    	<value>classpath&#58;org/springframework/richclient/image/images.properties</value>
    	<value>classpath&#58;images.properties</value>
    	</list>
    	</property>
    	<property name="resourceBasePath">
    	<value>images/</value>
    	</property>
    </bean>
    Can I add more resouces to it, in another context xml file under another module, such as:

    <bean id="imageResourcesFactory" class="org.springframework.context.support.Resourc eMapFactoryBean">
    <property name="locations">
    <list>
    <value>classpath:modulesource/images.properties</value>
    </list>
    </property>
    <property name="resourceBasePath">
    <value>modulesource/images/</value>
    </property>
    </bean>
    [/code]


    Thanks a lot in advance!

    Comment


    • #3
      Having more than one message/image files is easy:

      Code:
      	<bean id="messageSource" 
      		class="org.springframework.context.support.ResourceBundleMessageSource">
      		<property name="basenames">
      			<list>
      				<value>org.springframework.richclient.application.messages</value>
      				<value>other_message_file_1</value>
      				<value>other_message_file_2</value>
      				<value>other_message_file_3</value>
      			</list>
      		</property>
      	</bean>
      
      	<bean id="imageResourcesFactory" 
      		class="org.springframework.context.support.ResourceMapFactoryBean">
      		<property name="locations">
      			<list>
      				<value>classpath&#58;org/springframework/richclient/image/images.properties</value>
      				<value>other_image_file_1</value>
      				<value>other_image_file_2</value>
      				<value>other_image_file_3</value>
      			</list>
      		</property>
      		<property name="resourceBasePath">
      			<value>images/</value>
      		</property>
      	</bean>
      We don't currently support multiple rules sources but this should not be a problem. You could easily create your own implementation of RulesSource which supports delegation to a list of child RulesSources or you could simply inject a single DefaultRulesSource into each of your "modules" and then set the module specific Rules using the addRules method.

      Another option is to have your form objects implement PropertyConstraintProvider and provide the rules directly rather than via the central RulesSource. I think there's some documention showing this in the Wiki.

      Ollie

      Comment


      • #4
        Originally posted by oliverhutchison
        Having more than one image file is easy:
        Code:
        	<bean id="imageResourcesFactory" 
        		class="org.springframework.context.support.ResourceMapFactoryBean">
        		<property name="locations">
        			<list>
        				<value>classpath&#58;org/springframework/richclient/image/images.properties</value>
        				<value>other_image_file_1</value>
        				<value>other_image_file_2</value>
        				<value>other_image_file_3</value>
        			</list>
        		</property>
        		<property name="resourceBasePath">
        			<value>images/</value>
        		</property>
        	</bean>
        How do you deal with the situation of multiple "images.properties" files, where each file has a different "resourceBasePath"? For example, for the images provided with Spring Rich Client, this path is "images". But what if you have another images.properties file for images that are in the "com.somecompany.images" package (instead of the "images" package) in a third party jar?

        Comment


        • #5
          Multiple resource base path for images

          I have icons in multiple jar files and would like to avoid having to put them all in one jar file. So, I need to specify multiple resourceBasePath properties somehow.

          Has anyone else had to deal with his?

          Code:
              <bean id="imageResourcesFactory"
                  class="org.springframework.context.support.ResourceMapFactoryBean">
                  <property name="locations">
                      <list>
                          <value>classpath&#58;org/springframework/richclient/image/images.properties</value>
                          <value>classpath&#58;com/coned/config/images.properties</value>
                      </list>
                  </property>
                  
                  <property name="resourceBasePath">
                      <list>
                          <value>com/coned/images/</value>
                          <value>incorsIcons/</value>
                      </list>
                  </property>
              </bean>

          Comment


          • #6
            Thomas,

            that certainly seems like a reasonable requirement you should raise this as an issue in Jira.

            Thanks,

            Ollie

            Comment


            • #7
              Originally posted by oliverhutchison
              Thomas,

              that certainly seems like a reasonable requirement you should raise this as an issue in Jira.

              Thanks,

              Ollie
              Ok, thanks. I was thinking later that maybe I was being foolish.

              Can I get around this issue by having the base class be "/" and then use the full path in the image.properties files? If I do that, then maybe I wouldn't need the change? Though that would mean that any paths in the core spring-rich image.properties files wouldn't really be right.

              I'll go ahead and enter a jira bug, though.

              Thanks for your time and effort. This stuff is so cool, I'm getting a lot out of it. I think the biggest missing piece is documentation, but thankfully everyone is so helpful.

              Comment


              • #8
                Problem with resourceBasePath

                Hi everybody,

                I try to set up my first RCP Project and something is still working fine. But I've some problems with the resourceBasePath of the images.

                src/at/demo/rcp/sample/ --> LaunchClass
                src/at/demo/rcp/sample/common --> xml-Files for configuration
                src/at/demo/rcp/sample/ui --> GUI's and image.properties

                resources/images/splash.jpg

                this is a snippet of my application-context.xml
                Code:
                <bean id="imageResourcesFactory" class="org.springframework.context.support.ResourceMapFactoryBean">
                		<property name="locations">
                			<list>
                				<value>classpath&#58;org/springframework/richclient/image/images.properties</value>
                				<value>classpath&#58;at/demo/rcp/sample/ui/images.properties</value>
                			</list>
                		</property>
                		<property name="resourceBasePath">
                			<value>images/</value>
                		</property>
                	</bean>
                in my images.properties I've the property applicationInfo.image=logo.jpg. This jpg is in the resource/images directory mentioned above. I get always an error that the /images/splash.jpg cannot be found. How do you solve this problem? I hope you understand my matter :?:

                Refers the resourceBase to the images of the Spring RCP?

                thanks

                Comment

                Working...
                X