You need to sign in to do that
Don't have an account?
sunilkbansal
Simple Custom component developement: javascript function not found
Hello,
I created a simple VF custom component from the cookbook example (increment-decrement custom component).
There is also some javascript in the custom component.
I have used this custom component in other VF page.When this custom component get rendered in the VF page, all this custom component gets rendered in a <span> tag, so also the javascript is also in this span tag. When any function from this javascript is called, Error comes and says that function is not defined.
Has any one of you created a custom component with javascript, and used that javascript function in your component. Looks like a bug in rendering of the custom component or there should be some other way to use the custom component or to use the javascript in custom component.
Any thoughts/ suggests are welcome.
Thanks,
Sunil
I created a simple VF custom component from the cookbook example (increment-decrement custom component).
There is also some javascript in the custom component.
I have used this custom component in other VF page.When this custom component get rendered in the VF page, all this custom component gets rendered in a <span> tag, so also the javascript is also in this span tag. When any function from this javascript is called, Error comes and says that function is not defined.
Has any one of you created a custom component with javascript, and used that javascript function in your component. Looks like a bug in rendering of the custom component or there should be some other way to use the custom component or to use the javascript in custom component.
Any thoughts/ suggests are welcome.
Thanks,
Sunil
It would be nice if VF had a way for pages/components to dynamically contribute anything to the <head> element of the page, like some of the Java web frameworks allow, but it doesn't.
Thanks for your response.
But it has not worked for me. I created a Javascript file on my desktop and uploaded that to the Static Resources in my Dev Org with the name "dummy_script".
And then included that one in my VF custom component as: <script type="text/javascript" src="{!$Resource.dummy_script}"/>
It still says that function is not defined.
In the actual VF page (in the frame) custom component when rendered with the script tag as :
Jeremy - have you created an Idea for this to get some community support behind this excellent enhancement? BTW I opened a feature request on this for my team over a year ago but we have held off working on it primarily because there has been 0 interest expressed either directly or indirectly from the community...
I'll submit it as an idea but suspect that if SFDC only uses ideas feedback as the gauge of a feature's usefulness, this one will never make it. It solves TONS of little problems for users, makes coding components much more granular, but also has a pre-existing workaround for many of the use cases, such as the one here, and frankly most people who have run into issues this would solve probably won't immediately realize this would have solved it.
I'll buy you a drink if you code this over a weekend and then present it to your team as a fait accompli, which is probably what I would do :)
BTW apex:includeScript and apex:stylesheet are both implemented as non-positional <head> contributors (we'll even inject the <head></head> block if needed) and also implement include once and only once semantics.
We have just not exposed a general "inject this subtree's contents into the head" as of yet.
http://www.salesforce.com/us/developer/docs/pages/index.htm
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
But if I'm understanding what you are describing, and you wish to have the ability to assign a "directory number" to a custom object that is "random" - and I'm assuming by "random" you mean "unique, but number doesn't matter" - I would just use an auto-number field in Salesforce with a format of something like {000000} and a starting value of 100000. Obviously if you use a truly random number, and you're using it for some sort of directory ID, you will get duplicates over time.
Jeremy,
Thanks for your quick reply. I have going through the documentation you mentioned. Meanwhile I have following:
1. Object named "Service" already created
2. It has one text field called "AAA test Auto Directory number" (field name: AAA_test_Auto_Directory_number, API Name: AAA_test_Auto_Directory_number__c)
3. I have button called "Auto DN" (field name: Auto_DN, Display Type: Detail Page Button, Behaviour: Execure Java Script)
4. For this button I have defined following: