[SalesForce] Visualforce dynamic Ids assignment

I am trying to work on component. Currently, I have this as the structure:

<apex:pageBlock title="Document">
                <apex:pageBlockTable value="{!documents}" var="doc">
                    <apex:column headervalue="Name">
                        <apex:outputLink value="/servlet/servlet.FileDownload?file={!doc.id}">{!doc.name}.{!doc.Type}</apex:outputLink>
                    </apex:column>
                    <apex:column value="{!doc.Description}"/>                  
                </apex:pageBlockTable> 
            </apex:pageBlock>

I would like to add a new column to this table, "Job Status".

<apex:column headervalue="Job status"> 
                            <apex:outputText id="{!doc.id}"></apex:outputtext>
                        </apex:column>

This throws an error stating that id requires a literal value. I intend to use this id to peg the job status with the current document. However, I have run into this issue and seems I will not be able to track this info from the apex class. What other ways that I can add an additional column that has no information to deal with the page table variable?

Best Answer

The "id" attribute for any element with a "managed" XML namespace (e.g. apex:outputText, c:myComponent, etc), can never use non-literal values. This is because these id values must be unique and may be referenced from other locations, such as reRender targets or the $Component global variable. Instead, simply use a normal span tag, such as: <span id="{!doc.id}"></span>.

Related Topic