+ Start a Discussion
JNicJNic 

Extension controller not recognized fully

Hey all... I'm running into some strange phenomena...

 

 

I have a VF page like so:

 

<apex:page standardController="workOrder__c"   extensions="workOrderController" action="{!init}">
<apex:variable value="{!workOrder__c}" var="wrk"/>

<apex:sectionHeader title="Work Order" subtitle="{!wrk.name}"/>

{!hasShp}

</apex:page>

 

 

And the extension as such:

 

public with sharing class workOrderController {

public woJct__c [] jcts = new woJct__c[0];

private workOrder__c workOrder;

//If the jcts list contains any relatedToObject__c = "Shipment__c", then set this as true
//so I can render that component
public boolean hasShp = true;

//If the jcts list contains any relatedToObject__c = "Terminal_prep_order__c"
//then set this as true so I can render the component
public boolean hasTrmPrp = true;

//Make sure we can use this page as an extension on and above the standard controller
public ApexPages.StandardController controller;
public workOrderController(ApexPages.StandardController controller)
{
this.controller = controller;

workOrder = (workOrder__c)controller.getRecord();
}

public void init()
{
if (workOrder.Status__c == 'New')
{
if (workOrder.OwnerId == UserInfo.getUserId()) {
workOrder.Status__c = 'Open';
update workOrder;
}
}
UpdateBooleans();
}

private void UpdateBooleans()
{
woJct__c[] jctsShipment = [
SELECT Id
FROM woJct__c
WHERE workOrder__c = :workOrder.Id AND relatedToObject__c = :'Shipment__c'];
hasShp = jctsShipment.size() > 0;

woJct__c[] jctsTerminal = [
SELECT Id
FROM woJct__c
WHERE workOrder__c = :workOrder.Id AND relatedToObject__c = :'Terminal_prep_order__c'];
hasTrmPrp = jctsTerminal.size() > 0;
}

//This gets all the woJcts - If there is a better way, please do it.
public woJct__c[] getJcts(){
jcts = [
select id, name, relatedToId__c, relatedToName__c, relatedToObject__c, complete__c
from woJct__c where workOrder__c = :ApexPages.currentPage().getParameters().get('id')
];
return jcts;
}

}

 

 

When I add {!hasShp} to the VF page, I get the following error:

 

Error: Unknown property 'workOrder__cStandardController.hasShp'

 

It makes no sense to me! Please help!

 

thanks!

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

Either add a getter method or set the element as a property.

 

 

 public boolean hasShp {get; set;}

 

you can then initialize it to true in your constructor.

 

All Answers

ahab1372ahab1372

you need to add a getter method

see VF docu here: controller methods

 

or use the Apex properties: Apex docu properties

JimRaeJimRae

Either add a getter method or set the element as a property.

 

 

 public boolean hasShp {get; set;}

 

you can then initialize it to true in your constructor.

 

This was selected as the best answer