Projet

General

Profil

Autocomplete DS and How to fill description field with type properties

Ajouté par Augusto Lucena il y a plus de 8 ans

Hello Matthieu,

First of all, congratulations on your work with Designer, thanks to you, I can create my custom models and apply them to meet my needs eventhough I don't work with IT.

I have 2 questions and I would be pleased if you could help me:

1 - For autocomplete fields, I tried to input the object control to my property. However, I did not understand how should I input the datasource. On my extCustomForm I can see the <control-param name="ds">becpg/autocomplete/...</control-param> parameter. What should I do to implement that? Should I use .txt file?

2 - Do you know any way that I can add the metadata properties, from the custom type I created, to the Description field of a content on share? For instance, something like this prop1-prop2-prop3.

Thank you so much for your assistance!


Réponses (13)

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Mounia Azibi il y a plus de 8 ans

Hello,

1- There is a page explaining how to provide a datasource to an autocomplete control on the wiki : link. This should answer your question.
2- I didn't understand what you want to do, can you please give some further explanations ?

Regards,

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

Mounia Azibi a écrit :

Hello,

1- There is a page explaining how to provide a datasource to an autocomplete control on the wiki : link. This should answer your question.
2- I didn't understand what you want to do, can you please give some further explanations ?

Regards,

Hi Mounia,

I already read the wiki few times although I apologize cuz I could not understand (I don't work with IT). I didn't get what should exactly I do.

About this instruction
"Parameters:
ds (string) The datasource used by the control"

I tried to use value1, value2, value3 like we do with the list constraint. And also I tried with the same terms in each new paragraph
value1
value2
value3

Both of them did not work for me.

Please, forget about 2nd question. Regards.

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

Is it mandatory to speak French to get any help in here????
I've seen a bunch of questions in French which got answered immediately.

Taken from Wiki page:

Control path:
/fr/becpg/components/form/controls/autocomplete.ftl
Parameters:
ds (string) The datasource used by the control

Url of datasource

<control template="/fr/becpg/components/form/controls/autocomplete.ftl">
<control-param name="ds">becpg/autocomplete/exempleSourceType</control-param>
</control>

Again,it is not clear to me what should go in this path: <control-param name="ds">becpg/autocomplete/exempleSourceType</control-param>

How do I implement the datasource? What should go inside .../exempleSourceType?

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Matthieu Laborie il y a plus de 8 ans

Hi,

Augusto Lucena a écrit :

Is it mandatory to speak French to get any help in here????

If you prefer to pay for service or support you will get answers faster! You can also download the codesource and have a look by yourself on how it works.
If nobody of the community answers you it's maybe that your questions are useless! (Not a language problem, I even speak Portuguese).

Autocomplete is for advanced users, you should create a java class, map it to an url and pass this url to the form control (ds params). This is explain in the same wiki page under datasource. beCPG is using a lot of this control and there is plenty of Java examples in the code. If you think the wiki is not enought, take the time to understand the code, and contribute some documentations changes.

Regards

I've seen a bunch of questions in French which got answered immediately.

Taken from Wiki page:

Control path:
/fr/becpg/components/form/controls/autocomplete.ftl
Parameters:
ds (string) The datasource used by the control

Url of datasource

<control template="/fr/becpg/components/form/controls/autocomplete.ftl">
<control-param name="ds">becpg/autocomplete/exempleSourceType</control-param>
</control>

Again,it is not clear to me what should go in this path: <control-param name="ds">becpg/autocomplete/exempleSourceType</control-param>

How do I implement the datasource? What should go inside .../exempleSourceType?

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

Hello,

Matthieu Laborie a écrit :

Hi,

Augusto Lucena a écrit :

Is it mandatory to speak French to get any help in here????

If you prefer to pay for service or support you will get answers faster! You can also download the codesource and have a look by yourself on how it works.
If nobody of the community answers you it's maybe that your questions are useless! (Not a language problem, I even speak Portuguese).

Autocomplete is for advanced users, you should create a java class, map it to an url and pass this url to the form control (ds params). This is explain in the same wiki page under datasource. beCPG is using a lot of this control and there is plenty of Java examples in the code. If you think the wiki is not enought, take the time to understand the code, and contribute some documentations changes.

Regards

Sorry, I meant that because I saw some topics written in French which received promptly answers.

No hard feelings, please.
-----------------------------------------------------------------------------------------------------

At this part of my Java Class I should put the desired values to be autocompleted between those {}?

@Override
public ListValuePage suggest(String sourceType, String query, Integer pageNum, Map<String, Serializable> props) {
...
}

Did I get it right?

I will read and seek around a bit and try to make it on my own. Thanks.

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Matthieu Laborie il y a plus de 8 ans

Hi,

Maybe you can first explain what you want to achieve which data you want to display in the autocomplete, there is out of box plugin for associations.

Exemple :

Association like this

                       <associations>
                <association name="bcpg:allergenSubset">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:allergen</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
            </associations>

Works out of box with no params (default datasource)

<field id="bcpg:allergenSubset">
    <control
        template="/org/alfresco/components/form/controls/autocomplete-association.ftl">
    </control>
</field>

If you look at autocomplete-association.ftl it will use by default:

<#assign ds='becpg/autocomplete/targetassoc/associations/${field.dataType}'/>

Which call

fr.becpg.repo.listvalue.impl.EntityListValuePlugin.java

You can find both in source code

https://www.becpg.fr/redmine/projects/becpg-community/repository

Regards

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

Hi,

Matthieu, in your example which words would be suggested when the user type in?

Maybe I have misunderstood the use of this form control.

What I was thinking about is to have 2 properties in my form which one would be the company_name and the another would be employee_name.

For instance, imagine that I work for CompanyA. With that in mind, I could type in "CompanyA" and then, it would be possible to type in "Augusto" as I work for them:

Company Name: CompanyA
Employee Name: Augusto

The fields must be filled by the prior list names set.
Is it possible to do that with that form control or should I try another way to do that?

I thought of something like the picture below

Regards,

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Philippe Quéré il y a plus de 8 ans

Hello,

In the file becpg-project-form-config.xml, you have an example of linked fields:

<field id="pjt:projectHierarchy1" set="mainInfo" >
    <control template="/org/alfresco/components/form/controls/autocomplete.ftl">
        <control-param name="ds">becpg/autocomplete/linkedvalue/values/System/ProjectLists/bcpg:entityLists/project_Hierarchy
        </control-param>
    </control>
</field>
<field id="pjt:projectHierarchy2" set="mainInfo" >
    <control template="/org/alfresco/components/form/controls/autocomplete.ftl">
        <control-param name="ds">becpg/autocomplete/linkedvalue/values/System/ProjectLists/bcpg:entityLists/project_Hierarchy
        </control-param>
        <control-param name="parent">pjt_projectHierarchy1
        </control-param>
    </control>
</field>

With that configuration, sub-familly depends on familly:

Regards,

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

I won't quote to avoid flooding the page.

It's very clear now! However, just to clarify:

The DS param is not the values which will be suggested, right? The values are based on the fields from my types? What is the DS param for, then?

That point is not clear for me so far.

Thanks.

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

Hi!

I read this whole thread a lot of times and I noticed that my requirements were not clearly mentioned.

What I need is cascading drop-down lists or auto-complete exactly as the example provided from project.

I reproduced the example given above by adding in Hierarchy Data list the parent value and its children. However, I don't understand what should I do to replicate this behavior of associations. I noticed that when you add a new "child" row to the parent one, it will consider the level of the data.

Using Designer, what do I have to do in order to reproduce this behavior considering those constraints:

Constraint Client
Values: Client1, Client2, Client3

Constraint Worker Client1
Values: Client1-WorkerA, Client1- WorkerB, Client1 - WorkerC

Constraint Worker Client2
Values: Client2-WorkerA, Client2- WorkerB, Client2 - WorkerC

Thanks.

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

Please, forget about my question above.

I read other posts here, source codes, guides and other and I explored project and I believe I finally understand how can I do what I need.

Please confirm and assist me with what I'm not 100% sure:

- I have to create a new entity-data-list of the type LinkedValues;
- From which path: |Repository > System > Project Lists| or |Repository > System > Entity templates > Project| ?
- Then I can create new rows parent(Client Name) and its respective children(Employees Names) associating their parents;
- The param "ds", which I can modify into Designer after adding the control param, will be related to my newly created entity;

If everything I wrote above is right, my last questions are:
- There is no option to give a name to the entity. How do I know the name of that entity to call it on the ds param of the code:

<field id="pjt:projectHierarchy1" set="mainInfo" >
<control template="/org/alfresco/components/form/controls/autocomplete.ftl">
**<control-param name="ds">becpg/autocomplete/linkedvalue/values/System/ProjectLists/bcpg:entityLists/project_Hierarchy**
</control-param>
</control>
</field>

And latest, how can I publish the code above into share without mixing up with designer default form.config?

I appreciate the assistance and mostly your patience with such a dumb question.

Kind regards.

RE: Autocomplete DS and How to fill description field with type properties - Ajouté par Augusto Lucena il y a plus de 8 ans

I'm using the aforementioned project_Hierarchy entity list as my datalist.

It didn't work though, the child field values available are only the values from the parent and not the supposed ones to be linked with its parent.

What am I missing?

Model:

&lt;aspect name=&quot;ext1:aspect_dadosdocfunc&quot;&gt;
&lt;properties&gt;
&lt;property name=&quot;ext1:nome_func&quot;&gt;
&lt;title&gt;Nome Funcionário&lt;/title&gt;
&lt;type&gt;d:noderef&lt;/type&gt;
&lt;mandatory&gt;false&lt;/mandatory&gt;
&lt;index enabled=&quot;true&quot;&gt;
&lt;atomic&gt;false&lt;/atomic&gt;
&lt;stored&gt;false&lt;/stored&gt;
&lt;tokenised&gt;TRUE&lt;/tokenised&gt;
&lt;/index&gt;
&lt;/property&gt;
&lt;property name=&quot;ext1:nome_cliente&quot;&gt;
&lt;title&gt;Nome Cliente&lt;/title&gt;
&lt;type&gt;d:noderef&lt;/type&gt;
&lt;mandatory&gt;false&lt;/mandatory&gt;
&lt;index enabled=&quot;true&quot;&gt;
&lt;atomic&gt;false&lt;/atomic&gt;
&lt;stored&gt;false&lt;/stored&gt;
&lt;tokenised&gt;TRUE&lt;/tokenised&gt;
&lt;/index&gt;
&lt;/property&gt;
&lt;/properties&gt;

Form Config:

&lt;appearance&gt;
&lt;set appearance=&quot;bordered-panel&quot; id=&quot;dadosdocumento&quot; label=&quot;Dados Documento&quot; template=&quot;/org/alfresco/components/form/2-column-set.ftl&quot;/&gt;
&lt;field id=&quot;ext1:nome_cliente&quot; label=&quot;Nome do Cliente&quot; mandatory=&quot;false&quot; read-only=&quot;false&quot; set=&quot;dadosdocumento&quot;&gt;
&lt;control template=&quot;/org/alfresco/components/form/controls/autocomplete.ftl&quot;&gt;
&lt;control-param name=&quot;ds&quot;&gt;becpg/autocomplete/linkedvalue/values/System/ProjectLists/bcpg:entityLists/project_Hierarchy&lt;/control-param&gt;
&lt;/control&gt;
&lt;/field&gt;
&lt;field id=&quot;ext1:nome_func&quot; label=&quot;Nome do Funcionário&quot; mandatory=&quot;false&quot; read-only=&quot;false&quot; set=&quot;dadosdocumento&quot;&gt;
&lt;control template=&quot;/org/alfresco/components/form/controls/autocomplete.ftl&quot;&gt;
&lt;control-param name=&quot;ds&quot;&gt;becpg/autocomplete/linkedvalue/values/System/ProjectLists/bcpg:entityLists/project_Hierarchy2&lt;/control-param&gt;
&lt;control-param name=&quot;parent&quot;&gt;pjt_projectHierarchy1&lt;/control-param&gt;
&lt;/control&gt;
&lt;/field&gt;
&lt;/appearance&gt;
    (1-13/13)