You need to sign in to do that
Don't have an account?
Problem Rerendering an element
Hi
I have a pageblocktable which has to be rerendered in order to dispaly the updated field values but it fails to do so.
Following is my code.
Please help me resolve the issue.
<apex:page sidebar="false" Controller="MyLibrary">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:PanelGrid width="30%">
<apex:pageBlockSection >
<apex:outputLabel value="Parent Folder" styleClass="labelCol first last" for="parent"/>
<apex:selectList value="{!SelectedParentFolder}" size="1" id="parent" >
<apex:selectOptions value="{!ParentFolderList}" />
<apex:actionSupport event="onchange" reRender="folder"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:PanelGrid>
<apex:PanelGrid id="folder" width="30%">
<apex:pageBlockSection >
<apex:outputLabel value="Sub Folder" styleClass="labelCol first last" for="sfolder"/>
<apex:selectList value="{!SelectFolder}" size="1" id="sfolder" >
<apex:selectOptions value="{!FolderList}" />
<apex:actionSupport event="onchange" reRender="docs" action="{!Go}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:PanelGrid>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" id="docs">
<apex:pageMessage severity="info" summary="Sorry the Folder has no Content to display." rendered="{!if(UserLib.size!=0,if(Docs.size==0,true,false),false)}"/>
<apex:pageBlockTable value="{!Docs}" var="d" rendered="{!if(Docs.size>0,true,false)}" id="mytable">
<apex:column >
<apex:outputLink value="/servlet/servlet.FileDownload?file={!d.Document_Id__c}" >
<apex:image url="{!URLFOR($Resource.LibraryImages)}" title="Click to Download" />
<apex:actionSupport event="onclick" rerender="mytable" action="{!incrementCounter}">
<apex:param assignTo="{!SelectedId}" name="selId" value="{!d.Id}"/>
</apex:actionSupport>
</apex:outputLink>
</apex:column>
<apex:column headerValue="Downloaded" >
<apex:outputText value="{!d.Counter__c}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
--------------------------------------
public void go()
{
Docs=new List<Document_Details__c>();
Docs.clear();
try{
MyLib=[select id from My_Library__c where Folder__c=:SelectFolder];
UserLib =[select Accessed_by_User__c from User_Library__c where My_Library__c=: MyLib.id ];
if(UserLib.size()!=0)
{
for (Integer j = 0; j< UserLib.size(); j++)
{
if(u.id==UserLib[j].Accessed_by_User__c)
{
Docs=[Select id, Name__c, Document_Id__c, counter__c,Uploaded_by__c,Type__c,Description__c,Document_Created_On__c,My_Library__c From Document_Details__c where My_Library__c=: MyLib.id order by Name__c ];
system.debug('***'+docs);
}
}
}
}catch(Exception e){}
}
public pagereference incrementCounter()
{
UpdateCount = [select id, counter__c from Document_Details__c where id =:SelectedId];
Decimal num= updatecount.counter__c;
updatecount.counter__c=num+1;
update updatecount;
go();
return null;
}
The pageBlockTable doesn't seem to rerender. however the counter is working fine.
I used command link, and added the whole pageblocksection i wanted to reRender in a pageblock rendered in an outputpanel and gave it a differnt id. To download the docuemnt I gave window.open in onClick... And it worked!!
All Answers
Given that you are conditionally rendering the table, I'd say you are trying to rerender an element that doesn't exist (i.e. wasn't rendered in the first place).
I've written a blog post about this at:
http://bobbuzzard.blogspot.co.uk/2011/02/visualforce-re-rendering-woes.html
Even if I reRender the pageBlockSection where my table is placed or I add the whole pageBlockSection in an outpanel to reRender it isn't working!!
It may be that you have an exception that is being swallowed. Try adding a pagemessages and appending the id of that to the rerender attribute.
Hi Madura,
Ones remove Action support and write the Command button or link I think it will work. Even I have faced the same problem in the past.
Thanks
I used command link, and added the whole pageblocksection i wanted to reRender in a pageblock rendered in an outputpanel and gave it a differnt id. To download the docuemnt I gave window.open in onClick... And it worked!!