0

I have passed some Parameters across the URL string and I am trying to display one of two strings dependant on the value. I'm not getting any errors in my apex or on my VFP but it is returning blank.

Here is my APEX code

// get and set sub from url
public String submittedForm { get; set; }
public String theLRProdID { get; set; }
public String showLRstring { get; set; }
public String valueOne { get; set; }
public String valueTwo { get; set; }
public String showString { get; set; }
public String showSub { get; set; }

public String getIDSAstring() {
    theLRProdID = Apexpages.currentPage().getParameters().get('prodId');   
    String showID = theLRProdID;


    return showID;
}

// String for leadership ready header

public String showLRstring() { 
    submittedForm = Apexpages.currentPage().getParameters().get('sub');
    String showSub = submittedForm;
    return showSub;

    String valueOne = 'Please check over the details below and click the green submit button to confirm your Training Plan.';
    String valueTwo = 'Thank you for submitting your details. Click on the blue print button to print your Training Plan for future reference.';

    //If the form is submitted show value 2.         
    if (showSub != 'submitted'){
        String showString = valueOne;
    } else{
        String showString = valueTwo;
    }

    return showString;


}

And here is my VFP code

        <apex:facet name="caption"><p id="introText">{!showLRstring}</p></apex:facet>

Any ideas? Thanks.

2
  • Is that my answer works for you? Aug 3, 2017 at 4:37
  • I had to make some additional changes to your code. I will paste it below. Thanks for your help. Aug 3, 2017 at 5:29

3 Answers 3

1

There are lot of improvements are needed.

First of all you have declared method and property with the same name showLRstring. Make it distinct.

you have declared class level variable and local variable with same name as showString. Make it distinct.

Due to the following code and return statement, rest of the method will not execute

public String showLRstring() { 
    submittedForm = Apexpages.currentPage().getParameters().get('sub');
    String showSub = submittedForm;
    return showSub; //method is returned from here

Controller

// get and set sub from url
public String submittedForm { get; set; }
public String theLRProdID { get; set; }

public String valueOne { get; set; }
public String valueTwo { get; set; }
public String showString { get; set; }
public String showSub { get; set; }

public String getIDSAstring() {
    theLRProdID = Apexpages.currentPage().getParameters().get('prodId');   
    String showID = theLRProdID;
    return showID;
}

// String for leadership ready header

public String showLRstring() { 
    submittedForm = Apexpages.currentPage().getParameters().get('sub');
    String showSub = submittedForm;

    String valueOne = 'Please check over the details below and click the green submit button to confirm your Training Plan.';
    String valueTwo = 'Thank you for submitting your details. Click on the blue print button to print your Training Plan for future reference.';

    //If the form is submitted show value 2.         
    if (showSub != 'submitted'){
        showString = valueOne;
    } else{
        showString = valueTwo;
    }
    return showString
}

Visualforce

<apex:facet name="caption"><p id="introText">{!showString}</p></apex:facet>

Note: I haven't complied the code, tried to guide you.

0

Assign the showString value to showLRstring variable before return statement.

showLRstring = showString;

Thanks, Syed

1
  • thank you Syed for your reply. But still empty... Aug 2, 2017 at 1:33
0

Here is what I got working

// get and set sub from url
public String theLRProdID { get; set; }


//Get and Set String
public String LeadershipReadyHeader {get; set;}
public String buttonClass {get; set;}
public String subAnswer {get; set;}



public String getIDSAstring() {
    theLRProdID = Apexpages.currentPage().getParameters().get('prodId');   
    String showID = theLRProdID;
    return showID;
}

// String for leadership ready header

Then inside the constructor

 private void getLeadershipReadyHeader() {
     //subAnswer = '0';

    //submittedForm = Apexpages.currentPage().getParameters().get('sub');
    subAnswer =  myLeadershipReady.Automated_TP_Status__c;



         if(subAnswer != '1'){
          LeadershipReadyHeader = 'Please check over the details below and click the <span class="greenText">green submit button</span> to confirm your Training Plan.';
             buttonClass = 'action-button';
         }
     else{
         LeadershipReadyHeader = 'Thank you for submitting your details. Click on the <span class="blueText">blue print button</span> to print your Training Plan for future reference.';
            buttonClass = 'disabledButt';
        }
   }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .