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>

Comments

  1. there is no ADF faces core component palette in Jdev 11g, as coponents are purely JSF components with AJax, These are entirely new components and need to be used as per the tutorials given By Oracle. I will advice to download Oracle's sample for 11g preview 3, it would give u a better idea.More info at this web site.

    ReplyDelete

Post a Comment