function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dchris222Dchris222 

Problem with a Component dataTable

What I am going for is two dataTables on the same page. I created the one dataTable using the standardController: Opportunity. I then created  a custom controller for TradeIns called TradeInController2 that will be used in a component that will create the other dataTable on the page. I am extremely new at this so I am not sure If i'm on the right track or not and what my problems are in my code.

 

For your help here are the requirements:

 

Develop a visual force page that will allow us to query both opportunities and trade ins on the same page.  It would be able to search on the following fields from each

Opp.
Close date
Equipment state
Modality

Trade in
Deinstallation date
Equipment state
Modality

 

Currently the error I am receiving when trying to save my Component is  "Error: The content of elements must consist of well-formed character data or markup."  This is my first project so any fixes for my code and or help would be extremely appreciated.  I have gone through tons of documentation, but none have good examples of what my boss is asking so I am doing the best I can...

 

Controller for Component:

 

public class TradeInController2{

    private final Trade_in__c tradein;

    public TradeInController2() {
        tradein= [select name, Deinstall_Date__c, Status__c, Modality__c from Trade_in__c ];
    }
    public Trade_in__c getTradeIn() {
        return tradein;
    }
        }

 

Component:

 

<apex:component controller="TradeInController2">

    <apex:dataTable value="{!tradein}" var="tr" cellPadding="4" border="1">
              <apex:column >
                    <apex:facet name="header">Trade-In Number</apex:facet>
                    {!tr.name}
              </apex:column>
               <apex:column >
                    <apex:facet name="header">De-Install Date</apex:facet>
                     {!tr.Deinstall_Date__c}
              </apex:column>
              <apex:column >
                    <apex:facet name="header">Equipment State</apex:facet>
                    {!tr.Status__c}
              </apex:column>
              <apex:column >
                    <apex:facet name="header">Modality</apex:facet>
                    {!tr.Modality__c}
              </apex:column>

    </apex:dataTable>

<</apex:component>

 

 

The Page:

 

<apex:page standardController="Account">
 
    <apex:pageBlock title="Hello {!$User.FirstName}">
    </apex:pageBlock>   
    <apex:pageBlock title="Opportunities">
        <apex:dataTable value="{!account.Opportunities}" var="opportunity" cellPadding="4" border="1">
              <apex:column >
                    <apex:facet name="header">Opportunity Name</apex:facet>
                    {!opportunity.Name}
              </apex:column>
              <apex:column >
                   <apex:facet name="header">Close Date</apex:facet>
                    {!opportunity.CloseDate}
              </apex:column>
              <apex:column >
                     <apex:facet name="header">Equipment state</apex:facet>
                      {!opportunity.Equipment_State__c}
              </apex:column>
              <apex:column >
                    <apex:facet name="header">Modality</apex:facet>
                     {!opportunity.Equipment_State__c}
              </apex:column>
        </apex:dataTable>
     </apex:pageBlock>
    
     <apex:pageblock title="Trade-Ins">
           <c:TradeInComponent/>
    </apex:pageBlock>


   <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/>
</apex:page>

 

Thank you for your help in advance.

 

Chris

Best Answer chosen by Admin (Salesforce Developers) 
Dchris222Dchris222

TradeIn records are not related to Opportunities field wise. There can be multiple Tradins and mulitple Opportunities. The sales/leasing department just would  like to see all of both on the same page so that they can compare the two and possibly make a connection for a future sale.

 

Turns out I just had some code typed out wrong, thanks for your help though.

 

Chris

All Answers

nhobertnhobert

Chris,

Can you clarify a little more? Are the tradein records related to an opportunity? Is there 1 tradein per opportunity or are there multiple tradins per opportunity?

 

 

Dchris222Dchris222

TradeIn records are not related to Opportunities field wise. There can be multiple Tradins and mulitple Opportunities. The sales/leasing department just would  like to see all of both on the same page so that they can compare the two and possibly make a connection for a future sale.

 

Turns out I just had some code typed out wrong, thanks for your help though.

 

Chris

This was selected as the best answer