• Pzyren
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies

I am attempting to test this code. I need to set up the controller and set the parameters.
CONTROLLER.

The visualForce page has a standard controller of contact

Public Class myClass{
 public ApexPages.standardController controller {get; set;}
 public string pid {get; set;}

//CONSTRUCTOR
public myClass(ApexPages.StandardController controller){
 this.controller = controller;
 pId = ApexPages.CurrentPage().getparameters().get('id');
}

 

TEST CLASS

@isTest
public class testMyClass{

static testMethod void myTest(){
 PageReference pageRef = Page.myPage;
 Test.setCurrentPageReference(pageRef);

//create contact
 Contact cont = new Contact(name ='bob');
 insert cont;

 ApexPages.CurrentPage().getparameters().put('pid', cont[0].id);
 ApexPages.StandardController sc = new     ApexPages.standardController(cont[0]);
ApexPages.currentPage().getParameters().put(?); myClass sic = new myClass(sc);
system.assertQuals('something', here); } }

 

  • October 04, 2013
  • Like
  • 0
<apex:page controller="controller">
<apex:form >
 <apex:pageBlock title="foo"> 
<apex:pageBlockButtons location="top">       
         <apex:commandButton id="DeleteBtn" value="{!$Label.Delete}" />
   </apex:pageBlockButtons> 
  <apex:pageBlockTable value="{!list}" var="list" title="foo">
      <apex:column >
        <input type="checkbox" value="{!list.id}" id = "checkbox"/> 
   </apex:column>
   <apex:column>
      <apex:facet name="header"> <apex:outputText value="Name" /> </apex:facet>
        <apex:outputField value="{!foo.Name__c}" />
    </apex:column>
  
    <apex:column > 
      <apex:facet name="header"> <apex:outputText value="Type" /> </apex:facet>
        <apex:outputField value="{!foo.Type__c}" />
    </apex:column>
    <apex:column > 
      <apex:facet name="header"> <apex:outputText value="Comments" /> </apex:facet>
      <apex:outputField value="{!foo.Comment__c}" />
    </apex:column>
    
  </apex:pageBlockTable> 
 </apex:pageBlock>
</apex:form>
</apex:page>

 CONTROLLER. 

 

I want to be able to delete multiple rows out of the table. So delete all checked rows with he delete button. How do I do this? 

public with sharing class controller {

public List<sObjects> myList 	{get; set;}
public String pId		{get; set;}							
	
    //CONSTRUCTOR
    public controller(){
    	 pId = ApexPages.CurrentPage().getparameters().get('id');
    	 myList = loadlist(); 
    }
    
    public list<People_Skill__c> loadList(){
    	List<sObjects> myList= [SELECT Id, name__c, type__c, comment__c,    FROM object__c WHERE id=:pId];
    	return mylist;
    }
}

 

  • September 25, 2013
  • Like
  • 0

I would like to know if it is possible to have different visualforce pages in different tabs. Is it possible to do what I am trying to do? I know it can be done with component by referencing the component like

 

<c:componentName />

 Can it be odne with VF pages?

 

<form>
<div>
<apex:pageBlock >
			<apex:pageBlockButtons >
				<apex:commandButton value="Save" id="save" />
				<apex:commandButton value="Cancel" id="Cancel" />
			</apex:pageBlockButtons>
			<apex:tabPanel selectedTab="t1" id="panel" switchType="client" 
				tabClass="activeTab" inactiveTabClass="inactiveTab">
				<apex:tab name="tab1" id="tab1" label="label">
					<div class="tab" > 
					  <!--  This is where call to page will go -->
					</div>
				</apex:tab>
				<apex:tab name="tab2" id="tab2" label="label">
						<div class="cTab" > 
				        	<!--  This is where call to page will go -->
						</div>
				</apex:tab>
				<apex:tab name="tab3" id="tab3" label="label">
					<div class="tab" > 
						<!--  This is where call to page will go -->
					</div>	
				</apex:tab>
			</apex:tabPanel>
		</apex:pageBlock>
 </div>
</apex:form>

 

  • September 23, 2013
  • Like
  • 0

I have a table and the columns have outputlinks. Right now, if the column is empty, it displays "None" which is a link to nowhere. I want to be able to remove the link if the column is empty.  Any help? Thanks

 

I tried 

 

<apex:outputLink value="/{!object.field__c}" )}" disabled = {!IF(!object.field__c == '')}    target="_top">  

 Obviously didn't work since disabled takes in boolean. 

 

<apex:column >
   <apex:facet name="header" ><apex:outputText value="{!$Label.Name}" /></apex:facet>
       <apex:outputLink value="/{!object.field__c}" )}" target="_top">  
       <apex:outputField value="{!object.field__c}" />
       </apex:outputLink>
 </apex:column>  

 

  • September 19, 2013
  • Like
  • 0

Hello all, I have a checkbox in my visualforce page just like this :

<apex:inputCheckbox />

 I want to be able in my controller, to see whether or not the checkbox is checked. I am making a query that is based on the checkbox's state. For example. This is the state if the checkbox is not selected.

 

select name from foo__c where id = contactid 

 if the checkbox is selected, I want my query to be something like this

 

select name from foo__c where id IN :allContactIds

I'm stuck on this. Any help?

  • August 29, 2013
  • Like
  • 0

I am attempting to create my own custom date fields to use with events and tasks. When my method is called, it should determine whether it is an event or task and use some logic to set the date. I will be using this method in a query to filter my table. for example

String qry = select [datefilter(event, allOpen), status from Task]; 

 I'm hoping this will return all open tasks/events. Pretty much same plan for all other picklist values

 

Here is the picklist which is inside a list called dateList

   All Open

   All Past 

   Next 7 days.

 

Anyone know how I can go about this? potentially using Date methods? Thanks for your time

 

public void datefilter(String taskOrEvent, string date){

 if (taskOrEvent =='task' && date = 'allOpen'){
   //do logic
   }

  if (taskOrEvent =='task' && date = 'all past'){
   //do logic
   }

if (taskOrEvent =='task' && date = 'Next 7 days'){
   //do logic
   }

 if (taskOrEvent =='event' && date = 'allOpen'){
   //do logic
   }

  if (taskOrEvent =='event' && date = 'all past'){
   //do logic
   }

if (taskOrEvent =='event' && date = 'Next 7 days'){
   //do logic
   }

}

 

  • August 27, 2013
  • Like
  • 0

I keep getting the above error when I try to compile. I'm not sure if my placement of return values are off or not. Anyone see what I should be doing differently?

 

 

public List<Task> filterRecords(){
  	actList = new List<Task>();
  	
  	try {
  	actList = [
  	          SELECT Subject, WhatId, activityDate, status, priority, category__c, type__c, whoId
  	          FROM Task 
  	          WHERE activityDate=:act.ActivityDate AND status=:act.Status AND category__c=:act.category__c 
  	               AND type__c=:act.type__c AND priority=:act.Priority
  	          LIMIT 200
  	          ];
  	          
  	 if(actList.isEmpty()){
  	 	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Could not find any records'));
  	 	return null;
  	 } 
  	 else if(!actList.isEmpty()){
  	 	return actList;
  	 } 
  	}
  	catch(Exception e){System.debug(e.getMessage());}
  }

 

  • August 25, 2013
  • Like
  • 0

I am attempting to test this code. I need to set up the controller and set the parameters.
CONTROLLER.

The visualForce page has a standard controller of contact

Public Class myClass{
 public ApexPages.standardController controller {get; set;}
 public string pid {get; set;}

//CONSTRUCTOR
public myClass(ApexPages.StandardController controller){
 this.controller = controller;
 pId = ApexPages.CurrentPage().getparameters().get('id');
}

 

TEST CLASS

@isTest
public class testMyClass{

static testMethod void myTest(){
 PageReference pageRef = Page.myPage;
 Test.setCurrentPageReference(pageRef);

//create contact
 Contact cont = new Contact(name ='bob');
 insert cont;

 ApexPages.CurrentPage().getparameters().put('pid', cont[0].id);
 ApexPages.StandardController sc = new     ApexPages.standardController(cont[0]);
ApexPages.currentPage().getParameters().put(?); myClass sic = new myClass(sc);
system.assertQuals('something', here); } }

 

  • October 04, 2013
  • Like
  • 0
<apex:page controller="controller">
<apex:form >
 <apex:pageBlock title="foo"> 
<apex:pageBlockButtons location="top">       
         <apex:commandButton id="DeleteBtn" value="{!$Label.Delete}" />
   </apex:pageBlockButtons> 
  <apex:pageBlockTable value="{!list}" var="list" title="foo">
      <apex:column >
        <input type="checkbox" value="{!list.id}" id = "checkbox"/> 
   </apex:column>
   <apex:column>
      <apex:facet name="header"> <apex:outputText value="Name" /> </apex:facet>
        <apex:outputField value="{!foo.Name__c}" />
    </apex:column>
  
    <apex:column > 
      <apex:facet name="header"> <apex:outputText value="Type" /> </apex:facet>
        <apex:outputField value="{!foo.Type__c}" />
    </apex:column>
    <apex:column > 
      <apex:facet name="header"> <apex:outputText value="Comments" /> </apex:facet>
      <apex:outputField value="{!foo.Comment__c}" />
    </apex:column>
    
  </apex:pageBlockTable> 
 </apex:pageBlock>
</apex:form>
</apex:page>

 CONTROLLER. 

 

I want to be able to delete multiple rows out of the table. So delete all checked rows with he delete button. How do I do this? 

public with sharing class controller {

public List<sObjects> myList 	{get; set;}
public String pId		{get; set;}							
	
    //CONSTRUCTOR
    public controller(){
    	 pId = ApexPages.CurrentPage().getparameters().get('id');
    	 myList = loadlist(); 
    }
    
    public list<People_Skill__c> loadList(){
    	List<sObjects> myList= [SELECT Id, name__c, type__c, comment__c,    FROM object__c WHERE id=:pId];
    	return mylist;
    }
}

 

  • September 25, 2013
  • Like
  • 0

I keep getting the above error when I try to compile. I'm not sure if my placement of return values are off or not. Anyone see what I should be doing differently?

 

 

public List<Task> filterRecords(){
  	actList = new List<Task>();
  	
  	try {
  	actList = [
  	          SELECT Subject, WhatId, activityDate, status, priority, category__c, type__c, whoId
  	          FROM Task 
  	          WHERE activityDate=:act.ActivityDate AND status=:act.Status AND category__c=:act.category__c 
  	               AND type__c=:act.type__c AND priority=:act.Priority
  	          LIMIT 200
  	          ];
  	          
  	 if(actList.isEmpty()){
  	 	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Could not find any records'));
  	 	return null;
  	 } 
  	 else if(!actList.isEmpty()){
  	 	return actList;
  	 } 
  	}
  	catch(Exception e){System.debug(e.getMessage());}
  }

 

  • August 25, 2013
  • Like
  • 0