Let me 1st start by saying, I have looked all over the net for an answer, could not gt it done. Thought it would be simple. But is not working.
Problem: RoomType variable is not getting set. It is coming in as NULL, which I am passing to my SOQL as a parameter.
Where am I going wrong ? ANy better ideas to resolve this matter?
TIA
Page 1
<apex:inputField value="{!Transactions__c.Room_Type__c}" label="Room Type" />
<apex:inputField value="{!Transactions__c.Transaction_Type__c}" label="Transaction Type"/>
<apex:inputField value="{!Transactions__c.Check_In_Date__c}" label="CheckIn Date"/>
<apex:commandlink id="CLink" value="Check Availability" onclick="window.open('https://na15.salesforce.com/apex/GetAvailableRooms','_blank','height=600,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1', 1)" style="background:#99CCFF; font-weight=bold" >
<apex:param name="RoomType" value="{!Transactions__c.Room_Type__c}"/> </apex:commandlink>
In short the Command Link "Check Availability" is opening up another page GetAvailableRooms using windows.open
Page: GetAvailableRooms
<apex:page controller="getAvailableRooms" sidebar="false">
<apex:pageBlock >
<apex:pageBlockTable value="{!AvailableRooms}" var="AR">
<apex:column value="{!AR.Date__c}"/>
<apex:column value="{!AR.Room_Type__c}"/>
<apex:column value="{!AR.Room_Number__c}"/>
<apex:column value="{!AR.Room_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Controller: getAvailableRooms
public class getAvailableRooms{
// ApexPages.StandardSetController must be instantiated
// for standard list controllers
public String RoomType {get; set;}
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT Room_Type__c, Room_Number__c, Room_Status__c, Date__c FROM Room_Availabiity__c
WHERE Date__c >= TODAY AND Room_Type__c = :RoomType
//AND Room_Type__c = :RoomType
ORDER BY Date__c ASC, Room_Type__c ASC]));
}
return setCon;
}
set;
}
// Initialize setCon and return a list of records
public List<Room_Availabiity__c> getAvailableRooms() {
RoomType = ApexPages.CurrentPage().getParameters().get('RoomType');
System.debug(RoomType);
return (List<Room_Availabiity__c>) setCon.getRecords();
}
}