• RamyaS
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi,

Is there a function any function in VF similar to TRIM, in VF which is used to trim a string to a specific length?

EX: {!Opportunity__r.Name} I want to display only the string if length 10 characters.

Can I use any FORMAT function

Thanks.
  • December 09, 2008
  • Like
  • 0
We have a VF page that uses multiple instances of a custom component, when we pass information in through the Component attributes, and try to get them to the Component Controller, they are not setting before a apex:dataTable reads from the controller.
 
Example:
 
----------------------------
Page has this code: (this segment is inside of a PageBlockSection)
 
<tr>
<td><c:MedComp cnId="{!cn__c.id}" medGrp="ACONV"/></td>
<td><c:MedComp cnId="{!cn__c.id}" medGrp="STIM"/></td>
</tr>
----------------------------
Component has this code:
 
<apex:component controller="MedCompController">
    <apex:attribute name="cnId" type="String" required="true" description="Cn ID" assignTo="{!cnID}"></apex:attribute>
    <apex:attribute name="medGrp" type="String" required="true" description="Med Group" assignTo="{!medGrp}"></apex:attribute>
    <apex:dataTable value="{!meds}" var="med">
        <apex:column >
            <apex:facet name="header">Trade Name</apex:facet>
            <span style="{!med.tradeStyle}">{!med.tradeName}</span>
        </apex:column>   
        <apex:column >
            <apex:facet name="header">Generic Name</apex:facet>
            <span style="{!med.genericStyle}">{!med.genericName}</span>
        </apex:column>   
        <apex:column >
            <apex:facet name="header">Sensitivity</apex:facet>
            <span style="{!med.sensitivityStyle}">{!med.sensitivity}</span>
        </apex:column>   
    </apex:dataTable>   
</apex:component>
 
----------------------------
Component Controller has this code:
 
public class MedCompController
{       
    List<MedSensitivity> meds;
       
    private String cnId;
    private String medGrp;
               
    public void setCnId(String s)
    {
        cnId = s;
    }  
    public String getCnId()
    {
        return cnId;
    }
       
    public void setMedGrp(String s)
    {
        medGrp = s;
    }
    public String getMedGrp()
    {
        return medGrp;
    }
               
    public List<MedSensitivity> getMeds()
    {  
        if (meds == null )
        {
            meds = new List<MedSensitivity>();
           
            for(med__c medRow : [select trade__c, generic__c, sensitivity__c, sub_group_name__c, sub_group_sensitivity__c
                from med__c
                where
                drug_class__c = :medGrp AND cn_id__c = :cnId])
            {
                MedSensitivity medItem = new MedSensitivity();
                medItem.Setup( medRow);                                
                meds.Add( medItem);
            }      
        }
       
        return meds;
    }  
}
 
---------------------------------------------------------------
The CnID and Med groups are passed into the Component through the Attributes at the top of the component.  We have set the {assignTo} attributes, so they should call the Setter methods on the Controller, and the values should be stored on the Component.
 
The problem is that it appears as though the apex:dataTable is accessing the {meds} attribute on the Controller prior to the setter values from the attributes being set.  
 
How can we pass data into the Component Controller from the calling page, and have it availble for the building of the Data table?   There appears to be no way for this to work.
 
All the examples for the SQL in the Controller show using the Current Page parameters.  However, we will have mutliple instances of the Components on a page, and need to send different values to each one.
 
This appears to be a bug in Visual Force.
 
Thanks,
Steve