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
neeruneeru 

using of wrapper class can we pass field values dynamically??

Hi Everyone,

 

 

i need to develope an apex component in such a way that it should create a pageblocktable by taking object name ,fields name dynamically.For this i written a controller but it is not make my need.my approach is i'm trying to retrieve field names from wrapper class,object name dynamically from database.query and i will bind this wrapper to my page block table.
 Can anyone help this scenario with some sample code please guys??
 
Thanks,
bhagi
Shikha AgashiShikha Agashi
Can you please paste your code here as well as please explain little bit what you are trying to do there?
Parteek Kumar 5Parteek Kumar 5
Hi Neeru,

If u want to get object name and fields name dynamiclly, I beleive you should use field set for your requirment.

please check below links...
http://www.salesforcetutorial.com/fieldset-salesforce/
http://www.sfdcpoint.com/salesforce/fieldset-apex-code-salesforce/
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_field_sets.htm (http://www.sfdcpoint.com/salesforce/fieldset-apex-code-salesforce/)

Thanks,
Parteek
sandeep reddy 37sandeep reddy 37
yo its possible  
 see this is the  prog
first class
===============
public class dynamicsoql {
    public string aname{set;get;}
    public string aindustry{set;get;}
    public string query{set;get;}
    public list<account>accc{set;get;}
 
    public void show(){
        query='select id,name,industry from account';
        if((aname!='' && aname!=null) && (aindustry!=null && aindustry!='')){
           query=query +' where name=\''+aname+'\' and industry=\''+aindustry+'\'';

        }else{ 

if(aname!=null && aname!=''){ 

query=query+' where name=\''+aname+'\''; 



else if(aindustry!=null && aindustry!=''){ 

query=query+' where industry=\''+aindustry+'\''; 



accc=Database.query(query);
        }
    }
    
}
the vf
page is
=================
<apex:page controller="dynamicsoql">
    <apex:form >
        <apex:pageBlock title="my search">
            <apex:inputText value="{!names}"/>
            <apex:commandButton value="search" action="{!name}" /><br/><br/><br/>
            <apex:outputText value="{!names}"/>
            </apex:pageBlock>
    </apex:form>
</apex:page>
===========
let me know it is helpful or not