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
Naresh Krishna.ax1176Naresh Krishna.ax1176 

Issue with visualforce component ID

Hi All,

 

Below is my sample code:

 

Page:-

<apex:page sidebar="false" controller="sampleCtrl">
  <apex:dataTable id="example" value="{!numbers}" var="number">
  <apex:column >  
      <apex:facet name="header">Numbers</apex:facet>
      {!number}
  </apex:column>
  </apex:dataTable>
</apex:page>

 

Controller:-

public with sharing class sampleCtrl {

    public List<String> numbers { get; set; }
    
    public sampleCtrl()
    {
        numbers = new List<String>();
        numbers.add('One');
        numbers.add('Two');
        numbers.add('Three');
    }
    
}

 

Issue here is:

I have declared the id of the dataTable as 'example' but it becomes 'j_id0:example'.


Is there any way to eliminate this prior string of example in the id?

 

Thanks.

kiranmutturukiranmutturu

it will append all the previous tags ids  .. if you specified id you will get that other wise like j_id0 , j_id1 so on.....

Naresh Krishna.ax1176Naresh Krishna.ax1176

Thanks for you reply.

 

can you please suggest any way to eliminate the appended string in the id?

 

 

kiranmutturukiranmutturu

where exactly u are using that id and y u need to eliminate ?

Naresh Krishna.ax1176Naresh Krishna.ax1176

This id 'example' is used in jQuery. We dont have permissions to change the js files.

We should use only id as 'example'.

kiranmutturukiranmutturu

the id u r getting is not from  <apex:dataTable id="example" value="{!numbers}" var="number"> this?.. i dont think so... you are getting that formatted id for the above component only

Naresh Krishna.ax1176Naresh Krishna.ax1176

I tried as below, getting the id of dataTable only:

 

<apex:dataTable id="example" value="{!numbers}" var="number"

onclick="alert('pageId:'+{!$Component.pageId}.id+' Id: '+this.id);">

 

Can you please check it.