function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TarentTarent 

apex:panelbar

please give me examples of item attribute in <apex:panelbar> tag

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code snippet as reference:

 

------- vf page----------------

<apex:page Controller="New1">  

   <apex:form id="Describe">

      <apex:pageBlock id="block2" >

         <apex:pageblockbuttons location="top" >

            <apex:commandButton value="Get Describe Object Fields" action="{!showFields}"/>

         </apex:pageblockbuttons>

        <apex:pageblocksection >

          <apex:selectList value="{!selectedObject}" size="1">

           <apex:selectOptions value="{!objectNames}"/>

          </apex:selectList>

         

        </apex:pageblocksection>

        <apex:pageblocksection id="fieldList" rendered="{!not(isnull(selectedObject))}">

            <apex:panelBar items="{!fields}" var="fls">

            <apex:actionSupport event="onclick" action="{!GetSelected}"  />

             <apex:panelBarItem label="{!fls.key}">{!fls.val}</apex:panelBarItem>

            </apex:panelBar>

      

          <apex:inputText id="t1" value="{!show}"/>

          </apex:pageBlockSection>

       </apex:pageBlock>

    </apex:form>

</apex:page>

 

---------------- apex controller--------------

 

public class New1

{

 

    public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();

    public List<Pair> lstfieldname{get;set;}

    public List <Pair> fields {get{return lstfieldname;} set{lstfieldname =value;}}

    public List <SelectOption> objectNames{public get; private set;}

    public String selectedObject {get; set;}

    public String show {get; set;}

 

  public void GetSelected() {

  show='aaaa';

      

    }

    // Intialize objectNames and fields

    

    public New1() {

        objectNames = initObjNames();

        fields = new List<Pair>();

    }

    // Populate SelectOption list  - 

    

    // find all sObjects available in the organization 

    

    private List<SelectOption> initObjNames() {

        List<SelectOption> objNames = new List<SelectOption>();

        List<String> entities = new List<String>(schemaMap.keySet());

        entities.sort();

        for(String name : entities)

        objNames.add(new SelectOption(name,name));

        return objNames;

        }

        

    // Find the fields for the selected object

        

     public void showFields() {

        fields.clear();

        system.debug('$$$$$' + selectedObject);

        Map <String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObject).getDescribe().fields.getMap();

        for(Schema.SObjectField sfield : fieldMap.Values())

        {

        schema.describefieldresult dfield = sfield.getDescribe();

        system.debug('#######'  + dfield );   

        Pair field = new Pair();    

        field.key = dfield.getname();

         

        system.debug('#######4444'  + field.key);

        field.val = dfield.getType () + ' : ' + dfield.getLabel ();   

        lstfieldname.add(field);

        show=field.key;

        }

        }

       

    

  public class Pair

  {

     public String key {get; set;}

     public String val {get; set;}     

  }

}

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.