You need to sign in to do that
Don't have an account?
Pravi_1133
method return type for field type text.
Hi,
I have declared a field "Description__C" and itsdata type is "TEXT".
I am trying to return this field value using a <apex:outputText value={a.Description}/>. But I am getting error with resturn type.
VF page:
<apex:pageBlockTable value="{!lstDspMrch}" var="Prd">
<apex:column headerValue="Description">
<apex:outputText value="{!Prd.Desc}" /> </apex:column>
</apex:pageBlockTable>
Controller:
Public String Desc{
get
{
return Merchnd.Desc__c;
}
}
Error message:
Error Error: clsApexEx2 Compile Error: unexpected token: 'String' at line 36 column 15
Thanks in advance for your help.
I have declared a field "Description__C" and itsdata type is "TEXT".
I am trying to return this field value using a <apex:outputText value={a.Description}/>. But I am getting error with resturn type.
VF page:
<apex:pageBlockTable value="{!lstDspMrch}" var="Prd">
<apex:column headerValue="Description">
<apex:outputText value="{!Prd.Desc}" /> </apex:column>
</apex:pageBlockTable>
Controller:
Public String Desc{
get
{
return Merchnd.Desc__c;
}
}
Error message:
Error Error: clsApexEx2 Compile Error: unexpected token: 'String' at line 36 column 15
Thanks in advance for your help.
In the controller - you need to define the get method as a method get() - please check the following doc for code snippet:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_methods.htm
All Answers
In the controller - you need to define the get method as a method get() - please check the following doc for code snippet:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_methods.htm
After changing it as a getter method my code is working.
Below code works perfectly fine.
Public String getDesc()
{
return Merchnd.Desc__c;
}
If I had declared my Desc__C as textarea data type, then my code would have worked (return type string works).
My question is if I want to code like I mentioned in my question, then what is the return type for data type TEXT.
Thanks once again.
---Praveen.
Even when you have the data type as text for the field - you can choose the return type for the method as String.