Thursday, August 30, 2018

Referring ViewAttributeDefImpl properties from the dynamic UI tag

Referring ViewAttributeDefImpl properties from the dynamic UI tag


I have blogged on generating dynamic UI some time back. In case you missed them, here are the links
Model driven approach for building Dynamic UI
Enabling LOVs for Dynamic ViewObject attributes
Long living Dynamic Business Components

Here is a tip for you to refer the ViewAttributeDefImpl properties such as label and other custom properties  from the dynamic UI such as dynamic table.
For example if you have set label for an attribute as given below, it can be referred from UI through
#{defXXX.propertyMap.label} 

Code snippet for setting propertu for attribute definition in a dynamic view object(if you are not following this code snippet read Model driven approach for building Dynamic UI  and come back)

ViewAttributeDefImpl attrdef= getDynamicAttrdef();
attrdef.setAliasName(col.getName());
attrdef.setProperty("label", getSomeNiceLabel());

UI tag snippet referring the property that we set in the above code.

<af:table rows="#{bindings.DynamicVO.rangeSize}"
fetchSize="#{bindings.DynamicVO.rangeSize}"
emptyText="#{bindings.DynamicVO.viewable ? No data to display. : Access Denied.}"
var="row" rowBandingInterval="0"
columnStretching="column:clmn2"
value="#{bindings.DynamicVO.collectionModel}"
selectedRowKeys="#{bindings.DynamicVO.collectionModel.selectedRow}"
selectionListener="#{bindings.DynamicVO.collectionModel.makeCurrent}"
rowSelection="single" id="t1"
styleClass="AFStretchWidth">
<af:forEach items="#{bindings.DynamicVOIterator.attributeDefs}"
var="def" varStatus="vs">
<af:column headerText="#{def.propertyMap.label}" sortable="true"
sortProperty="#{def.name}"
id="clmn${vs.index}">
<af:inputText value="#{row.bindings[def.name].inputValue}"
maximumLength="#{row.bindings[def.name].hints[def.name].precision}"
id="fld1"/>
</af:column>
</af:forEach>
</af:table>


visit link download