cancel
Showing results for 
Search instead for 
Did you mean: 

Order property

robby
Champ in-the-making
Champ in-the-making
Hi all,
it's posible get the list of the property in the defined (xml) order?
Eg:
<type name="prfix:Type">         <title>Title</title>        <parent>cm:content</parent>        <properties>            <property name="xxx">               <title>Prop1</title>                  <type>d:text</type>            </property>            <property name="yyy">               <title>Prop2</title>                  <type>d:date</type>            </property>            <property name="zzz">               <title>Prop3</title>                  <type>d:text</type>                  <mandatory>true</mandatory>            </property>        </properties></type>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

At this point i get the properties map with:
Map<QName, PropertyDefinition> propertyDefsMap = typeDef.getProperties();

This is a map and i lost the sorting.
I want to have this order: Prop1,Prop2,Prop3.
It's possible???

Best regards

Robert.
6 REPLIES 6

robby
Champ in-the-making
Champ in-the-making
Is't possible write smth like:
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());Config wizardCfg = svc.getConfig("prfix:Type");ConfigElement typesCfg = wizardCfg.getConfigElement("show-property");‍‍‍‍‍


Associated to xml:
<config evaluator="node-type" condition="prfix:Type">      <property-sheet>               <show-property name="Prop1" />         <show-property name="Prop2" />         <show-property name="Prop3" /></config>‍‍‍‍‍‍‍‍

All suggestions are welcome!!

Robert.

gavinc
Champ in-the-making
Champ in-the-making
No, only the config will return the properties in a guaranteed order, getting the property definitions from the model will not necessarily come back in the order defined in the model (as Maps are used)

robby
Champ in-the-making
Champ in-the-making
I want to get the properties list in config order but i can't do that.

It's possible or not???

gavinc
Champ in-the-making
Champ in-the-making
Sorry, I misunderstood your question, yes you can get the properties in config order.

With the config example you provide you must pass an instance of a Node object (org.alfresco.web.bean.repository.Node) to getConfig() not a String, if you want to access the config by string you would have to change the evaluator to be "string-compare".

Presuming you are using a Node you can do the following:

ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance()); Config wizardCfg = svc.getConfig(yourNode); PropertySheetConfigElement props = (PropertySheetConfigElement)wizardCfg.getConfigElement("property-sheet");List<String> propsToShow = props.getItemNamesToShow();‍‍‍‍

This will return you a list of the properties (in order) that are configured to be displayed.

Hope this helps.

robby
Champ in-the-making
Champ in-the-making
Ok, it's clear..
But i don't have the node object…
I want to retrive the property list using the content type name (Eg: cm:MyType). This because the node object dosn't exists.

The user chose a type, after the choice, I display a form with the associated properties…
My problem is only the property sorting… :roll:  :roll:  :roll:

Robert….

robby
Champ in-the-making
Champ in-the-making
OK,
i've changed
<config evaluator="node-type" condition="ecm:TypeName">‍‍‍
with:
<config evaluator="string-compare" condition="ecm:TypeName">‍‍‍

Now with:
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());      Config wizardCfg = svc.getConfig("ecm:TypeName");      PropertySheetConfigElement props = (PropertySheetConfigElement)wizardCfg.getConfigElement("property-sheet");      List<String> propsToShow = props.getItemNamesToShow();‍‍‍‍‍‍

I get all sorted properties list.
Thank's!

Robert.