Hi all i am trying to access the inputfield value that the user selects and then pass it to an SOQL query in my controller extension then return the SOQL result to an outputText compunent, my code is shown below:
Visualforce
<apex:page standardController="Ships_Book__c" extensions="sBookController">
<apex:pageBlock title="Ships Book">
<apex:pageBlockSection >
<apex:form >
<apex:inputField value="{!Ships_Book__c.Vessel_Name__c}" id="Vessel_Name">
<apex:actionSupport event="onchange" action="{!setsWeight}"/>
</apex:inputField>
Vessel Weight
<apex:outputText value="{0}">
<apex:param value="{!sWeight}"/>
</apex:outputText>
</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Apex
public class sBookController {
private ApexPages.StandardController stdCtrl {get; Set;}
public integer sWeight;
public sBookController(ApexPages.StandardController std) {
stdCtrl = std;
}
public integer getsWeight() {
return sWeight;
}
public void setsWeight() {
sWeight= [SELECT Vessel_weight__C FROM Vessel_Weight__c WHERE Vessel_Name__c =: ship.Vessel_Name__c Limit 1];
}
}
Any help would be greatly appreciated as i am just learning
Thanks