You need to sign in to do that
Don't have an account?
narsavagep
Javascript Referencing Input Cell In Iterative Component
I have a VF page which lists several objects at once and allows the user to update them and hit a "save" button. When the user edits one of the fields, I want a javascript call to populate something in another field. How do I reference the appropriate field in the action command?
Below is the example of what I'm looking to do.
<apex:pageBlockSection title="New Case Dates" columns="1" collapsible="false" showHeader="true"> <apex:pageBlockTable value="{!CasesToCreate}" var="case"> <apex:column headerValue="Commit"> <apex:inputField value="{!case.Commit_Date__c}" onchange="UpdateReleaseText(this.value, ReleaseTextId?);"/> </apex:column> <apex:column headerValue="Release"> <apex:inputField value="{!case.Release__c}" id="ReleaseText"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection>
Thanks!
Paul
Hmmm. That is quite tricky.
It looks like getUniqNum may get rationalised to a single replacement when the page is rendered.
Presumably you are creating a list of cases? That being the case(!) you could bring a wrapper class into the equation and combine the unique id with the case and return a list of those.
Something like:
Then in your page you'd iterate the wrapper list:
All Answers
You'll need to generate an id that is unique to the particular instance that your pageblocktable is processing.
As you are using case sobjects, can you use the sobject id? Something like:
Thanks Bob...
Good idea... however, I get the following error if I try to do that:
Bummer.
I've just checked back how I did something similar.
I wrapped my components in a vanilla HTML span tag, which can take a dynamically generated id. My javascript then located the span, found the input element inside that and populated its value. There's obviously some compromise there, in that you are assuming the particular type of input element (e.g. select, textarea etc), but that wasn't an issue for me.
OK, that makes sense.
Do you happen to have the javascript code that you could post a snippet of if? Just to make development time for me quicker/easier. If not, I understand.
Thanks so much for your input.
Paul
It wouldn't be much use I'm afraid, as it was part of a Dojo drag and drop event handler and the logic was split over about four methods.
OK, I'm getting there... my current issue is trying to get a unique number/identifier for each row.
I'm creating six new cases for these six rows that I'm working with, but they are not actually "inserted" into the database at the time the VF page is created -- as the user needs to populate the dates, hit submit, and then the cases are created. So there is no "Case.Id" for the rows. *sigh*
I tried creating a unique number, but these functions in the controller are always returning "1" -- never incrementing.
When I call {!NewUniqNum} on the VF page, I get "1" for every row... it's not incrementing??
What am I missing here?
Thanks!
Hmmm. That is quite tricky.
It looks like getUniqNum may get rationalised to a single replacement when the page is rendered.
Presumably you are creating a list of cases? That being the case(!) you could bring a wrapper class into the equation and combine the unique id with the case and return a list of those.
Something like:
Then in your page you'd iterate the wrapper list:
Brilliant!!
Thanks so much!
For future reference, and if anyone else is looking for same/similar solution... here's snippets of the code I ended-up with that works great.
Page:
Page Javascript:
Controller:
Thanks again so much!
Paul
PS: The code above shows a date field (we call "commit") and a text field (we call "release").
The javascript populates the release field with the month and year of the selected commit date. (ie "February 2011")
(The release text can then be modified by the user if they wish.)