You need to sign in to do that
Don't have an account?
Seemingly simple get/set problem
Hello.
On a page, I have an inputtext field called "giftItemCost". In the custom controller, I'm referencing that value directly in a SOQL query.
When I use the following, it works fine:
public decimal giftItemCost {get; set;}
However, in order to do unit testing (and thus assign a value to the inputtext during testing), I need an explicit getter and setter. So, when I switch it to the following, it doesn't work:
public decimal giftItemCost; public decimal getGiftItemCost() { return giftItemCost; } public void setGiftItemCost(Decimal d) { giftItemCost = d; }
Not only does it not work, but the button on the VF page stops working entirely. Oddly, my VF page has a series of other inputtext fields, and all of them are working properly using the latter explicit get/set version of the code.
Any explanation would be very appreciated. Thank you.
-Greg
You don't have to have explicit getter setter. You can still call the get/set method by using
ClassName.VariableName = AssignedValue
Can you send your test method here?
All Answers
You don't have to have explicit getter setter. You can still call the get/set method by using
ClassName.VariableName = AssignedValue
Can you send your test method here?
Hi Osama, and thanks for the reply.
Thanks for the tip regarding assigning values without explicitly calling get/set. I've modified my test method, and everything works perfectly. I have included the complete test method below, as requested, and I'm still not sure why writing it as an explicit get/set didn't work.
-Greg