• CapCbRM
  • NEWBIE
  • 75 Points
  • Member since 2007

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies

Hi DF,

 

I have completed a class to use as an extension of a VF page. I use it on a "Worldcolor_Project" page layout to show the Schedule associated with the project and the underlying Milestones attached to that Schedule.

 

The save and delete methods are used for VF buttons.

 

I am currently confused on how to begin my Testmethod. I started with Creating a new Worldcolor_Project and schedule related but am unsure how to test the inidividual methods. Any help would be greatly appreciated.

 

 

public with sharing class PullMilestones_Worldcolor {

    public Milestone__c[] milestones = new Milestone__c[0];
    public Schedule__c[] scheduleinfo;
   
    public PullMilestones_Worldcolor(ApexPages.StandardController controller) {
    }
    

    public Milestone__c[] getMilestones() {
        
         milestones = [SELECT ID, Name, Duration__c, Status__c, Due_Date__c,Start_Date__c,  Milestone_Status__c, Index__c, Predecessor_Index__c, Responsible__c
                        FROM Milestone__c
      WHERE Worldcolor_ProjectID__c = :ApexPages.currentPage().getParameters().get('id')
                            ORDER BY Index__c];
                            
        return milestones;
    }
    
    public void saveMile(){ UPDATE milestones; } 
       


    public Schedule__c[] getSchedule() {

        scheduleinfo = [SELECT ID, Name, Details__c, Start_Date__c, End_Date__c, Method__c, Duration__c, Overdue_Milestones__c, Risk_Status__c, Schedule_Template__c  
                            FROM Schedule__c 
                             WHERE WorldColor_Project__c = :ApexPages.currentPage().getParameters().get('id')];
        
        return scheduleinfo;
    }
	 
     public void saveSched() { UPDATE scheduleinfo; }     
     public void delSched() { DELETE scheduleinfo; }

}

 

 

VF Board,

 

I currently have a VF page that is displayed on a layout for my Opportunity object, leaving the Opportunity layout intact to keep the inline edibility.

 

I was wondering if there is a way to dynamically control the height of the VF page on the layout?

 

The VF page displays a set of milestones for an Opp, some will range from 5 to 15 depending on the project type. Is this doable concept or is it restricted?

Hi VF board,

 

I am currently working with a VF page that is placed on the Opp page:

 

public class PullMilestones{ public Milestone__c[] milestones = new Milestone__c[0]; public PullMilestones(ApexPages.StandardController controller) { } public PageReference save() { UPDATE milestones; return null; } public Milestone__c[] getMilestones() { //Milestone__c[] milestones; milestones = [SELECT ID, Name, Duration__c, Status__c, Due_Date__c, Start_Date__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate]; return milestones; } public Schedule__c[] getSchedule() { Schedule__c[] schedules; schedules = [SELECT ID, Name, Start_Date__c, End_Date__c FROM Schedule__c WHERE Project_Link__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate]; return schedules; } }

 

 On my VF page I have the lines:

 

<apex:page standardController="Opportunity" extensions="PullMilestones" showHeader="false" > <apex:form> <apex:pageBlock title="Schedule"> <apex:pageBlockTable value="{!schedules}" var="sched"> <apex:column headerValue="Name"> <apex:outputField value="{!sched.Name}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> <apex:form > <apex:pageBlock title="Milestones" mode="edit"> <apex:pageMessages /> ... <apex:pageBlockTable value="{!milestones}" var="m"> <apex:column headerValue="Name"> <apex:outputField value="{!m.Name}"/> </apex:column>

 

The table with value {!milestones} works fine but the {!schedules} does not.

I keep getting an error: 

Error: Unknown property 'OpportunityStandardController.schedules'

 

I was wondering, how does the milestones value work and not the schedules (both being on the extension)? Is there a way to make it look at the extension rather than the StandardController?

 

 

 

Hi,

 

I currently have a VF page that pulls from a custom object called Milestone__c, I would like to use this page on my Opportunity layout.

 

I currently have the standardController set to Opportunity so it can be displayed on the Opp layout.

 

The object heirarchy is as follows:

 

Opportunity

Schedule

Milestones

 

The current VFpage is as follows:

 

<apex:page standardController="Opportunity" extensions="PullMilestones" showHeader="false" >
<apex:form >

<apex:pageBlock title="Milestones" mode="edit">
<apex:pageMessages />

<apex:pageblockButtons location="top">
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!milestones}" var="m">

<apex:column headerValue="Name">
<apex:inputField value="{!m.Name}"/>
</apex:column>

<apex:column headerValue="Duration">
<apex:inputField value="{!m.Duration__c}"/>
</apex:column>

<apex:column headerValue="Status">
<apex:inputField value="{!m.Status__c}"/>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

</apex:page>

 

The extension controller is:

 

public Class PullMilestones{

public PullMilestones(ApexPages.StandardController controller) {
}

public Milestone__c[] getMilestones() {
Milestone__c[] milestones;

milestones = [SELECT ID, Name, Duration__c, Status__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id')
ORDER BY CreatedDate];

return milestones;
}

}

 I would like to use the Save button, being that page loads in edit mode. With the standardController set to Opportunity I get this: You cannot call save() on a null object

 

If I set the standardController to Milestone__c I get an error saying "Content cannot be displayed: Id value 006Q0000003hx4D is not valid for the Milestone__c standard controller" (the ID being the test Opp ID I am testing on)

 

Anyone have any input? I've been flipping through the book trying to figure out the best way to handle this.

 

Still learning, anything will help. Thanks in advance.

 

Hi,

 

I am pretty new to Visualforce... I have the developer guide printed out in front of me trying to get my head wrapped around everything.

 

I currently have a custom controller that pulls a bunch of records from a custom object called Milestone__c based on the Opp ID of the current page.That works fine, I am just trying to get a save button to work so I/whoever can update the milestones quickly. I used the "An Approach to Inline Editting" tutorial and that works fine but now am thinking that a save button on the list would be better. Can anyone help me with this?

 

I really want to make the Status field a drop down where you can edit multiple then save. Right now it is a drop down but I can't figure out the Save function, I've tried a bunch of different approaches based on posts but have been unsuccessful.

 

VF:

 

<apex:page Controller="TestMilestones" showHeader="false" > <apex:form > <apex:pageBlock title="Milestones" > <apex:pageBlockButtons location="top"> <apex:commandButton action="{!save}" value="save" id="saveButton"/> </apex:pageBlockButtons> <apex:outputPanel id="projectList"> <table> <tr> <th style="width:25px; "> </th> <th style="width:25px; "> </th> <th style="width:150px; ">Name</th> <th style="width:68px; ">Status</th> <th style="width:30px; ">Duration</th> </tr> <apex:repeat value="{!projects}" var="p"> <tr style="height:22px"> <apex:outputPanel id="editRow" layout="none" rendered="{!p.Id == editProject.Id}"> <td><apex:commandLink action="{!cancelEdit}" rerender="projectList">Cancel</apex:commandLink></td> <td><apex:commandLink action="{!saveEdit}" rerender="projectList">Save</apex:commandLink></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Name}"/></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Status__c}"/></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Duration__c}"/></td> </apex:outputPanel> <apex:outputPanel id="viewRow" layout="none" rendered="{!p.Id != editProject.Id}"> <td style="font-style:italic; font-size:10px"> <apex:commandLink action="{!del}" onclick="return confirm('Are you sure you want to delete this project?')">Del <apex:param name="delid" value="{!p.Id}"/> </apex:commandLink> </td> <td style="font-style:italic"> <apex:commandLink action="{!edit}" rerender="projectList">Edit <apex:param name="editid" value="{!p.Id}"/> </apex:commandLink> </td> <td>{!p.Name}</td> <td style="background-color:yellow"><apex:inputField id="stat" value="{!p.Status__c}" /></td> <td><CENTER>{!p.Duration__c}</CENTER></td> </apex:outputPanel> </tr> </apex:repeat> </table> <CENTER><STRONG>**Click on status to update it</STRONG></CENTER> </apex:outputPanel> </apex:pageBlock> </apex:page>

 

 Controller:

 

public class TestMilestones { public TestMilestones(ApexPages.StandardController controller) { } public Milestone__c newProject { get; set; } public Milestone__c editProject { get; set; } public TestMilestones() { newProject = new Milestone__c(); } public Milestone__c[] getProjects() { return [SELECT Name, Duration__c, Status__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate DESC]; } public String getParam(String name) { return ApexPages.currentPage().getParameters().get(name); } public PageReference add() { try { INSERT newProject; // if successful, reset the new project for the next entry newProject = new Milestone__c(); } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference del() { try { String delid = getParam('delid'); Milestone__c project = [SELECT Id FROM Milestone__c WHERE ID=:delid]; DELETE project; } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference edit() { String editid = getParam('editid'); editProject = [SELECT Name, Duration__c, Status__c FROM Milestone__c WHERE Id=:editid]; return null; } public PageReference cancelEdit() { editProject = null; return null; } public PageReference saveEdit() { try { UPDATE editProject; editProject = null; } catch (Exception e) { ApexPages.addMessages(e); } return null; } }

 

 Any help would be greatly appreciated

 

 

Hi DF,

 

I have completed a class to use as an extension of a VF page. I use it on a "Worldcolor_Project" page layout to show the Schedule associated with the project and the underlying Milestones attached to that Schedule.

 

The save and delete methods are used for VF buttons.

 

I am currently confused on how to begin my Testmethod. I started with Creating a new Worldcolor_Project and schedule related but am unsure how to test the inidividual methods. Any help would be greatly appreciated.

 

 

public with sharing class PullMilestones_Worldcolor {

    public Milestone__c[] milestones = new Milestone__c[0];
    public Schedule__c[] scheduleinfo;
   
    public PullMilestones_Worldcolor(ApexPages.StandardController controller) {
    }
    

    public Milestone__c[] getMilestones() {
        
         milestones = [SELECT ID, Name, Duration__c, Status__c, Due_Date__c,Start_Date__c,  Milestone_Status__c, Index__c, Predecessor_Index__c, Responsible__c
                        FROM Milestone__c
      WHERE Worldcolor_ProjectID__c = :ApexPages.currentPage().getParameters().get('id')
                            ORDER BY Index__c];
                            
        return milestones;
    }
    
    public void saveMile(){ UPDATE milestones; } 
       


    public Schedule__c[] getSchedule() {

        scheduleinfo = [SELECT ID, Name, Details__c, Start_Date__c, End_Date__c, Method__c, Duration__c, Overdue_Milestones__c, Risk_Status__c, Schedule_Template__c  
                            FROM Schedule__c 
                             WHERE WorldColor_Project__c = :ApexPages.currentPage().getParameters().get('id')];
        
        return scheduleinfo;
    }
	 
     public void saveSched() { UPDATE scheduleinfo; }     
     public void delSched() { DELETE scheduleinfo; }

}

 

 

VF Board,

 

I currently have a VF page that is displayed on a layout for my Opportunity object, leaving the Opportunity layout intact to keep the inline edibility.

 

I was wondering if there is a way to dynamically control the height of the VF page on the layout?

 

The VF page displays a set of milestones for an Opp, some will range from 5 to 15 depending on the project type. Is this doable concept or is it restricted?

Hi VF board,

 

I am currently working with a VF page that is placed on the Opp page:

 

public class PullMilestones{ public Milestone__c[] milestones = new Milestone__c[0]; public PullMilestones(ApexPages.StandardController controller) { } public PageReference save() { UPDATE milestones; return null; } public Milestone__c[] getMilestones() { //Milestone__c[] milestones; milestones = [SELECT ID, Name, Duration__c, Status__c, Due_Date__c, Start_Date__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate]; return milestones; } public Schedule__c[] getSchedule() { Schedule__c[] schedules; schedules = [SELECT ID, Name, Start_Date__c, End_Date__c FROM Schedule__c WHERE Project_Link__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate]; return schedules; } }

 

 On my VF page I have the lines:

 

<apex:page standardController="Opportunity" extensions="PullMilestones" showHeader="false" > <apex:form> <apex:pageBlock title="Schedule"> <apex:pageBlockTable value="{!schedules}" var="sched"> <apex:column headerValue="Name"> <apex:outputField value="{!sched.Name}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> <apex:form > <apex:pageBlock title="Milestones" mode="edit"> <apex:pageMessages /> ... <apex:pageBlockTable value="{!milestones}" var="m"> <apex:column headerValue="Name"> <apex:outputField value="{!m.Name}"/> </apex:column>

 

The table with value {!milestones} works fine but the {!schedules} does not.

I keep getting an error: 

Error: Unknown property 'OpportunityStandardController.schedules'

 

I was wondering, how does the milestones value work and not the schedules (both being on the extension)? Is there a way to make it look at the extension rather than the StandardController?

 

 

 

Hi,

 

I currently have a VF page that pulls from a custom object called Milestone__c, I would like to use this page on my Opportunity layout.

 

I currently have the standardController set to Opportunity so it can be displayed on the Opp layout.

 

The object heirarchy is as follows:

 

Opportunity

Schedule

Milestones

 

The current VFpage is as follows:

 

<apex:page standardController="Opportunity" extensions="PullMilestones" showHeader="false" >
<apex:form >

<apex:pageBlock title="Milestones" mode="edit">
<apex:pageMessages />

<apex:pageblockButtons location="top">
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!milestones}" var="m">

<apex:column headerValue="Name">
<apex:inputField value="{!m.Name}"/>
</apex:column>

<apex:column headerValue="Duration">
<apex:inputField value="{!m.Duration__c}"/>
</apex:column>

<apex:column headerValue="Status">
<apex:inputField value="{!m.Status__c}"/>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

</apex:page>

 

The extension controller is:

 

public Class PullMilestones{

public PullMilestones(ApexPages.StandardController controller) {
}

public Milestone__c[] getMilestones() {
Milestone__c[] milestones;

milestones = [SELECT ID, Name, Duration__c, Status__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id')
ORDER BY CreatedDate];

return milestones;
}

}

 I would like to use the Save button, being that page loads in edit mode. With the standardController set to Opportunity I get this: You cannot call save() on a null object

 

If I set the standardController to Milestone__c I get an error saying "Content cannot be displayed: Id value 006Q0000003hx4D is not valid for the Milestone__c standard controller" (the ID being the test Opp ID I am testing on)

 

Anyone have any input? I've been flipping through the book trying to figure out the best way to handle this.

 

Still learning, anything will help. Thanks in advance.

 

Hi,

 

I am pretty new to Visualforce... I have the developer guide printed out in front of me trying to get my head wrapped around everything.

 

I currently have a custom controller that pulls a bunch of records from a custom object called Milestone__c based on the Opp ID of the current page.That works fine, I am just trying to get a save button to work so I/whoever can update the milestones quickly. I used the "An Approach to Inline Editting" tutorial and that works fine but now am thinking that a save button on the list would be better. Can anyone help me with this?

 

I really want to make the Status field a drop down where you can edit multiple then save. Right now it is a drop down but I can't figure out the Save function, I've tried a bunch of different approaches based on posts but have been unsuccessful.

 

VF:

 

<apex:page Controller="TestMilestones" showHeader="false" > <apex:form > <apex:pageBlock title="Milestones" > <apex:pageBlockButtons location="top"> <apex:commandButton action="{!save}" value="save" id="saveButton"/> </apex:pageBlockButtons> <apex:outputPanel id="projectList"> <table> <tr> <th style="width:25px; "> </th> <th style="width:25px; "> </th> <th style="width:150px; ">Name</th> <th style="width:68px; ">Status</th> <th style="width:30px; ">Duration</th> </tr> <apex:repeat value="{!projects}" var="p"> <tr style="height:22px"> <apex:outputPanel id="editRow" layout="none" rendered="{!p.Id == editProject.Id}"> <td><apex:commandLink action="{!cancelEdit}" rerender="projectList">Cancel</apex:commandLink></td> <td><apex:commandLink action="{!saveEdit}" rerender="projectList">Save</apex:commandLink></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Name}"/></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Status__c}"/></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Duration__c}"/></td> </apex:outputPanel> <apex:outputPanel id="viewRow" layout="none" rendered="{!p.Id != editProject.Id}"> <td style="font-style:italic; font-size:10px"> <apex:commandLink action="{!del}" onclick="return confirm('Are you sure you want to delete this project?')">Del <apex:param name="delid" value="{!p.Id}"/> </apex:commandLink> </td> <td style="font-style:italic"> <apex:commandLink action="{!edit}" rerender="projectList">Edit <apex:param name="editid" value="{!p.Id}"/> </apex:commandLink> </td> <td>{!p.Name}</td> <td style="background-color:yellow"><apex:inputField id="stat" value="{!p.Status__c}" /></td> <td><CENTER>{!p.Duration__c}</CENTER></td> </apex:outputPanel> </tr> </apex:repeat> </table> <CENTER><STRONG>**Click on status to update it</STRONG></CENTER> </apex:outputPanel> </apex:pageBlock> </apex:page>

 

 Controller:

 

public class TestMilestones { public TestMilestones(ApexPages.StandardController controller) { } public Milestone__c newProject { get; set; } public Milestone__c editProject { get; set; } public TestMilestones() { newProject = new Milestone__c(); } public Milestone__c[] getProjects() { return [SELECT Name, Duration__c, Status__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate DESC]; } public String getParam(String name) { return ApexPages.currentPage().getParameters().get(name); } public PageReference add() { try { INSERT newProject; // if successful, reset the new project for the next entry newProject = new Milestone__c(); } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference del() { try { String delid = getParam('delid'); Milestone__c project = [SELECT Id FROM Milestone__c WHERE ID=:delid]; DELETE project; } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference edit() { String editid = getParam('editid'); editProject = [SELECT Name, Duration__c, Status__c FROM Milestone__c WHERE Id=:editid]; return null; } public PageReference cancelEdit() { editProject = null; return null; } public PageReference saveEdit() { try { UPDATE editProject; editProject = null; } catch (Exception e) { ApexPages.addMessages(e); } return null; } }

 

 Any help would be greatly appreciated