• Edo
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have following VisualForce page code:
<apex:page standardController="WMIDMapping__c" extensions="GroupsTestController" showheader="true" sidebar="false" docType="html-5.0">

    <apex:form >

      <apex:actionFunction name="rerenderGroupsPanel" rerender="GroupsPanel" action="{!TestCall}" >
            <apex:param name="selectedCurrencyParam" value="" assignTo="{!selectedCurrency}" />                    
      </apex:actionFunction>

      <input type="radio" name="rTest" onclick="rerenderGroupsPanel('EUR');"/>click

      <apex:outputPanel id="GroupsPanel" layout="block">

          <apex:repeat value="{!mt4groups}" var="mt4group" >                                
              <label class="row dealItem" id="groupItem{!mt4group.Id}"><div>{!mt4group.Name}</div></label>
          </apex:repeat>

       </apex:outputPanel>

    </apex:form>
    </apex:page>

In controller I have following:
 
public with sharing class GroupsTestController {

   public List<MT4Group__c> mt4groups;    

    public String selectedCurrency {get; set;}

   public pageReference TestCall(){
     getMT4Groups();
     return null;
   }

    public List<MT4Group__c> getMT4Groups() {
            if(selectedCurrency != null && selectedCurrency.length()>0) {

                mt4groups = [SELECT Id, Name, Description__c, Currency__c, ProductCategory__c FROM MT4Group__c WHERE Active__c = true and Currency__c = :selectedCurrency ORDER BY Name ASC ];            
                System.Debug('############# selectedCurrency:' + selectedCurrency);
                System.Debug('############# mt4groups size :' + mt4groups.size());
            } else {
                mt4groups = [SELECT Id, Name, Description__c, Currency__c, ProductCategory__c FROM MT4Group__c WHERE Active__c = true ORDER BY Name ASC ];            
            }
        return mt4groups;
    }



    public GroupsTestController(){
        //Constructor
    }

     public GroupsTestController(ApexPages.StandardController stdController){


     }


}

First time page is loaded everything is rendered correctlly. HTML below
 
<div id="j_id0:j_id8:GroupsPanel">                            
    <label class="row dealItem" id="groupItema16g0000000iOUQAA2"><div>agentEUR</div>
    </label>  
    <label class="row dealItem" id="groupItema16g0000000iOURAA2"><div>agentGBP</div>
    </label>  
    <label class="row dealItem" id="groupItema16g0000000iOUPAA2"><div>agentUSD</div>
    </label>  
 </div>

When I click on the radio button it calls actionFunction, controller get the value for selectedCurrency and shorted list of mt4groups is rerendered on page.

But HTML is totally messed up:
 
<div xmlns="http://www.w3.org/1999/xhtml" id="j_id0:j_id8:GroupsPanel">
<label class="row dealItem" id="groupItema16g0000000iOUQAA2"></label>
<div>
<label class="row dealItem" id="groupItema16g0000000iOUQAA2">agentEUR</label></div>
<label class="row dealItem" id="groupItema16g0000000iOSFAA2"></label>
<div>
<label class="row dealItem" id="groupItema16g0000000iOSFAA2">cfdEUR</label>
</div>
<label class="row dealItem" id="groupItema16g0000000iOSgAAM"></label><div>

</div>

Can someone help with the problem?

Also, if I put only {!mt4group.Name} inside apex:repeat that works ok first time and every time it is rerendered.
Also if I replace <div>{!mt4group.Name}</div> with <span>{!mt4group.Name}</span> it is rendering correctlly.

Seems like reerender only works with some of the HTML tags inside, is that possible ??? Seems like it doent like block tags liek div, online inline tags like span.

If you need any more info please let me know and I'll provide more details.
  • March 13, 2015
  • Like
  • 0

Hello all,

 

@future's seem to cause a lot of fun and games, but this one has me foxed. I'm sure someone has solved this one.

I have a trigger on a case change. (Some pretty wierd code in here = legacy)

 

 

trigger caseChangeTrigger onCase (beforeinsert, beforeupdate) {

 

 Set<Id> ownerIds = new Set<Id>(); 

 Map<Id,Id> map1 = new Map<Id,Id>();

 Map<Id,boolean> map2 = new Map<Id,boolean>();

 Map<Id,Id> map3 = new Map<Id,Id>();

 

    Case[] cs = trigger.new;

    for (Case c : cs) 

    {

        ownerIds.add(c.OwnerId); 

        map1.put(c.Id,c.OwnerId);

    }

    

    for(User u : [select Id, Out_Of_Office__c, User_Backup__c from User where Id in : ownerIds])

    {

        map2.put(u.Id,u.Out_Of_Office__c);

        map3.put(u.Id,u.User_Backup__c);

    }

    

    for(Case c : cs)

    {

        if (map2.get(map1.get(c.Id)) == true ) { 

            c.Case_Owner_Backup__c = map3.get(map1.get(c.Id));

        } 

        else {

            c.Case_Owner_Backup__c = null;

        }

            

      if(c.accountid==null && c.RecordTypeId=='012500000001BVb')

      {

        c.accountid = '0015000000PJ7ec';

      }   

      

      // Sync Case with JIRA Issues

      String systemId = '1';

      String objectType ='CASE';

      String objectId = c.id;

      //Execute the sync

      JIRAConnectorWebserviceCallout.syncCase(jiraURL, systemId ,objectType,objectId);      

    } 

}

 

It's that final block that causes all the problems. 

and that syncCase does a call to a remote system. (Pretty common thing to do, I've noticed.) It begins...

 

global class JIRAConnectorWebserviceCallout {

    @future (callout=true)

    WebService static void syncCase(String jiraURL, String systemId, String objectType, String objectId) {

.... etc,

 

 

And the error is:

 

caseChangeTrigger: execution of BeforeUpdate

 caused by: System.AsyncException: Future method cannot be called from a future or batch method: JIRAConnectorWebserviceCallout.syncCase(String, String, String, String)

 

I've seen cases where a @future is called within a trigger, and the trigger shouldn't be firing multiple times, since I don't have any batch scripts running.

 

I'd appreciate any ideas and recommendations,

Thanks,

Graeme

 

  • June 20, 2012
  • Like
  • 0