0

I have create two fieldset and working as wizard format first page showing first fieldset and second page showing second fieldset (using next,previoud commandbutton) . Fieldset label are showing but its respective data not showing on VFpage.

this is my class public with sharing class wizardFieldsetController { public list account{get; set;} public list account2{get; set;} public String fields ='';

public list<Account> geta() {
    if(account == null) account = new list<Account>();
    for(Schema.FieldSetMember f : SObjectType.Account.FieldSets.AccountFieldSet.getFields()) {
        fields += f.getFieldPath() + ',';
    }

    fields = fields.removeEnd(',');
    String queryString = 'SELECT '+fields+' FROM Account';
    account = Database.query(queryString);
    return account;

}

public list<Account> getb() {
    if(account2 == null) account2 = new list<Account>();
    for(Schema.FieldSetMember f : SObjectType.Account.FieldSets.AccountFieldSet2.getFields()) {
        fields += f.getFieldPath() + ',';
    }

    fields = fields.removeEnd(',');
    String queryString = 'SELECT '+fields+' FROM Account';
    account2 = Database.query(queryString);
    return account2;

}
public pageReference next() {
    return page.wizardFieldset2;
}
public pageReference previous() {
    return page.wizardFieldset;
}

public PageReference save() {
    upsert account;

    upsert account2;
    return null;

}

}

this is my first vfpage

</apex:pageBlockTable>
<apex:pageBlockButtons>
 <apex:commandButton value="Next" action="{!next}" />
 </apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

this is my second vfPage

<apex:pageBlockTable value="{!account2}" var="templist" rules="rows">
  <apex:repeat value="{!$ObjectType.Account.FieldSets.AccountFieldset2}" var="f">
    <apex:column headervalue="{!f.label}">
       <apex:inputField value="{!templist[f.fieldPath]}"> </apex:inputField>
    </apex:column>
</apex:repeat>
</apex:pageBlockTable>

<apex:pageBlockButtons>
 <apex:commandButton value="Previous" action="{!previous}" />
      <apex:commandButton value="Save" action="{!save}" />
 </apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

1

I am assuming you using same controller for all pages, Please use the PageRefrence redirect metehod to maintain state of controller.

https://developer.salesforce.com/docs/atlas.en-us.200.0.apexcode.meta/apexcode/apex_System_PageReference_setRedirect.htm

Thanks,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.