You need to sign in to do that
Don't have an account?
Mario Hammer
Getters and Setters for Observables
Hi everyone,
I have this piece of code:
Does anyone know how to achieve this?
I have this piece of code:
/* Free Allotments */ public ObservableInteger freeAllotments = new ObservableInteger(); public Integer getFreeAllotments(){ return freeAllotments.getInteger(); } public void setFreeAllotments(Integer newValue) { freeAllotments.setInteger(newValue); }The ObservableInteger is a class that follows the standard observer pattern. I want this to look like an Integer property for the visualforce page to use standard components:
<apex:inputText value="{!freeAllotments}" />When I try to save the VF page, I get: Read only property 'ContractWizardCtrl.freeAllotments'
Does anyone know how to achieve this?
I've found one dirty hack. Did some renaming for the Observable and inserted an Integer that fits to the getters / setters: I don't like this solution but the behaviour of the page is as I want it. Does anyone have a better solution?
Mario, I think the way you have it is about the cleanest you're going to get it. Alternatively, you could combine the get and set methods in one varaible declaration, as seen in the example below. In the example, I've also moved the ObservableInteger initialization to the constructor, as in my opinion, this is cleaner yet.