You need to sign in to do that
Don't have an account?
Kumar5
It should show edit page once the records are saved in tab1
Hello All,
I have created Vf page with two different tabs. I want to know how to show it in edit page once the records are saved in tab1.
Can any one help me how to achieve it
below is the code :
<apex:page controller="ManageApplicationController" tabstyle="Account">
<apex:tabPanel switchType="client" selectedTab="Student" id="theTabPanel">
<apex:tab label="Studnet" name="name1" id="tabOne">
<apex:form >
<apex:repeat value="{!Manageapp}" var="item">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!item.Std.Name}"/>
<apex:inputField value="{!item.Std.stunumber__c}"/>
</apex:pageBlocksection>
</apex:pageBlock>
</apex:repeat>
<apex:commandButton Value="save" action="{!saveText}"/>
</apex:form>
</apex:tab>
<apex:tab label="Item" name="name2" id="tabTwo">content for tab two
<apex:Form >
<apex:repeat value="{!Manageapp}" var="item">
<apex:pageBlock >
<br></br>
<apex:pageBlockSection >
<apex:inputField value="{!item.Std.city__c}"/>
<apex:inputField value="{!item.litem.Name}"/>
<apex:inputField value="{!item.litem.Linetemnumber__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:repeat>
<apex:commandButton Value="save" action="{!saveText}"/>
</apex:form>
</apex:tab>
</apex:tabPanel>
</apex:page>
Class :
public class ManageApplicationController {
public List<wrapperclass> ManageApp
{
get;
set;
}
public ManageApplicationController ()
{
ManageApp = new List<wrapperclass>();
addfields();
}
public PageReference addfields()
{
try
{
ManageApp.add(new wrapperclass(new Student__c(),new Item__c())); // Adding fields toVfpage when user click on Add Button.
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
return ApexPages.currentPage();
}
public class wrapperclass // wrapper class to handle multiple objects.
{
public student__c Std{get;set;}
public Item__c litem{get;set;}
public wrapperclass(Student__c Std,Item__c lit)
{
this.std = Std;
this.litem = lit;
}
}
public PageReference saveText() // this method for inserting records into multiple objects.
{
try
{
List<student__c> listStudent = new List<student__c>();
List<Item__c> lineItem = new List<Item__c>();
for(wrapperclass item : ManageApp)
{
listStudent.add(item.Std);
lineItem.add(item.litem);
}
if(listStudent.size() > 0 && lineItem.size() > 0)
upsert lineItem; // Inserting records in to multiple objects
upsert listStudent;
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
return ApexPages.currentPage();
}
}
Thanks,
Kumar
I have created Vf page with two different tabs. I want to know how to show it in edit page once the records are saved in tab1.
Can any one help me how to achieve it
below is the code :
<apex:page controller="ManageApplicationController" tabstyle="Account">
<apex:tabPanel switchType="client" selectedTab="Student" id="theTabPanel">
<apex:tab label="Studnet" name="name1" id="tabOne">
<apex:form >
<apex:repeat value="{!Manageapp}" var="item">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!item.Std.Name}"/>
<apex:inputField value="{!item.Std.stunumber__c}"/>
</apex:pageBlocksection>
</apex:pageBlock>
</apex:repeat>
<apex:commandButton Value="save" action="{!saveText}"/>
</apex:form>
</apex:tab>
<apex:tab label="Item" name="name2" id="tabTwo">content for tab two
<apex:Form >
<apex:repeat value="{!Manageapp}" var="item">
<apex:pageBlock >
<br></br>
<apex:pageBlockSection >
<apex:inputField value="{!item.Std.city__c}"/>
<apex:inputField value="{!item.litem.Name}"/>
<apex:inputField value="{!item.litem.Linetemnumber__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:repeat>
<apex:commandButton Value="save" action="{!saveText}"/>
</apex:form>
</apex:tab>
</apex:tabPanel>
</apex:page>
Class :
public class ManageApplicationController {
public List<wrapperclass> ManageApp
{
get;
set;
}
public ManageApplicationController ()
{
ManageApp = new List<wrapperclass>();
addfields();
}
public PageReference addfields()
{
try
{
ManageApp.add(new wrapperclass(new Student__c(),new Item__c())); // Adding fields toVfpage when user click on Add Button.
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
return ApexPages.currentPage();
}
public class wrapperclass // wrapper class to handle multiple objects.
{
public student__c Std{get;set;}
public Item__c litem{get;set;}
public wrapperclass(Student__c Std,Item__c lit)
{
this.std = Std;
this.litem = lit;
}
}
public PageReference saveText() // this method for inserting records into multiple objects.
{
try
{
List<student__c> listStudent = new List<student__c>();
List<Item__c> lineItem = new List<Item__c>();
for(wrapperclass item : ManageApp)
{
listStudent.add(item.Std);
lineItem.add(item.litem);
}
if(listStudent.size() > 0 && lineItem.size() > 0)
upsert lineItem; // Inserting records in to multiple objects
upsert listStudent;
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
return ApexPages.currentPage();
}
}
Thanks,
Kumar