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

How to get subject from a visualforce page for SControl which is embeded in the visualforce page


I've created an scontrol and want to embed it into a visualforce page. 
With the attribute subject we can give an object id to the scontroll:

<apex:page standardController="Account">
<apex:scontrol controlName="HelloWorld" height="60" subject="0017000000NHLs5"></apex:scontrol>

But how can I get this object id in the scontrol?

Thanks for your idea.



Why are you building new scontrols at all? Scontrols are on a deprecation path and there is nothing you can do in an scontrol that you cannot do in VF at least as well and almost always better, faster, cheaper etc.

Can you provide a bit more info on what you are trying to accomplish and we'll see if we can get you on the right path?
Hi Doug,

Thanks for your reply.

Want I want to do is  to list records of an SObject in a VF page. For this I tried to use the apex dataTable elemet. But I could not make the number of columns dynamic. For example, depending on some current field values I want the table to have different number of columns.


If columnNumber__c == 2, then the table schold have columns field1__c and field2__c and if columnNumber__c == 3, then the table should have columns field2__c, field4__c and field__5.

That is, in the first case the table has 2 columns while in the second case the table has 3 columns.

It seem that it's impossible to realize this with VF I wanted to try this with SControl, since with Scontrol we can print a table with both dynamic number of columns and rows. That's why I wanted to deliver the ID of the object which has the field columnNumber__c.

Thanks a lot for your answer,

In this situation the best approach is still to stay with VF and leverage the lower level components like apex:repeat to generate the dynamic table. This lets you still leverage apex code/server side API access. I suspect you will also want to learn about using dynamic SOQL in apex code.

At the end of the day you can get as close to the metal/browser as you want using VF.
Thanks a lot. With dynamic SOQL now I've solved the problems. :smileywink:

i'm also looking for the usage of subject attribute of scontrol tag, seems there is no documentation.
indeed trying to pass parameter to scontrol from vf page. any ideas?
What about hosting a Flex object on a Visual Force page?  Don't you need to use an S-Control for that?  How do you use the subject attribute of the apex:scontrol tag? I'm having a hard time get my object id's into Flex?

Suresh RaghuramSuresh Raghuram

hey i followed your post it is pretty intresting , but i want to see how you implemented the dynamic soql could you plz shed some ideas and the code snippets.


Thanks in advance.