• Dro
  • NEWBIE
  • 5 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

I've got a visualforce page that displays a list of child items with links that allow them to be deleted.  I'm trying to refresh the list upon deletion with AJAX, but have run into a stumbling block.  It appears that if I use an onclick attribute and rerender attribute together on the commandlink doing the deletion, it doesn't work.  I'm using the onclick attribute to popup a confirmation box and the rerender to attempt the AJAX refresh.  If I drop the onclick, it works as expected (with no confirmation).  If I drop the rerender, if works as expected (with a full page refresh).  If I use both, it pops up the confirmation box, but then doesn't even call the controller (nothing shows up in the system log).

 

It appears to exhibit the same behavior if I substitute a commandbutton for the commandlink.

 

I've reproduced this with the simple code here (though the real code is returning a list of actual SObjects)...

 

Page:

 

 

<apex:page controller="TestController">
<apex:pageMessages />

  <apex:form >
    <apex:pageBlock title="Test" id="ListBlock">
        <apex:pageBlockTable value="{!Records}" var="i">
            <apex:column headerValue="Action">
                    <apex:commandLink action="{!delrec}" immediate="true"  onclick="return confirm('Are you sure?')" 
                        rerender="ListBlock" >Del
                        <apex:param name="delid" value="{!i}"/>
                    </apex:commandLink>
            </apex:column>
            <apex:column headerValue="ID"  > 
                    <apex:outputtext value="{!i}" />
            </apex:column>        
        </apex:pageBlockTable> 
       </apex:pageBlock> 
  </apex:form>
</apex:page>

 Controller:

 

public with sharing class TestController {
    Map<string,Integer> x;
	
    public TestController() {
    	x = new Map<string,Integer>();
    	x.put('1',1);
    	x.put('2',2);
    	x.put('3',3);
    }

    public List<Integer> getRecords() {
        return x.values();
    }

    public PageReference delRec() {
    	x.remove(ApexPages.currentPage().getParameters().get('delid'));   
        return null;
    }
}

 

Any ideas? 

 

Thanks!

 

   - Dov

 

 

  • August 03, 2010
  • Like
  • 0

Hi all

I have used a pageblocktable in my visualforce page and applied a scrollbar for that by using ouputpanel styleClass but this applies a scroll for the entire table where as i whant to freeze my table header and apply scroll for only the data part how can i do that.

here is my code:

<apex:page Controller="mycontroller">
<style>
.container
{
   overflow:auto;  
   height:50px;  
   align:bottom;
}
</style>
     <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
           <apex:pageBlockSection title="My Content Section" columns="1"   > 
               <apex:outputPanel layout="block" styleClass="container"  >           
                <apex:pageBlockTable value="{!temp}" var="item" align="top" width="100%" columns="10" >
                    <apex:column value="{!item.password__c}" ></apex:column>
                    <apex:column value="{!item.password__c}"></apex:column>  
                    <apex:column value="{!item.password__c}"></apex:column> 
                    <apex:column value="{!item.password__c}"></apex:column> 
                    <apex:column value="{!item.password__c}"></apex:column> 
                    <apex:column value="{!item.password__c}"></apex:column>
                    <apex:column value="{!item.password__c}"></apex:column>                      
                </apex:pageBlockTable>
             </apex:outputPanel>           
            </apex:pageBlockSection>
         </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

  • September 21, 2010
  • Like
  • 1

I've got a visualforce page that displays a list of child items with links that allow them to be deleted.  I'm trying to refresh the list upon deletion with AJAX, but have run into a stumbling block.  It appears that if I use an onclick attribute and rerender attribute together on the commandlink doing the deletion, it doesn't work.  I'm using the onclick attribute to popup a confirmation box and the rerender to attempt the AJAX refresh.  If I drop the onclick, it works as expected (with no confirmation).  If I drop the rerender, if works as expected (with a full page refresh).  If I use both, it pops up the confirmation box, but then doesn't even call the controller (nothing shows up in the system log).

 

It appears to exhibit the same behavior if I substitute a commandbutton for the commandlink.

 

I've reproduced this with the simple code here (though the real code is returning a list of actual SObjects)...

 

Page:

 

 

<apex:page controller="TestController">
<apex:pageMessages />

  <apex:form >
    <apex:pageBlock title="Test" id="ListBlock">
        <apex:pageBlockTable value="{!Records}" var="i">
            <apex:column headerValue="Action">
                    <apex:commandLink action="{!delrec}" immediate="true"  onclick="return confirm('Are you sure?')" 
                        rerender="ListBlock" >Del
                        <apex:param name="delid" value="{!i}"/>
                    </apex:commandLink>
            </apex:column>
            <apex:column headerValue="ID"  > 
                    <apex:outputtext value="{!i}" />
            </apex:column>        
        </apex:pageBlockTable> 
       </apex:pageBlock> 
  </apex:form>
</apex:page>

 Controller:

 

public with sharing class TestController {
    Map<string,Integer> x;
	
    public TestController() {
    	x = new Map<string,Integer>();
    	x.put('1',1);
    	x.put('2',2);
    	x.put('3',3);
    }

    public List<Integer> getRecords() {
        return x.values();
    }

    public PageReference delRec() {
    	x.remove(ApexPages.currentPage().getParameters().get('delid'));   
        return null;
    }
}

 

Any ideas? 

 

Thanks!

 

   - Dov

 

 

  • August 03, 2010
  • Like
  • 0