Changes for page Properties Module
Last modified by Vincent Massol on 2021/03/17 21:12
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -xwiki:XWiki. ThomasMortagne1 +xwiki:XWiki.atallahade
- ExtensionCode.ExtensionClass[0]
-
- Description
-
... ... @@ -25,13 +25,19 @@ 25 25 Then it's possible to tweak this behavior with annotations: 26 26 27 27 * ##org.xwiki.properties.annotation.PropertyDescription##: a text describing the property 28 -* ##org.xwiki.properties.annotation.PropertyHidden##: indicate that the property should not be taken into account by BeanManager 29 -* ##org.xwiki.properties.annotation.PropertyMandatory##: indicate that an error should be generated when no value is provided in the Map for this property when populating. 28 +* ##org.xwiki.properties.annotation.PropertyHidden##: indicates that the property should not be taken into account by BeanManager 29 +* ##org.xwiki.properties.annotation.PropertyMandatory##: indicates that an error should be generated when no value is provided in the Map for this property when populating. 30 30 * ##org.xwiki.properties.annotation.PropertyName##: a text with the display name of the field 31 -* [since 6.3] ##org.xwiki.properties.annotation.PropertyId##: overwrite the property identifier 31 +* {{info}}since 6.3{{/info}} ##org.xwiki.properties.annotation.PropertyId##: overwrite the property identifier 32 +* {{info}}since 10.10{{/info}} ##org.xwiki.properties.annotation.PropertyAdvanced##: indicates that the property is to be used by more advanced users 33 +* {{info}}since 10.11{{/info}} ##org.xwiki.properties.annotation.PropertyGroup##: used to group properties together 34 +* {{info}}since 10.11{{/info}} ##org.xwiki.properties.annotation.PropertyFeature##: binds a property to a feature (two properties can be used for the same feature) 35 +* {{info}}since 11.0{{/info}} ##org.xwiki.properties.annotation.PropertyDisplayType##: overrides the type of the property for display only (e.g. WYSIWYG) 32 32 33 33 Finally default implementation of BeanManager support [[JSR 303 (Bean Validation)>>http://jcp.org/en/jsr/detail?id=303]] if an implementation can be found. 34 34 39 +==== Example ==== 40 + 35 35 {{code language="java"}} 36 36 /** 37 37 * Parameters for the {@link org.xwiki.rendering.internal.macro.include.IncludeMacro} Macro. ... ... @@ -52,15 +52,14 @@ 52 52 }; 53 53 54 54 /** 55 - * The nameofthedocumentto include.61 + * The entity reference to include. 56 56 */ 57 - private String document;63 + private String reference; 58 58 59 59 /** 60 - * Defines whether the included page is executed in its separated execution context or whether it's executed in the 61 - * context of the current page. 66 + * Type of the entity to include. 62 62 */ 63 - private Contextcontext;68 + private EntityType type = EntityType.DOCUMENT; 64 64 65 65 private String hiddenProperty; 66 66 ... ... @@ -67,24 +67,54 @@ 67 67 public int publicField; 68 68 69 69 /** 70 - * @param documentthe name of thedocumentto include.75 + * @param reference the reference of the resource to include 71 71 */ 72 - @PropertyMandatory 73 - @PropertyDescription("the name of the document to include") 74 - public void setDocument(String document) 77 + @PropertyDescription("the reference of the resource to display") 78 + @PropertyGroup("stringReference") 79 + @PropertyFeature("reference") 80 + public void setReference(String reference) 75 75 { 76 - this. document=document;82 + this.reference = reference; 77 77 } 78 78 79 79 /** 80 - * @return the n ame of thedocumentto include.86 + * @return the reference of the resource to include 81 81 */ 82 - public String get Document()88 + public String getReference() 83 83 { 84 - return this. document;90 + return this.reference; 85 85 } 86 86 87 87 /** 94 + * @return the type of the reference 95 + */ 96 + @PropertyDescription("the type of the reference") 97 + @PropertyGroup("stringReference") 98 + public EntityType getType() 99 + { 100 + return this.type; 101 + } 102 + 103 + /** 104 + * @param type the type of the reference 105 + */ 106 + public void setType(EntityType type) 107 + { 108 + this.type = type; 109 + } 110 + 111 + /** 112 + * @param page the reference of the page to include 113 + */ 114 + @PropertyDescription("The reference of the page to include") 115 + @PropertyFeature("reference") 116 + public void setPage(String page) 117 + { 118 + this.reference = page; 119 + this.type = EntityType.PAGE; 120 + } 121 + 122 + /** 88 88 * @param context defines whether the included page is executed in its separated execution context or whether it's 89 89 * executed in the context of the current page. 90 90 */ ... ... @@ -105,10 +105,10 @@ 105 105 } 106 106 107 107 @PropertyHidden 108 - public void setHiddenProperty(String hiddenProperty) 109 - { 110 - this.hiddenProperty = hiddenProperty; 111 - } 143 + public void setHiddenProperty(String hiddenProperty) 144 + { 145 + this.hiddenProperty = hiddenProperty; 146 + } 112 112 113 113 public String getHiddenProperty() 114 114 { ... ... @@ -120,7 +120,7 @@ 120 120 {{code language="java"}} 121 121 Map<String, String> values = new HashMap<String, String>(); 122 122 123 -values.put(" document", "Space.Page");158 +values.put("reference", "Space.Page"); 124 124 values.put("context", "new"); 125 125 values.put("publicField", "42"); 126 126 values.put("hiddenProperty", "hiddenPropertyvalue"); ... ... @@ -130,13 +130,12 @@ 130 130 BeanManager beanManager = componentManager.getInstance(BeanManager.class); 131 131 beanManager.populate(bean, values); 132 132 133 -assertEquals("Space.Page", bean.get Document());168 +assertEquals("Space.Page", bean.getReference()); 134 134 assertEquals(Context.NEW, bean.getContext()); 135 135 assertEquals(42, bean.publicField); 136 136 assertNull(bean.getHiddenProperty()); 137 137 {{/code}} 138 138 139 - 140 140 === Get bean descriptor === 141 141 142 142 It's possible to ask BeanManager descriptor generated from a Java Bean for easy listing of properties, values, etc. For example this is used to fill ##ParameterDescriptor##s of most of the Java-based macros. ... ... @@ -291,5 +291,6 @@ 291 291 {{/code}} 292 292 293 293 ==== Apache ConvertUtils Converter ==== 328 + 294 294 295 295 When convert manager can't find a specific converter for a type it uses Apache ConvertUtils. See http://commons.apache.org/beanutils/ for more details.