cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic change the 'Additional options'

mliwski
Champ in-the-making
Champ in-the-making
Hello i am trying to change the advanced search to dynamic change the "Additional options" according to the "Content type" i am thinking make it with AJAX but does not found where to download the AdvancedSearchBean.java to work it or where i can do it ( if that is not the class to do it ). If anyone can help me or if someone do it or approximate to what i am trying to do…. I'll really thankful if that one can join it with the community.    I know that there is a JIRA ticket for it but i think that this is a good place to start…    Thanks again.    Matias.  Buenos Aires - Argentina.
5 REPLIES 5

mliwski
Champ in-the-making
Champ in-the-making
It's me again:
i need help to understand this line:

AdvancedSearchConfigElement config = (AdvancedSearchConfigElement)Application.getConfigService(context).getConfig("Advanced Search").getConfigElement(AdvancedSearchConfigElement.CONFIG_ELEMENT_ID);

From
http://jsourcery.com/api/sourceforge/alfresco/2.0.0/org/alfresco/web/ui/repo/component/UISearchCusto...

Please if someone can help me, i will really thankful.

(I'm stoked there but is in this line where can make dynamic the search (if i'm wrong please correct me))

lucky to all.

Matias.

frederick
Champ in-the-making
Champ in-the-making
AdvancedSearchConfigElement config = (AdvancedSearchConfigElement)Application.getConfigService(context).getConfig("Advanced Search").getConfigElement(AdvancedSearchConfigElement.CONFIG_ELEMENT_ID); 
This code refers to the ConfigService of Alfresco, which loads various config elements at startup.
Eg. for the web client, Spring loads the file 'web-client-application-context'. This file contains a Spring bean named 'webClientConfigSource':

   <bean id="webClientConfigSource" class="org.alfresco.config.source.UrlConfigSource">
      <constructor-arg>
         <list>
            <value>classpath:alfresco/web-client-config.xml</value>
            <value>classpath:alfresco/web-client-config-dialogs.xml</value>
            <value>classpath:alfresco/web-client-config-wizards.xml</value>
            <value>classpath:alfresco/web-client-config-properties.xml</value>
            <value>classpath:alfresco/web-client-config-navigation.xml</value>
            <value>classpath:alfresco/web-client-config-wcm.xml</value>
            <value>classpath:alfresco/web-client-config-actions.xml</value>
            <value>classpath:alfresco/web-client-config-forum-actions.xml</value>
            <value>classpath:alfresco/web-client-config-wcm-actions.xml</value>
            <value>classpath:alfresco/web-client-config-workflow-actions.xml</value>
            <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
            <value>jar:*!/META-INF/web-client-config-custom.xml</value>
         </list>
      </constructor-arg>
   </bean>

The config files mentioned here are full of <config> tags. For example, 'web-client-config.xml' has the following tag:

   <config evaluator="string-compare" condition="Advanced Search">
      <!– advanced search custom attribute config –>
      <!– see http://wiki.alfresco.com/wiki/Advanced_Search_Custom_Attributes –>
      <advanced-search>
         <!– type constraint drop-down –>
         <content-types>
            <!– cm:content type is implicit in this list –>
            <!– types must extend cm:content for display in the Alfresco web-client –>
            <type name="fm:post" />
         </content-types>
         <folder-types>
            <!– cm:folder type is implicit in this list –>
            <!– types must extend cm:folder for display in the Alfresco web-client –>
            <type name="fm:forums" />
         </folder-types>
      </advanced-search>
   </config>

As you may have guessed, this is the config element that is read by the code you posted. In fact, you can use this config element to add attributes to the advanced search without having to program anything.

More information here:
http://wiki.alfresco.com/w/index.php?title=Advanced_Search_Custom_Attributes&oldid=12327

Note: that the latest version of that wikipage is broken, I've linked to the previous version.

Note: you should be able to extend this config element using 'web-client-config-custom.xml' in your extension folder, instead of editing 'web-client-config.xml' directly. The wikipage also explains this further.

kevinr
Star Contributor
Star Contributor
Some odd user removed the wiki page content (hmmm) i've restored it.

Kev

mliwski
Champ in-the-making
Champ in-the-making
I'm already do that, but i want to do that by dynamic way.
This is: modifying the source code (in the class further mentioned) where it reads the values to add on the Additional options.
When change the content type, change also the Additional options of advanced search.

I.e.:

<config evaluator="string-compare" condition="Advanced Search">
   <advanced-search>
      <content-types>
         <type name="custom:pressrelease" />
      </content-types>
      <custom-properties>
                        <pressrelease>******************ADDED
                     <meta-data    type="custom:pressrelease"
                              property="custom:PRDate" />
                        </pressrelease>*****************ADDED
                        <CustomerDetails>***************ADDED
                     <meta-data    aspect="custom:CustomerDetails"
                              property="custom:CustomerName" />
                     <meta-data    aspect="custom:CustomerDetails"
                              property="custom:NewCustomer" />
                        </CustomerDetails>**************ADDED
      </custom-properties>
   </advanced-search>
</config>

My idea is change the xml and add another nested tag to custom-properties for every "dynamic" Additional options, then read the type or the aspect any time that content type (In more options search )change and then build the Additional options….

My think is if can made surely i.e. in php we can made with jsp……

Thanks.

Matias.

nikes
Champ on-the-rise
Champ on-the-rise
I am looking for the same solution.

We are having dozens of content type, if I put each search type custom property in XML to display in Additional Options panel…….it would contain hundreds of fields….

Did you find any solution? If yes please share with us.

Thanks,
Nikesh