You need to sign in to do that
Don't have an account?
B2000
How Do I Pass String[] Variable in a VF Page Component
How do I pass a list of strings values (not a controller variable) in the VF Page component tag to the controller?
VF Page: <c:testComponent strList="1,2,3" />
Component: <apex:component controller="testCont"> <apex:attribute name="strList" type="String[]" assignTo="{!listStrings}" required="true" description="" />
testCont Controller: public String[] listStrings {get;set;}
I have tried strList="1,2,3", strList="[1,2,3]", strList="{1,2,3}" and also with single quotes around each element.
I get this VF Page error message: Content cannot be displayed: Cannot convert the value of '{!listStrings}' to the expected type.
Thanks
VF Page: <c:testComponent strList="1,2,3" />
Component: <apex:component controller="testCont"> <apex:attribute name="strList" type="String[]" assignTo="{!listStrings}" required="true" description="" />
testCont Controller: public String[] listStrings {get;set;}
I have tried strList="1,2,3", strList="[1,2,3]", strList="{1,2,3}" and also with single quotes around each element.
I get this VF Page error message: Content cannot be displayed: Cannot convert the value of '{!listStrings}' to the expected type.
Thanks
Component
Component Controller
Visualforce Page
All Answers
Controller
VisualForce Page
Thanks for your response. Yes I do have a requirement to pass an actual plaintext array to the component. The values can't be hard coded in the controller as you have suggested. I either need to pass them via plaintext or is there a way to pass an array using Javascript using a getter variable in the controller without having to use an action such as on click:
Example <script>var someArray = ["1","2","3"];</script> public String[] someArray {get;set;}
Component
Component Controller
Visualforce Page