[SalesForce] Action function not rerendering

Here is the visual force page:

<apex:page controller="MyNotesController" showHeader="false" sidebar="false" >
     <apex:includeScript value="/support/console/25.0/integration.js"/>
    <style> 
        html body.sfdcBody {
            background-color: #FFFFCC;
        }
    </style>



    <apex:form style="overflow:auto;width:750px;height:300px;background-color:#FFFFCC; border:0px; margin:0px;">


       <apex:outputPanel id ="noteListSection">
        <apex:dataList id="noteslist" value="{!noteslist}" var="note"  rendered="{!showNoteList}">
        <!--<apex:outputText value = "{!note.id}"/> -->
            <apex:outputLink onclick="openNote('{!note.id}');return false;"><apex:outputText value="{!note.Note_Header__c}"/> </apex:outputLink>
        </apex:datalist>

        </apex:outputpanel>


         <apex:outputPanel id="noteDetailPanel" rendered="{!showNoteDetail}">  

            <textarea id="notesInput">  {!Notes}</textarea>  
            <!--<textarea id="notesInput" style="overflow:auto;width:750px;height:300px;background-color:#FFFFCC; border:0px; margin:0px;" onkeyup="saveNotes();" >  {!Notes}</textarea>  -->
        </apex:outputPanel>

        <apex:actionFunction action="{!setNotes}" name="setNotesJS" reRender="">
            <apex:param name="note" assignTo="{!Notes}" value=""/>
        </apex:actionFunction> 
        <apex:actionFunction action="{!openNote}" name="openNotesJS" reRender="noteListSection,noteDetailPanel">
            <apex:param name="noteId" assignTo="{!noteId}" value=""/>
        </apex:actionFunction> 



    </apex:form>

    <script>
        var notesTextArea = document.getElementById('notesInput');        
        function saveNotes() {
            setNotesJS(notesTextArea.value);
        }
         function openNote(noteId) {
            //alert('opennote');
            //alert('opennote'+noteId);
            openNotesJS(noteId);
            return false;

        }


    </script>

</apex:page>

Controller code :

public class MyNotesController {

    My_Notes__c myNotepad;
    Integer notesCount;    
    public List <My_Notes__c>  noteslist {get;set;}
    public String Notes{ get; set;} 
    public String noteId{ get; set;} 
    public boolean showNoteDetail {get; set;} 
    public boolean showNoteList {get; set;} 

    public MyNotesController() {
         notesCount = [Select COUNT() from My_Notes__c where ownerId = :UserInfo.getUserId()];   
         //if(noteslist==null ||!noteslist.isEmpty())      
        getNoteslist();
         //showNoteList =true;
         //showNoteDetail =false;
    }

    //public void init() {
   public List <My_Notes__c> getNoteslist(){
         //My_Notes__c  notesObject;
         System.debug('init  method'+ NotesCount);
         if (notesCount > 0) {

             noteslist = [Select id,Note__c,ownerId,Note_Header__c,lastmodifiedDate from My_Notes__c where ownerId = :UserInfo.getUserId() order by lastmodifiedDate];   
              showNoteList =true;          
         }
System.debug('Notes noteslist ' + noteslist.size());
         return noteslist;
         //myNotepad = notesObject;
         //Notes = notesObject.note__c;
    }


    public void createNewNote(){
           // notesObject = new My_Notes__c();
           //  notesObject.ownerId = UserInfo.getUserId();

    }
    public pagereference openNote(){
           // notesObject = new My_Notes__c();

           System.debug('Inside openNote method');
        System.debug('Note Id1=>' + noteId);
        My_Notes__c notesObject  = [Select id,Note__c,ownerId,Note_Header__c,lastmodifiedDate from My_Notes__c where id = :noteId limit 1];             
           Notes = notesObject.note__c;
          System.debug('Notes data ' + Notes);  
        showNoteList=false;
        showNoteDetail =true;

        System.debug('Inside openNote method : showNoteDetail'+showNoteDetail);
        System.debug('Inside openNote method : showNoteList'+showNoteList);
        //PageReference thisPage = ApexPages.currentPage();
        //thisPage.setRedirect(true);
        return null;

    }
}

My problem here is that the output panel "noteDetailPanel" is not rendering. any pointers would be helpful.

Best Answer

You cannot rerender an element if it has a conditional render attached to it and the condition will not rerender so its state will remain the same (shown or hidden depending on the condition). You have to rerender the parent element

So add an ID to your form and rerender that

Related Topic