function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nil_von_9wonil_von_9wo 

Problem with Force.com_Developer Tutorial: Chapter 12: Controller Extensions

I am *trying* to work through the tutorials in the Force.com_Developer guide.

 

I have created the VisualForceExtension page, as described starting on page 379.

 

However, I can not get the dependant selectList to work. I've checked the Errata and I couldn't find any information to fix this problem.

 

If I do not remove

 

where pt.Department__c = :position.Department__c

 

from positionExtension.cls, the resulting selectList is empty. 

 

And, of course, if I remove it, the resulting selectList contains an entry for each Position Type record. 

 

I am guessing this selectList is empty because the Department defaults to "None"; moreover, that the problem isn't actually with the where clause, but the AJAX mechanism. 

 

I don't believe the page is being dynamically modified when Department is changed despite the lines which read: 

 

<apex:actionSupport

     event="onchange"

     action="{!resetPositionType}"  

     rerender="dependentPositionType"

     status="departmentStatus" />

 

 

I tried setting a default for the Department picklist, however the choice presented still defaulted to "None", so this didn't help to test the above theory that I'm stuck on the initial values populating the list.

 

On the theory that the AJAX may be incompatible with Firefox 3.5, I've also tried to view the page in several other browsers (Flock 2.5, Chrome 3.0, Safari 4.5, Opera 10, and IE7), however either I received the same results or SalesForce wouldn't even let me log in using the browser.

 

 

If anyone knows how to get the code in the book to work with modern browsers, please let me know.

 

If I need to use an older browser, please let me know that to.

 

Thanks,

 

-Brian.

Best Answer chosen by Admin (Salesforce Developers) 
nil_von_9wonil_von_9wo
If anyone cares, I solved the problem.

It seems, unlike what is published in the Developer's Guide, the apex:actionSupport tag should be embedded within, not placed after, the apex:inputField tag.

All Answers

nil_von_9wonil_von_9wo

Pushing forward in the tutorial, despite this problem, I assigned the VisualForceExtension page as the "Edit" page for the Position object. Once I did this, I was able to confirm that:

 

1. The "where" clause is working correctly when an existing object is selected to edit.

 

2. The selectList is not being updated when the Department is changed.

 

 

.... I still haven't figured out how to fix this.

 

Will continue pushing forward, but ideas are welcome!

 

 

-Brian.

 

 

nil_von_9wonil_von_9wo

m For whatever its worth, it seems that not only is the apex:actionSupport not changing the dependent selectList, it also isn't resetting the list in spite of

 

action="{!resetPositionType}"

 

 I'm really tempted to say that this is a browser problem, except that this code can't be made to work right in any browser I have...

nil_von_9wonil_von_9wo
If anyone cares, I solved the problem.

It seems, unlike what is published in the Developer's Guide, the apex:actionSupport tag should be embedded within, not placed after, the apex:inputField tag.
This was selected as the best answer
SteveAnderson41SteveAnderson41
I'm glad you found the issue.  I am sorry you've had such issues with the examples.  We're working on updating that book as we speak and we'll include this fix in it.