Share customization - Could not make the advanced searching with dropdown property to work?

cancel
Showing results for 
Search instead for 
Did you mean: 
Established Member

Share customization - Could not make the advanced searching with dropdown property to work?

Jump to solution

I am using Alfresco Community 5.2. I used Alfresco Maven SDK 3.0 to generate AMPs for the repository tier and share UI tier. I did customization in the share config custom XML, etc.

Say, custom type A has a dropdown property (through a custom aspect and constraints). (Only in the try-alfresco-tomcat, I am able to do the following). Now in the Advanced Search, the property shows up as a dropdown with all the values (because of the customization). The first value is preselected for the dropdown (as naturally expected).

Now, whether I like it or not, it will become part of the search conditions (when I click search).
I cannot have it optionally in the search condition. Like, if I choose nothing, do not search by it. And if I choose a valid value from the dropdown, then search by it.

This search behavior can be accomplished for the text box search fields, right?
How could I do the same for dropdown custom property.

Gnanasekaran Sakthivel
1 Solution

Accepted Solutions
Moderator
Moderator

Re: Share customization - Could not make the advanced searching with dropdown property to work?

Jump to solution

You have two options, either you a custom form template for that property that will display all the values with a "" (empty) option or add the "" (empty) in constraint list in content model you have defined.

e.g., notice the empty <value>, this should resolve use case you have.  This is the simplest option.

<constraint name="demo:trialProductList" type="LIST">
      <parameter name="allowedValues">
        <list>
          <value></value>
          <value>Trial30</value>
          <value>Trial60</value>
.......
        </list>
      </parameter>
    </constraint>

Alternatively, you have to write a freemarker template, keep it in <yourShareModule>\src\main\resources\alfresco\web-extension\site-webscripts\com\demo\components\form\controls directory for example and use it as a template for the properties where you want to see an additonal empty option. You can take reference of out of the box "selectone.ftl" template and create your custom template that shows a blank option to avoid first value by default selected.

e.g.:

<field id="demo:trialProducts">
   <control
	  template="/com/demo/components/form/controls/select-menu-with-blank.ftl" />
</field>

  

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)

View solution in original post

4 Replies
Moderator
Moderator

Re: Share customization - Could not make the advanced searching with dropdown property to work?

Jump to solution

You have two options, either you a custom form template for that property that will display all the values with a "" (empty) option or add the "" (empty) in constraint list in content model you have defined.

e.g., notice the empty <value>, this should resolve use case you have.  This is the simplest option.

<constraint name="demo:trialProductList" type="LIST">
      <parameter name="allowedValues">
        <list>
          <value></value>
          <value>Trial30</value>
          <value>Trial60</value>
.......
        </list>
      </parameter>
    </constraint>

Alternatively, you have to write a freemarker template, keep it in <yourShareModule>\src\main\resources\alfresco\web-extension\site-webscripts\com\demo\components\form\controls directory for example and use it as a template for the properties where you want to see an additonal empty option. You can take reference of out of the box "selectone.ftl" template and create your custom template that shows a blank option to avoid first value by default selected.

e.g.:

<field id="demo:trialProducts">
   <control
	  template="/com/demo/components/form/controls/select-menu-with-blank.ftl" />
</field>

  

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)

View solution in original post

Established Member

Re: Share customization - Could not make the advanced searching with dropdown property to work?

Jump to solution

One problem I am facing is, since the property is defined as integer or numeric, I am seeing an exception thrown while loading the page. This exception is similar to numberformat exception (trying to convert the empty space into numeric)

<property name="demo:Year_Single">
  <title>Fiscal Year</title>
  <type>d:int</type>
  <mandatory>false</mandatory>
  <index enabled="true">
    <tokenised>true</tokenised>
    <facetable>true</facetable>
  </index>
  <constraints>
    <constraint ref="demo:yearValuesList" />
  </constraints>
</property>


And the year list is defined as a constraint

<constraint name="demo:yearValuesList" type="LIST">
  <parameter name="allowedValues">
  <list>
    <value></value>
    <value>2008</value>
    <value>2009</value>
    <value>2010</value>
    <value>2011</value>
    <value>2012</value>
    …more...
  </list>
</parameter>
<parameter name="caseSensitive">
  <value>true</value>
</parameter>
<parameter name="sorted">
  <value>false</value>
</parameter>
</constraint>

I could change the type to text. But, is there a way to deal with this numeric conversion issue?
In regular web page frameworks, some negative number could be used to represent null or no selection. 

Gnanasekaran Sakthivel
Moderator
Moderator

Re: Share customization - Could not make the advanced searching with dropdown property to work?

Jump to solution

I don't think so. You have empty value in the list and type is d:int hence error is expected. Either

- convert the property to d:text

or

- remove empty from the constraint list and create a field template (e.g. custom template, selectone-with-blank.ftl) to show an additional empty value when share form loads. 

example of custom template: 

https://github.com/rjmfernandes/share-custom-form-controls/blob/master/share-custom-fc-share/src/mai... 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)
Moderator
Moderator

Re: Share customization - Could not make the advanced searching with dropdown property to work?

Jump to solution

Glad it worked for you. good luck @sepgs2004 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)