You need to sign in to do that
Don't have an account?
Can't create apex:attribute in custom component
Hi all,
I have a problem regarding tying an attribute in a visualforce component to a Controller. THe thing is, i needed some new functionality so i created new controller PaginatorController2. There, i have a property defined like this:
public object pCon {get;set;}
next I added an attribute to a component:
<apex:component controller="PaginatorController2"> <apex:attribute name="pCon" description="" assignTo="{!pCon }" type="object" required="true"/>
The compiler reports an error:
<apex:attribute assignTo> cannot be the same as the <apex:attribute name> ( pCon )
Ok, i change the name of the attribute to 'xxxx' or whatever else, but now compiler prints an error:
Type mismatch for <apex:attribute assignTo>. Value binding to a property of type ANY is required, property specified (pCon) is of type Object.
Now, i can't do anything with this, i have a feeling it's some bug with compilor but it is veeery frustrating, can't create any new component. I didn't want to bother you so i tried the forum first but with no luck.
http://salesforce.stackexchange.com/questions/54628/cant-create-attribute-with-type-object-in-custom-vf-component?noredirect=1#comment71901_54628 (http://salesforce.stackexchange.com/questions/54628/cant-create-attribute-with-type-object-in-custom-vf-component?noredirect=1#comment71901_54628)
After this, i tried setting the attribute type to be specific, type="BaseListExtension" and it worked, both component and controller compiled properly, but when i wanted to add the component to a page, like any other component, on any other page, it didn't want to accept my changes
(MyController is of BaseListExtension type)
<c:Paginator2 controller="{!MyController }"></c:Paginator2>
The error produced is
Wrong type for attribute <urbanhawks:paginator3 controller="{!MyController}">. Expected BaseListExtensionS, found String
And i know i am not doing anything wrong with the code because i am trying to accomplish something that works on several places throughout the project in the same way.
I would appreciate any help I can get. Thanks.
Luka
<apex:component controller="PaginatorController2">
<apex:attribute name="pCon1" description="" assignTo="{!pCon }" type="object" required="true"/>
Hope this helps!