You need to sign in to do that
Don't have an account?
neeru
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
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
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