You need to sign in to do that
Don't have an account?
df_ritu
Error: Read only property while passing value from URL into input text
Hi,
I am looking to pass the parameter passed through the URL ../apex/New_Lead?msg=test into a custom field called Web_Lead_Source__c.
Below is my code:
<apex:page standardController="contact" extensions="setValfromURL" > Your page redirected from: {!message}<br/> <!-- {!$CurrentPage.URL}<br/>--> <!--{!$CurrentPage.parameters.msg}--> <apex:sectionHeader title="New Lead"/> <apex:form > <apex:pageBlock title="Information" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Submit"/> <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Contact Information"> <apex:inputField id="contactFirstName" value="{!contact.firstName}"/> <apex:inputField id="contactLastName" value="{!contact.lastName}"/> <apex:inputField id="contactPhone" value="{!contact.phone}"/> <apex:inputField id="Source" value="{!contact.Web_Lead_Source__c}"/> <apex:inputField id="Medium" value="{!contact.Web_Lead_Medium__c}"/> <apex:inputField id="contactEmail" value="{!contact.email}"/> <apex:inputText id="Source1" value="{!message}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class setValfromURL { private ApexPages.StandardController controller; public setValfromURL(ApexPages.StandardController controller) { this.controller = controller; } public String getMessage(){ String a = ApexPages.currentPage().getParameters().get('msg'); return a; } }
The first reference to {!message} works fine but the second reference to {!message} gives an error : Error: Read only property '[setValfromURL].message'
I am also able to use {!$CurrentPage.parameters.msg} to display the parameter value, but I am not able to pass it into the inputText.
Please advice.
Thanks,
Ritu
To use {!message} in an inputText, you need a setMessage(String s) method in your controller.
All Answers
To use {!message} in an inputText, you need a setMessage(String s) method in your controller.
Hi,
If you are defining the properties like below as you did:
public String getmessage()
{
//String a = ApexPages.currentPage().getParameters().get('msg');
return 'a';
}
but you are trying to bind with <apex:inputfield> which mean you are trying to modify the value of read only property "message" in your visualforce page , this is region you are getting the error, if you will use the message value only for display purpose you will not get any error as
ex: <apex:outputText value="{!message}"></apex:outputText>
which behave like read only
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.