You need to sign in to do that
Don't have an account?
Laytro80
Simple question newbie and running out of time
Below is a simple VF page and Controller. You will not on the Controller I hard code the
where nights__c = 4
I want to make this dynamic using a input field on the VF page.
VF Page
<apex:page controller="Resmanager"> <apex:sectionHeader title="Availability Search"/> <apex:pageBlock title="Reservations"> <apex:pageBlockSection > <apex:pageBlockTable value="{!Reservations}" var="res"> <apex:column value="{!res.Start_Date__c}" /> <apex:column value="{!res.End_Date__c}" /> <apex:column value="{!res.Nights__c}" /> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
APEX Controller
public class Resmanager { public List<Reservation__c> getReservations(){ List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where nights__c = 4]; return listBd; } }
Now I am just fumbling around as well, being I am some what new to apex myself. try this;
All Answers
Why not create a field in your controller called something like
Then in your VF page something like
<apex:inputtext value="{!min_num_nights}"/>
where you can dynamically change the value
Then in your SOQL query
typo, meant to write
Thanks for this I get this error - Resmanager Compile Error: Invalid constructor name: getMinNumNights at line 6 column 12
sorry I typed to quickly.
you need to specify the return type so it should be
Thanks for the fast reply, that fixed the problem but I now have another issue - sorry!
I get this error -> Read only property '[Resmanager].minNumNights'
Please don't apologize. I also ask for help plenty of times.
The fault is mine. I forgot to include that you need to also create a setter. Unless you need to do some processing of the value when setting, which I don't think you do in this case, use the following when specifying the field
Integer minNumNights {set;}
this will create a default setter to allow you to set the variable.
Thanks I think we are getting closer.
Apparently you need to create the get; as well. I thought that since you are creating a get method, that is was unncessary but I added it and the error went away.
so try
Integer minNumNights {get; set;}
and see what happens
I back to the
Now I am just fumbling around as well, being I am some what new to apex myself. try this;
Still having problems but have changed a bit of the code. I think the read only problem was because I was not using the right type. Now I can render a field and if I hit enter with or without a number the query runs but it only brings back the default minimum so it's ignoring the field but it seems like progress.
To be honest this query came from somebody that want a quick solution. I have now built a report which is a temporary fix and buys me a few weeks.
Here is the VF page
And the APEX code
Thanks again for all your help.
Cheers R
Thanks again for all your help got there in the end.
glad it worked out for you. :manhappy