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
chris_centrachris_centra 

custom component - accepting form input...

hello.  i have to ceate a bunch of survey pages in vf - each survey has a handful of questions - some of the questions are repeated between surveys.

what i would love to do is have a vf page with the form tag for the whole survey, create the frequently-repeated questions as vf components, and then drop them into the vf form as necessary.  so this is where i have a disconnect with custom components.  i've played with this, and when i submit (the form and submit button are in the "outer" vf page), the values from the component don't make it to my instance of the controller.  (i found that if i put the button inside a component and click that button, then the input values are in the controller.)

so my question is: is there a way to do what i want to do (create a snippet that will accept input - that i can drop into a page)?  seems that components are great for displaying frequently-used bits, but it's a little more complicated when input is involved...

thanks for your time.
chris
Best Answer chosen by chris_centra
bob_buzzardbob_buzzard
Yes you can do this.  It sounds like the component controllers are managing the questions themselves, in which case the values won't make it back to the parent controller as they are in a different class instance.  You can pass values as attributes and have the component controller update them.

I wrote a blog post on this at : http://bobbuzzard.blogspot.co.uk/2011/05/updating-attributes-in-component.html

All Answers

bob_buzzardbob_buzzard
Yes you can do this.  It sounds like the component controllers are managing the questions themselves, in which case the values won't make it back to the parent controller as they are in a different class instance.  You can pass values as attributes and have the component controller update them.

I wrote a blog post on this at : http://bobbuzzard.blogspot.co.uk/2011/05/updating-attributes-in-component.html
This was selected as the best answer
chris_centrachris_centra
wow - that is very cool.  awesome - thanks so much for the response - and great blog post!
chris