• Johannes Pohlmann
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi all,
I'm fairly new to Salesforce, especially Visualforce, so this might be a rather simple problem but I can't figure it out. I'm trying to create a VF Page with a lookup field for users to select a Course__c and then pass the selected Course as a parameter to an apex method for further processing. The lookup field itself is not a problem, neither is passing a hardcoded value (here the three question marks as a string) but how can I dynamically assign the selected value from the lookup to my parameter?
Thank you

VF-Page:
<apex:page controller="mycontroller">  
    <apex:form >
        <apex:inputField label="Find a Course" id="theLookup" value="{!Firstname.Course__c}"/>
        <apex:commandButton value="GO" action="{!processButtonClick}" rerender="hiddenBlock">
            <apex:param name="myCourse"
                value="???"
                assignTo="{!myCourse}"/>
        </apex:commandButton>
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public with sharing class mycontroller {
    public Course__c myCourse {
        get;
        set {
            myCourse = value;
        }
    }
    public Course_Group__c getFirstname(){
        return new Course_Group__c();
    }
    public PageReference processButtonClick() {
        System.debug('nickName: '+myCourse);
        // here I'd call my apex method with the selected Course as parameter
        return null;
    }
}

Hi all,
I'm fairly new to Salesforce, especially Visualforce, so this might be a rather simple problem but I can't figure it out. I'm trying to create a VF Page with a lookup field for users to select a Course__c and then pass the selected Course as a parameter to an apex method for further processing. The lookup field itself is not a problem, neither is passing a hardcoded value (here the three question marks as a string) but how can I dynamically assign the selected value from the lookup to my parameter?
Thank you

VF-Page:
<apex:page controller="mycontroller">  
    <apex:form >
        <apex:inputField label="Find a Course" id="theLookup" value="{!Firstname.Course__c}"/>
        <apex:commandButton value="GO" action="{!processButtonClick}" rerender="hiddenBlock">
            <apex:param name="myCourse"
                value="???"
                assignTo="{!myCourse}"/>
        </apex:commandButton>
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public with sharing class mycontroller {
    public Course__c myCourse {
        get;
        set {
            myCourse = value;
        }
    }
    public Course_Group__c getFirstname(){
        return new Course_Group__c();
    }
    public PageReference processButtonClick() {
        System.debug('nickName: '+myCourse);
        // here I'd call my apex method with the selected Course as parameter
        return null;
    }
}