You need to sign in to do that
Don't have an account?
benwrigley
Assigning dynamic IDs to elements
Hi There,
Very new to visualforce here, so sorry if this is a dumb question.
I'm using the pageBlockTable tag to render a list of objects to the page. I want to make one of the columns hold an empty string that will be updated by some AJAX later on. In order to do that I want to add a unique ID to each one of these fields to reference it later. What I was hoping would work was:
<apex:pageBlockTable value="{!RateCardPriceBreaks}" var="pb">
<apex:column headerValue="Select" >
<apex:commandButton action="{!getQuantity('test')}" value="Select"/>
</apex:column>
<apex:column headerValue="Product" value="{!pb.product__r.Name}" />
<apex:column headerValue="Quantity" id="quantity" value="{!pb.ID}"/>
</apex:pageBlockTable>
<apex:pageBlockTable value="{!RateCardPriceBreaks}" var="pb"> <apex:column headerValue="Product" value="{!pb.product__r.Name}" /> <apex:column headerValue="Quantity" id="quantity{!pb.ID}" value=""/> </apex:pageBlockTable>
Error: Literal value is required for attribute id in <apex:column> at line 8 column 45 |
So that's obviously *not* the way to do it. Any tips?
TIA
In my opinion we can not assign dynamic id's to VF components but can assign dynamic id's to html elements.
In salesforce <apex:repeat> component shows dynamic id's automatically but if you try to assign by yourself then it will show an error.
Hope this helps.
I have very similar situation.
I am trying to add input element: Qty dynamically for selected Products. And I want to retrive the Qty values for each of the selected products in my controller. Dynamic Id is one work around, if someone can think of other work around please post it here. Thanks.
Inside <apex:repeat> I have :
<td>
<apex:inputtext value="{!fObj.val}" id="bVAL" />
</td>
In this case the id is being generated dynamically by VF and we can retrieve the dynamic id by '{!$Component.bVAL}'.
hope this helps!
thanks.
When user selects a record, there are 4 fields that needs to be udpate based on the logic in controller. Do you think there is anything else I can do to speed up the things? In long run, I may use jQuery.
I am doing simple alert and the id in the alert does not match with actual id of "prodSalePrice" input field. I have highlighted the difference ( 7 vs 9) above.
Any clue?
Mitesh
Even im also face issue. do you have any clue.
thank you