+ Start a Discussion
KeithlarsKeithlars 

similar vs page works with standard object but not custom object

The first vs page using opportunity work fine when access page via list view button.

 

The second vs page using a custom object doesn't.  Why not?

 

 

<apex:page standardController="Org_Contact_Analysis__c" recordSetVar="Org_Contacts"
tabStyle="Org_Contact_Analysis__c" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pagemessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Org_Contact_Analysis__c}" var="c">
<apex:column value="{!c.ContactID__c}"/>
<apex:column headerValue="Title">
<apex:inputField value="{!Org_Contact_Analysis__c.Title__c}"/>
</apex:column>
<apex:column headerValue="Local Owner">
<apex:inputField value="{!Org_Contact_Analysis__c.Local_Owner_ID__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 



<apex:page standardController="Opportunity" recordSetVar="opportunities"
tabStyle="Opportunity" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunities}" var="opp">
<apex:column value="{!opp.name}"/>
<apex:column headerValue="Stage">
<apex:inputField value="{!opp.stageName}"/>
</apex:column>
<apex:column headerValue="Close Date">
<apex:inputField value="{!opp.closeDate}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 


mtbclimber: Moved code into SRC Blocks

 

Message Edited by mtbclimber on 01-24-2009 08:57 AM
mtbclimbermtbclimber

The second page fails to compile, right?

 

The reason it isn't working is that you are trying to assign the single prototype object,  Org_Contact_Analysis__c to the value attribute on pageBlockTable. You should be assigning the variable that refers to the collection that you declared in the page tag with recordSetVar.

 

Looks like you also had some direct bindings to the prototype object rather than the given row in the collection.   I'm not sure whether that was intentional or not.

 

NOTE: I also removed the tabstyle declaration, it's not necessary when a standardController is used unless you want to override the selected tab.

 

Try this:

<apex:page standardController="Org_Contact_Analysis__c" recordSetVar="Org_Contacts" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pagemessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Org_Contacts}" var="c">
<apex:column value="{!c.ContactID__c}"/>
<apex:column headerValue="Title">
<apex:inputField value="{!c.Title__c}"/>
</apex:column>
<apex:column headerValue="Local Owner">
<apex:inputField value="{!c.Local_Owner_ID__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Message Edited by mtbclimber on 01-24-2009 09:05 AM
KeithlarsKeithlars
That worked. Thanks.