• Akshata Asukar 10
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi I am currently working on a requirement, which requires the user to enter details in VF page 1 click next and enter details on VF page 2, enter details and again click next, then perform the insertion of record on clicking a button in VF page 3. All the pages use the same controller. Can any one help me how to accomplish this. My code is pasted below.

Controller
public class RedirectionController
{
    public Marchendise__c mar{get;set;}
    public integer num{get;set;}
    public RedirectionController()
    {
    }
    
    public PageReference NextPage()
    {
    System.debug('+++debug+++'+mar);
        PageReference pg=new PageReference('/apex/SecondPage');
        pg.setRedirect(false);
        return pg;
    }
    
     public PageReference NextPage2()
    {
    System.debug('+++debug2+++'+mar);
    System.debug('++num++'+num);
        PageReference pg=new PageReference('/apex/FinalPage');
        pg.setRedirect(false);
        return pg;
    }
    public void Save()
    {
    insert mar;
    }
}

PAGE 1
<apex:page controller="RedirectionController">
  <apex:form>
  <apex:pageBlock>
  <apex:inputField value="{!mar.Line_Item__c}"/>
  <apex:pageBlockButtons title="Next" >
  <apex:commandButton value="Next" action="{!NextPage}">
  </apex:commandButton>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

PAGE 2
<apex:page controller="RedirectionController">
 <apex:form>
  <apex:pageBlock>
  <apex:inputField value="{!mar.Price__c}"/>
  <apex:pageBlockButtons title="Next" >
  <apex:commandButton value="Next" action="{!NextPage2}"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

PAGE 3
<apex:page controller="RedirectionController">
  <apex:form>
  <apex:pageBlock>
  <apex:inputField value="{!mar.Quantity__c}"/>
  <apex:pageBlockButtons title="Next" >
  <apex:commandButton value="Next" action="{!Save}"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

In the end I get error as Attempt to dereference null object because there is no data in mar instance of Marchendise__c.

 
Hi I am currently working on a requirement, which requires the user to enter details in VF page 1 click next and enter details on VF page 2, enter details and again click next, then perform the insertion of record on clicking a button in VF page 3. All the pages use the same controller. Can any one help me how to accomplish this. My code is pasted below.

Controller
public class RedirectionController
{
    public Marchendise__c mar{get;set;}
    public integer num{get;set;}
    public RedirectionController()
    {
    }
    
    public PageReference NextPage()
    {
    System.debug('+++debug+++'+mar);
        PageReference pg=new PageReference('/apex/SecondPage');
        pg.setRedirect(false);
        return pg;
    }
    
     public PageReference NextPage2()
    {
    System.debug('+++debug2+++'+mar);
    System.debug('++num++'+num);
        PageReference pg=new PageReference('/apex/FinalPage');
        pg.setRedirect(false);
        return pg;
    }
    public void Save()
    {
    insert mar;
    }
}

PAGE 1
<apex:page controller="RedirectionController">
  <apex:form>
  <apex:pageBlock>
  <apex:inputField value="{!mar.Line_Item__c}"/>
  <apex:pageBlockButtons title="Next" >
  <apex:commandButton value="Next" action="{!NextPage}">
  </apex:commandButton>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

PAGE 2
<apex:page controller="RedirectionController">
 <apex:form>
  <apex:pageBlock>
  <apex:inputField value="{!mar.Price__c}"/>
  <apex:pageBlockButtons title="Next" >
  <apex:commandButton value="Next" action="{!NextPage2}"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

PAGE 3
<apex:page controller="RedirectionController">
  <apex:form>
  <apex:pageBlock>
  <apex:inputField value="{!mar.Quantity__c}"/>
  <apex:pageBlockButtons title="Next" >
  <apex:commandButton value="Next" action="{!Save}"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

In the end I get error as Attempt to dereference null object because there is no data in mar instance of Marchendise__c.

 
Hi All,

I am doing Apex Rest Callouts in Trailhead Apex Integration Service Module.
https://developer.salesforce.com/trailhead/force_com_dev_intermediate/apex_integration_services/apex_integration_rest_callouts

This is AnimalLocator class.
public class AnimalLocator{
    public static String getAnimalNameById(Integer x){
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        
        req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/' + x);
        
        req.setMethod('GET');
        
        HttpResponse res = h.send(req);
        Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
        Map<String, Object> animal = (Map<String, Object>) results.get('animal');
        return (String)animal.get('name');
    }
}
However, I was encountered this error when checking challenge.
Challenge Not yet complete... here's what's wrong: 
The Apex class does not appear to be calling the REST endpoint using HttpRequest.
I have no idea what it means, but I have call the REST endpoint.
  • December 24, 2015
  • Like
  • 0