You need to sign in to do that
Don't have an account?

Render Field Based on String Variable In Controller
Hi All,
First of all, thanks for taking the time to look at my question.
I have the following issue. I am writing a detail page in vf, and the client wants inline editing.
I am trying to implement as follows:
<apex:outputField value="{!myTask.Owner.Name}" id="ownerDisplay" /><apex:commandLink id="editOwnerLink" action="{!renderField}" reRender="ownerEdit, fieldToEditDisplay" >Edit<apex:param name="fieldToShow" value="Owner"/> </apex:commandLink> <apex:inputField value="{!myTask.OwnerId}" id="ownerEdit" rendered="{!IF(FieldToEdit == 'Owner','true','false')}"/> <apex:outputText value='{!FieldToEdit}' id='fieldToEditDisplay'></apex:outputText>
The controller code:
public String getFieldToEdit(){ return fieldToEdit; } public void renderField(){ fieldToEdit = ApexPages.currentPage().getParameters().get('fieldToShow'); }
I have tried to do the render formula in different ways: plain {!FieldToEdit == 'Owner'}, {!FieldToEdit.equals('Owner')},{!IF(FieldToEdit == 'Owner', true, false}.
I've also tried with = and not ==. NOTHING SEEMS TO WORK.
I know that the fieldToEdit does get set to owner because I output with the <apex:outputText> just below.
Does anyone have any idea why this wouldn't work???
Any suggestions are welcome!
Thanks..
As your input field is not rendered when the page is initially displayed, there is nothing there to be re-rendered when the link is clicked.
You need to wrap your input field in an output panel and re-render that. That way the re-rendered item is always present, it just doesn't contain anything to begin with.
E.g.
All Answers
As your input field is not rendered when the page is initially displayed, there is nothing there to be re-rendered when the link is clicked.
You need to wrap your input field in an output panel and re-render that. That way the re-rendered item is always present, it just doesn't contain anything to begin with.
E.g.
Thank you! This is exactly what I needed.