Results 1 to 8 of 8

Thread: On multiple message files/ image files/ rule source class

  1. #1
    Join Date
    Oct 2004
    Location
    Vancouver, Canada
    Posts
    35

    Default 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.
    Regards
    linwei

  2. #2
    Join Date
    Oct 2004
    Location
    Vancouver, Canada
    Posts
    35

    Default

    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!
    Regards
    linwei

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    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

  4. #4
    Join Date
    Sep 2004
    Location
    Vancouver, BC, Canada
    Posts
    135

    Default

    Quote 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?
    Cheers,
    Joe
    "All your bean are belong to us" - Spring Framework's IOC Container

  5. #5

    Default 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>

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    Thomas,

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

    Thanks,

    Ollie

  7. #7

    Default

    Quote 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.

  8. #8
    Join Date
    Jul 2005
    Location
    Austria
    Posts
    105

    Default 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

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Replies: 3
    Last Post: Sep 4th, 2005, 11:11 PM
  4. Help: the boolean property exception!
    By linwei in forum Swing
    Replies: 2
    Last Post: Nov 17th, 2004, 07:11 PM
  5. Replies: 6
    Last Post: Nov 8th, 2004, 06:43 AM

Posting Permissions

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