+ Start a Discussion
cnp_nareshcnp_naresh 

How to concatenate tow variables in visualforce

HI all,

 

        In visualforce we can write like this.

<apex:inputField value="{!CreateAnEvent.Event_title__c}" style="width:250px" id="Eventinfo_title"/>.

 

Is it possible to concatenate another variable which is defined in apex class to the value attribute in <apex:inputField>. Its a very urgent requirement.Please help me. 

 

My requirement is, I will select few field names randomly  of an Object in apex class.I need to display these fields dynamically in visualforce page. How can I achieve this.

 

If you need any other information please let me know.

 

Thanks,

Naresh B                   

 

Best Answer chosen by Admin (Salesforce Developers) 
ashish raiashish rai

Hello,

  Well you can use <apex:inputtext> insted of <apex:inputfield. But if you want to use <apex:inputfield then you must have to concatinate the field inside you controller then bind this with <apex:inputfield >value. You can you <apex:inputtext> field like this:

 

<apex:page standardController="Contact">
  <apex:form>
      <apex:inputText value="{!contact.firstname } {!contact.lastname}">     
      </apex:inputText>
  </apex:form>
</apex:page>

 

Think this will help you.

All Answers

ashish raiashish rai

Hello,

  Well you can use <apex:inputtext> insted of <apex:inputfield. But if you want to use <apex:inputfield then you must have to concatinate the field inside you controller then bind this with <apex:inputfield >value. You can you <apex:inputtext> field like this:

 

<apex:page standardController="Contact">
  <apex:form>
      <apex:inputText value="{!contact.firstname } {!contact.lastname}">     
      </apex:inputText>
  </apex:form>
</apex:page>

 

Think this will help you.

This was selected as the best answer
ChandrakanthChandrakanth

Hi,

 

<apex:outputText value="{!Object_2__c.LastModifiedBy.FirstName} {!Object_2__c.LastModifiedBy.LastName} {!Object_2__c.LastModifiedDate}"/>

 

 

but i am not getting space between my first name , Lats name and date....

 

 

how can i put one or more spaces between them....?




Rama Gaikwad 5Rama Gaikwad 5
Hi Ashish ,
I tried your code but its throwing a error 
i.e.
Attribute value in <apex:inputText> must contain only a formula expression that resolves to a single controller variable or method in CreateContactVf .

Thanks 
R@ma.