Hello,
I have requirement like that.
Create field from vf page by selecting data type and created field display as input in vf page.
For example from pick-list If selected text field with label name this field I want display on another page as a input field.
I trust you are doing very well.
Below is the sample code which I have tested in my org. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
Below code can fullfill your requirements. Hope this will work for you.
Visualforce Page:
<apex:page standardController="Account" extensions="AccountDeleteWrapperCLs">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!accWrap}" var="acc">
<apex:column headerValue="select">
<apex:inputCheckbox value="{!acc.checkbox}"/>
</apex:column>
<apex:column headerValue="id">
<apex:outputField value="{!acc.accObj.id}"/>
</apex:column>
<apex:column headerValue="Name">
<apex:outputField value="{!acc.accObj.name}"/>
</apex:column>
<apex:column headerValue="Industry">
<apex:outputField value="{!acc.accObj.Industry}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="delete" action="{! deletecheckedRecs}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class AccountDeleteWrapperCLs{
public list<Account> Acclist{get;set;}
public ID currentPageID;
public list<DeleteExample> accWrap {get;set;}
public AccountDeleteWrapperCLs(ApexPages.StandardController controller) {
accWrap = new list<DeleteExample>();
//Querying the Student records
Acclist = [select id,name,industry from account];
//Iterating through all the records of the student object
for(integer i =0;i<Acclist.size();i++){
//Creating a new Object of InnerClass
DeleteExample conObj = new DeleteExample(false,Acclist[i]);
accWrap.add(conObj);
}
}
//Method to delete the selected records
public pagereference deletecheckedRecs (){
//Iterating through the list
for(integer i=0;i<accWrap.size();i++){
//Fetching data of the selected records
if(accWrap[i].checkbox == true){
//deleting student records based on lists index
delete accWrap[i].accObj;
}
}
// create visualforce page with name deleteWrapperExample
pagereference ref = new pagereference('/apex/AccountDeleteWrapperPage');
ref.setredirect(true);
return ref;
}
//Inner Class
public class DeleteExample{
public boolean checkbox{get;set;}
public account accObj{get;set;}
public DeleteExample(boolean checkbox,account acc)
{
checkbox = checkbox;
accObj = acc;
}
}
}
Please mark this as best answer if this solves your problem.
Thank you
Ajay Dubedi