2

I am having a field, Final_Step__c which is of data type Text Area.

I am showing it in VF page:

but, due to maximum length issue of <apex:textarea> i wanted to use html <textarea> component with maxlength attribute.

so, any idea how to use <textarea> component in VF page?

  • are you referring to apex:inputTextArea? I don't know of an apex:textarea component per the VF doc. – cropredy Apr 18 '14 at 23:25
  • <textarea> is a HTML component – SFDC Geek Apr 19 '14 at 0:36
2

VF component apex:inputTextArea generates textArea as underlying HTML. To support the maxlength attribute, you use HTML-5 pass-through attributes as documented here.

Here is a simple example (no controller extension required):

<apex:page standardController="Foo__c" doctype="html-5.0">
 <apex:form >
   <apex:commandButton value="save" action="{!save}"/>
   <apex:inputTextArea value="{!Foo__c.bar__c}" html-maxlength="10" rows="2" cols="10"/>
 </apex:form>
</apex:page>

The above assumes field bar__c is of type textArea as per your problem statement

Notes

  1. apex:page requires adding attribute doctype="html-5.0"
  2. You 'pass through' the VF attribute html-maxlength to the underlying textarea HTML-5 maxlength attribute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.