You need to sign in to do that
Don't have an account?
modolea
Problem with outputField in custom component
Hi,
I try to make dinamicaly a custom component in order to display an outputLabel and an outputField from a single vf tag.
Here is the code I use in the custom component called 'detailField':
Code:
<apex:component> <apex:attribute name="label" type="String" required="true" description=""/> <apex:attribute name="value" type="SObject" required="true" description=""/> <apex:attribute name="style" type="String" required="true" description=""/> <apex:outputLabel value="{!label}" styleClass="{!style}"/> <apex:outputField value="{!value}"/> </apex:component>
I get an error when I save: Error: Could not resolve the entity from <apex:outputField> value binding '{!value}'. outputField can only be used with SObject fields.
Can someone provide me a solution?
Thanks
adrian
as apex:outputField is used only with SObject , so try to use apex:outputText instead of outputField.
Thanks & Regards,
Yash
Thank you for your reply.
I already try to use outputText but the problem is that I lose the the stylesheet for the row.
regards
(Also don't forget to use the "for" attribute on outputLabel)
no, I change to 'String' but I get the same error. Also, when I use the 'for' attribute.
Also, when I use the 'for' attribute with outputText, there in no error, but the standard css style for the label and value in the detailTable is ignored.
regards
You should definitely stick to outputText for now. Your styles should work for both of those. You do realize that your custom component takes a style and that you're assigning that to styleClass instead of style on your outputLabel, right? style takes things like "color:red" and styleClass takes the actual name of a css class. You should be able to view the HTML source on your page and verify that the style you are passing in is getting generated.