-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
2Questions
-
4Replies
Update Class and Page
I want to update the class and vforce page for something that was already created for my organization. I want to mimic it to keep everything similar and it was made by a 3rd party developer who decided to stop consulting. Here is the new object and fields i want to replace the existing with. It seems that the class and page is complex for a simple add and remove fields. Simply replace everywhere audienceunitlineitem. Any help would be great.
New Object -
Audience_Direct__c
New Fields
Segment_ID__c Segment_Name__c Data_Provider__c Uniques__c Impression_s__c CPMU__c CPM__c Total_Value__c
Class
}
public with sharing class adUnitLineItemExtension
{
private final Publisher_Site__c p;
ApexPages.StandardController stdController;
public Publisher_Site__c publisher { get; set; }
public List<AUWrapper> adUnitLines { get; set; }
public String focusedLi { get; set; }
public Integer wrapperID { get; set; }
public Boolean saveError { get; set; }
public String errorMessage { get; set; }
//Extension Constructor
public adUnitLineItemExtension(ApexPages.StandardController stdCont)
{
stdController = stdCont;
p = (Publisher_Site__c)stdController.getRecord();
publisher = [SELECT Id, Publisher_Tier__c, Name, Geo_Target__c from Publisher_Site__c where Id = :p.Id LIMIT 1];
adUnitLines = new List<AUWrapper>{};
focusedLi = '';
wrapperID = 0;
saveError = false;
errorMessage = 'You must set an Ad Size, an Ad Position, and one or more Geotargets before you may save an Ad Unit!';
if (publisher != null)
{
List<Ad_Unit__c> auLis = [SELECT Id,
Name,
Unit_Name__c,
Ad_Size__c,
Ad_Positioning__c,
Geotarget__c,
Publisher_Site__c
from Ad_Unit__c
where Publisher_Site__c = :publisher.Id
LIMIT 1000];
for(Ad_Unit__c l : auLis)
{
AUWrapper wrapper = new AUWrapper(wrapperID++);
wrapper.adUnit = l;
wrapper.isNew = false;
adUnitLines.add(wrapper);
}
}
}
public void addLine()
{
AUWrapper wrapper = new AUWrapper(wrapperID++);
wrapper.adUnit.Publisher_Site__c = p.Id;
focusedLi = wrapper.wrapperID;
saveError = false;
adUnitLines.add(wrapper);
}
public void removeLine()
{
for(Integer i = 0; i < adUnitLines.size(); i++)
{
if (adUnitLines[i].wrapperID == System.currentPageReference().getParameters().get('selectedID'))
{
if (adUnitLines[i].isNew == false)
{
delete adUnitLines[i].adUnit;
}
adUnitLines.remove(i);
focusedLi = '';
saveError = false;
break;
}
}
}
public void saveLine()
{
for(Integer i = 0; i < adUnitLines.size(); i++)
{
if (adUnitLines[i].wrapperID == System.currentPageReference().getParameters().get('selectedID'))
{
if(adUnitLines[i].isNew == false)
{
saveError = ((adUnitLines[i].adUnit.Ad_Size__c == '') ||
(adUnitLines[i].adUnit.Ad_Size__c == null) ||
(adUnitLines[i].adUnit.Ad_Positioning__c == '') ||
(adUnitLines[i].adUnit.Ad_Positioning__c == null) ||
(adUnitLines[i].adUnit.Geotarget__c == '') ||
(adUnitLines[i].adUnit.Geotarget__c == null));
if(!saveError)
{
update adUnitLines[i].adUnit;
}
}
else
{
saveError = ((adUnitLines[i].adUnit.Ad_Size__c == '') ||
(adUnitLines[i].adUnit.Ad_Size__c == null) ||
(adUnitLines[i].adUnit.Ad_Positioning__c == '') ||
(adUnitLines[i].adUnit.Ad_Positioning__c == null) ||
(adUnitLines[i].adUnit.Geotarget__c == '') ||
(adUnitLines[i].adUnit.Geotarget__c == null));
if(!saveError)
{
insert adUnitLines[i].adUnit;
Ad_Unit__c au = [SELECT Id,
Name,
Unit_Name__c,
Ad_Size__c,
Ad_Positioning__c,
Geotarget__c,
Publisher_Site__c
from Ad_Unit__c
where Id = :adUnitLines[i].adUnit.Id
LIMIT 1];
if(au != null)
{
adUnitLines[i].adUnit = au;
adUnitLines[i].isNew = false;
}
}
}
focusedLi = '';
break;
}
}
}
public void editLine()
{
focusedLi = System.currentPageReference().getParameters().get('selectedID');
}
Page
</apex:page>
<apex:page standardController="Publisher_Site__c" extensions="adUnitLineItemExtension"> <apex:detail relatedList="false" > <apex:form > <apex:pageBlock id="adUnitLineItems" title="Publisher Ad Units"> <apex:outputPanel style="color: red; text-aline: center" id="messages"> <apex:outputPanel style="color: red; text-align: center" id="errorMessage" rendered="{!saveError}"> {!errorMessage} </apex:outputPanel> </apex:outputPanel> <apex:pageBlockButtons location="top"> <apex:commandButton action="{!addLine}" value="Add Ad Unit" rerender="auLines,messages" status="adding" /> <span style = "color: green"> <apex:actionStatus id="adding" startText="Adding..." /> </span> <span style = "color: blue"> <apex:actionStatus id="saving" startText="Saving..." /> </span> <span style = "color: red"> <apex:actionStatus id="deleting" startText="Deleting..." /> </span> <span style = "color: blue"> <apex:actionStatus id="editing" startText="Loading..." /> </span> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <apex:pageBlockTable id="auLines" value="{!adUnitLines}" var="auLi"> <apex:column headervalue="Action"> <apex:commandLink rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="Edit" action="{!editLine}" rerender="auLines,messages" status="editing"> <apex:param name="selectedID" value="{!auLi.wrapperID}" /> </apex:commandLink> <apex:commandLink rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="Save" action="{!saveLine}" rerender="auLines,messages" status="saving"> <apex:param name="selectedID" value="{!auLi.wrapperID}" /> </apex:commandLink> | <apex:commandLink value="Del" action="{!removeLine}" rerender="auLines,messages" status="deleting"> <apex:param name="selectedID" value="{!auLi.wrapperID}" /> </apex:commandLink> </apex:column> <apex:column headervalue="Name"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Unit_Name__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Unit_Name__c}" /> </apex:column> <apex:column headervalue="Size"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Size__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Size__c}" /> </apex:column> <apex:column headervalue="Positioning"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Positioning__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Positioning__c}" /> </apex:column> <apex:column headervalue="Geotarget"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Geotarget__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Geotarget__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:relatedList list="Cases__r" subject="{!Publisher_Site__c}" /> <apex:relatedList list="OpenActivities" subject="{!Publisher_Site__c}" /> <apex:relatedList list="ActivityHistories" subject="{!Publisher_Site__c}" /> <apex:relatedList list="NotesAndAttachments" subject="{!Publisher_Site__c}" /> <apex:pageBlock id="thePageBlock" title="Publisher Site Field History"> <apex:pageBlockTable value="{!Publisher_Site__c.Histories}" var="h"> <apex:column headerValue="Date" > <apex:outputText value="{0,date,MM/dd/yyyy HH:mm }"> <apex:param value="{!h.createddate}" /> </apex:outputText> </apex:column> <apex:column headerValue="What">{!h.field}</apex:column> <apex:column headerValue="From">{!h.oldvalue}</apex:column> <apex:column headerValue="To">{!h.newvalue}</apex:column> <apex:column headerValue="User">{!h.createdby.name}</apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:detail>
- Pip
- July 21, 2011
- Like
- 0
- Continue reading or reply
Apex Trigger
Hi,
Want to create an apex trigger that when an opportunity is saved it overwrites what a user has entered and puts the account name + a custom field. Can anyone help or give suggestions. Can this be applied to only certain opportunity types?
- Pip
- March 28, 2011
- Like
- 0
- Continue reading or reply
Update Class and Page
I want to update the class and vforce page for something that was already created for my organization. I want to mimic it to keep everything similar and it was made by a 3rd party developer who decided to stop consulting. Here is the new object and fields i want to replace the existing with. It seems that the class and page is complex for a simple add and remove fields. Simply replace everywhere audienceunitlineitem. Any help would be great.
New Object -
Audience_Direct__c
New Fields
Segment_ID__c Segment_Name__c Data_Provider__c Uniques__c Impression_s__c CPMU__c CPM__c Total_Value__c
Class
}
public with sharing class adUnitLineItemExtension
{
private final Publisher_Site__c p;
ApexPages.StandardController stdController;
public Publisher_Site__c publisher { get; set; }
public List<AUWrapper> adUnitLines { get; set; }
public String focusedLi { get; set; }
public Integer wrapperID { get; set; }
public Boolean saveError { get; set; }
public String errorMessage { get; set; }
//Extension Constructor
public adUnitLineItemExtension(ApexPages.StandardController stdCont)
{
stdController = stdCont;
p = (Publisher_Site__c)stdController.getRecord();
publisher = [SELECT Id, Publisher_Tier__c, Name, Geo_Target__c from Publisher_Site__c where Id = :p.Id LIMIT 1];
adUnitLines = new List<AUWrapper>{};
focusedLi = '';
wrapperID = 0;
saveError = false;
errorMessage = 'You must set an Ad Size, an Ad Position, and one or more Geotargets before you may save an Ad Unit!';
if (publisher != null)
{
List<Ad_Unit__c> auLis = [SELECT Id,
Name,
Unit_Name__c,
Ad_Size__c,
Ad_Positioning__c,
Geotarget__c,
Publisher_Site__c
from Ad_Unit__c
where Publisher_Site__c = :publisher.Id
LIMIT 1000];
for(Ad_Unit__c l : auLis)
{
AUWrapper wrapper = new AUWrapper(wrapperID++);
wrapper.adUnit = l;
wrapper.isNew = false;
adUnitLines.add(wrapper);
}
}
}
public void addLine()
{
AUWrapper wrapper = new AUWrapper(wrapperID++);
wrapper.adUnit.Publisher_Site__c = p.Id;
focusedLi = wrapper.wrapperID;
saveError = false;
adUnitLines.add(wrapper);
}
public void removeLine()
{
for(Integer i = 0; i < adUnitLines.size(); i++)
{
if (adUnitLines[i].wrapperID == System.currentPageReference().getParameters().get('selectedID'))
{
if (adUnitLines[i].isNew == false)
{
delete adUnitLines[i].adUnit;
}
adUnitLines.remove(i);
focusedLi = '';
saveError = false;
break;
}
}
}
public void saveLine()
{
for(Integer i = 0; i < adUnitLines.size(); i++)
{
if (adUnitLines[i].wrapperID == System.currentPageReference().getParameters().get('selectedID'))
{
if(adUnitLines[i].isNew == false)
{
saveError = ((adUnitLines[i].adUnit.Ad_Size__c == '') ||
(adUnitLines[i].adUnit.Ad_Size__c == null) ||
(adUnitLines[i].adUnit.Ad_Positioning__c == '') ||
(adUnitLines[i].adUnit.Ad_Positioning__c == null) ||
(adUnitLines[i].adUnit.Geotarget__c == '') ||
(adUnitLines[i].adUnit.Geotarget__c == null));
if(!saveError)
{
update adUnitLines[i].adUnit;
}
}
else
{
saveError = ((adUnitLines[i].adUnit.Ad_Size__c == '') ||
(adUnitLines[i].adUnit.Ad_Size__c == null) ||
(adUnitLines[i].adUnit.Ad_Positioning__c == '') ||
(adUnitLines[i].adUnit.Ad_Positioning__c == null) ||
(adUnitLines[i].adUnit.Geotarget__c == '') ||
(adUnitLines[i].adUnit.Geotarget__c == null));
if(!saveError)
{
insert adUnitLines[i].adUnit;
Ad_Unit__c au = [SELECT Id,
Name,
Unit_Name__c,
Ad_Size__c,
Ad_Positioning__c,
Geotarget__c,
Publisher_Site__c
from Ad_Unit__c
where Id = :adUnitLines[i].adUnit.Id
LIMIT 1];
if(au != null)
{
adUnitLines[i].adUnit = au;
adUnitLines[i].isNew = false;
}
}
}
focusedLi = '';
break;
}
}
}
public void editLine()
{
focusedLi = System.currentPageReference().getParameters().get('selectedID');
}
Page
</apex:page>
<apex:page standardController="Publisher_Site__c" extensions="adUnitLineItemExtension"> <apex:detail relatedList="false" > <apex:form > <apex:pageBlock id="adUnitLineItems" title="Publisher Ad Units"> <apex:outputPanel style="color: red; text-aline: center" id="messages"> <apex:outputPanel style="color: red; text-align: center" id="errorMessage" rendered="{!saveError}"> {!errorMessage} </apex:outputPanel> </apex:outputPanel> <apex:pageBlockButtons location="top"> <apex:commandButton action="{!addLine}" value="Add Ad Unit" rerender="auLines,messages" status="adding" /> <span style = "color: green"> <apex:actionStatus id="adding" startText="Adding..." /> </span> <span style = "color: blue"> <apex:actionStatus id="saving" startText="Saving..." /> </span> <span style = "color: red"> <apex:actionStatus id="deleting" startText="Deleting..." /> </span> <span style = "color: blue"> <apex:actionStatus id="editing" startText="Loading..." /> </span> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <apex:pageBlockTable id="auLines" value="{!adUnitLines}" var="auLi"> <apex:column headervalue="Action"> <apex:commandLink rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="Edit" action="{!editLine}" rerender="auLines,messages" status="editing"> <apex:param name="selectedID" value="{!auLi.wrapperID}" /> </apex:commandLink> <apex:commandLink rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="Save" action="{!saveLine}" rerender="auLines,messages" status="saving"> <apex:param name="selectedID" value="{!auLi.wrapperID}" /> </apex:commandLink> | <apex:commandLink value="Del" action="{!removeLine}" rerender="auLines,messages" status="deleting"> <apex:param name="selectedID" value="{!auLi.wrapperID}" /> </apex:commandLink> </apex:column> <apex:column headervalue="Name"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Unit_Name__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Unit_Name__c}" /> </apex:column> <apex:column headervalue="Size"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Size__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Size__c}" /> </apex:column> <apex:column headervalue="Positioning"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Positioning__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Ad_Positioning__c}" /> </apex:column> <apex:column headervalue="Geotarget"> <apex:outputField rendered="{!IF(auLi.wrapperID != focusedLi, true, false)}" value="{!auLi.adUnit.Geotarget__c}" /> <apex:inputField rendered="{!IF(auLi.wrapperID == focusedLi, true, false)}" value="{!auLi.adUnit.Geotarget__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:relatedList list="Cases__r" subject="{!Publisher_Site__c}" /> <apex:relatedList list="OpenActivities" subject="{!Publisher_Site__c}" /> <apex:relatedList list="ActivityHistories" subject="{!Publisher_Site__c}" /> <apex:relatedList list="NotesAndAttachments" subject="{!Publisher_Site__c}" /> <apex:pageBlock id="thePageBlock" title="Publisher Site Field History"> <apex:pageBlockTable value="{!Publisher_Site__c.Histories}" var="h"> <apex:column headerValue="Date" > <apex:outputText value="{0,date,MM/dd/yyyy HH:mm }"> <apex:param value="{!h.createddate}" /> </apex:outputText> </apex:column> <apex:column headerValue="What">{!h.field}</apex:column> <apex:column headerValue="From">{!h.oldvalue}</apex:column> <apex:column headerValue="To">{!h.newvalue}</apex:column> <apex:column headerValue="User">{!h.createdby.name}</apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:detail>
- Pip
- July 21, 2011
- Like
- 0
- Continue reading or reply
Apex Trigger
Hi,
Want to create an apex trigger that when an opportunity is saved it overwrites what a user has entered and puts the account name + a custom field. Can anyone help or give suggestions. Can this be applied to only certain opportunity types?
- Pip
- March 28, 2011
- Like
- 0
- Continue reading or reply