<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing properties files in Action in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298970#M252100</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you've injected the global properties in your action's spring bean like &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;property name="properties"&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;ref bean="global-properties"/&amp;gt;&lt;BR /&gt;&amp;lt;/property&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then all you do is call &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;properties.getProperty("&amp;lt;prop name&amp;gt;")&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; - it's just a java.util.Properties object, look at the Javadocs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Realistically though unless your action needs to figure out what property to look for at runtime, then it's far easier just to inject the actual property values you need using the ${prop.name} notation as shown above&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steven&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 Jun 2016 10:28:00 GMT</pubDate>
    <dc:creator>steven_okennedy</dc:creator>
    <dc:date>2016-06-04T10:28:00Z</dc:date>
    <item>
      <title>Accessing properties files in Action</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298967#M252097</link>
      <description>Hi,Is there a way to access properties files in a custom action? I can use ResourceBundle resourceBundle = getResources();‍ in a Java webscript but it throws an error in my custom action.Any help will be appreciated.</description>
      <pubDate>Wed, 01 Jun 2016 05:16:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298967#M252097</guid>
      <dc:creator>rohit_chakrabor</dc:creator>
      <dc:date>2016-06-01T05:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing properties files in Action</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298968#M252098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume your are talking about properties that exist within your global properties file/standard OOTB Alfresco properties files?&amp;nbsp; The easiest way to do this is just inject the properties you need into the Spring bean that represents your action using ${} notation. E.g. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;bean id="script" class="org.alfresco.repo.action.executer.ScriptActionExecuter" parent="action-executer"&amp;gt;&lt;BR /&gt;&amp;lt;!– The service registry is needed as ScriptAction needs it –&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;property name="serviceRegistry"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref bean="ServiceRegistry" /&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;property name="personService"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref bean="personService" /&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;property name="storeUrl"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;value&amp;gt;${spaces.store}&amp;lt;/value&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;property name="companyHomePath"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;value&amp;gt;/${spaces.company_home.childname}&amp;lt;/value&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;property name="sysAdminParams"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref bean="sysAdminParams" /&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;BR /&gt;&amp;lt;/bean&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All you would need to do is create the instance variable in your class to hold the value (usually a String) and define an appropriate setter for it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternatively if you need to dynamically look up properties, you could inject the entire Global Properties object itself e.g. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;property name="properties"&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;ref bean="global-properties"/&amp;gt;&lt;BR /&gt;&amp;lt;/property&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this case your "properties" instance variable would need to be of type java.util.Properties&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steven&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 09:03:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298968#M252098</guid>
      <dc:creator>steven_okennedy</dc:creator>
      <dc:date>2016-06-01T09:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing properties files in Action</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298969#M252099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks but how do I access the properties file in the Java action class?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 05:14:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298969#M252099</guid>
      <dc:creator>rohit_chakrabor</dc:creator>
      <dc:date>2016-06-03T05:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing properties files in Action</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298970#M252100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you've injected the global properties in your action's spring bean like &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;property name="properties"&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;ref bean="global-properties"/&amp;gt;&lt;BR /&gt;&amp;lt;/property&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then all you do is call &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;properties.getProperty("&amp;lt;prop name&amp;gt;")&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; - it's just a java.util.Properties object, look at the Javadocs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Realistically though unless your action needs to figure out what property to look for at runtime, then it's far easier just to inject the actual property values you need using the ${prop.name} notation as shown above&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steven&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Jun 2016 10:28:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-properties-files-in-action/m-p/298970#M252100</guid>
      <dc:creator>steven_okennedy</dc:creator>
      <dc:date>2016-06-04T10:28:00Z</dc:date>
    </item>
  </channel>
</rss>

