I'm trying to build a test class for a controller extension on a Visualforce page and I need a more in depth description of what certain lines mean. Help on this would be appreciated.
1)
String msg=e.getMessage();
integer pos;
// if its field validation, this will be added to the messages by default
if (-1==(pos=msg.indexOf('FIELD_CUSTOM_VALIDATION_EXCEPTION, ')))
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, msg));
}
result=false;
2)
pr.setRedirect(true);
3) The null
here
public void newSkid()
{
if (updateSkids())
{
Skid__c skid=new Skid__c(Name=newSkidName, Dimension__c=newSkidDimension, Number_of_Pieces__c=newSkidNumberofPieces, UOM__c=newskiduom, Weight__c=newskidweight, Bill_of_Lading__c=getBillofLading().id);
insert skid;
newSkidName=null;
newSkidDimension=null;
newSkidNumberofPieces=null;
newskidbilloflading=null;
newskiduom=null;
newskidweight=null;
skids=null;
4) The null!=
here
public void deleteSkid()
{
if (updateSkids())
{
if (null!=chosenskidId)
{
Skid__c skid=new Skid__c(Id=chosenskidId);
delete skid;
skids=null;
chosenskidId=null;
}
}
}
5) The null
statement again here
public List<Skid__c> getSkids()
{
if ( (null!=getBillofLading().id) && (skids == null) )
{
skids=[SELECT Id, Name, Bill_of_Lading__c,
Dimension__c, Number_of_Pieces__c, UOM__c, Weight__c
FROM Skid__c
WHERE Id =: getBillofLading().id
ORDER BY CreatedDate];
6) These functions
public String getChooserender() {
if (ApexPages.currentPage().getParameters().get('p') != null)
return 'pdf';
else
return null;
}
public PageReference deliverAsPDF() {
PageReference pdf = Page.Billofladingtest05222013;
pdf.getParameters().put('p','p');
return pdf;
}