0

I am facing a problem, i want to update an output field when an lookup field get changed, so i used an actionSupport with a param tag. in order to do so, i send a parameter to apex class to retrieve the appropriate name to be displayed (of course a method get executed in the controller).

The problem is that the first change is not detected meaning that the value sent to the controller is null, only after that (starting from the second change) that the field get updated here is the code:

   <apex:InputField value="{!mission.remplace1__c}" id="Remplace1" >
<apex:actionSupport event="onchange" rerender="remplacement,accroissement,buttonBlock" action="{!AfficherRemplacant}" >
<apex:param name="personneID" assignto="{!missionPersonne}" value="{!mission.remplace1__c}"/>
</apex:actionSupport>
 </apex:InputField> 

here is the field to be updated :

<apex:OUTPUTField value="{!listHabilitation[0].poste__r.name}" rendered="{!flag4}">

and finally the apex method executed:

public pagereference AfficherRemplacant(){

    system.debug('Le ID transmet est = '+missionPersonne);
    listHabilitation = [select id,poste__r.name from habilitation__c where personne__c =:missionPersonne limit 1];

    if(listHabilitation.size() > 0){
        flag4 =true;
    }
    return null;
}  

any ideas or workarounds ?

2

A better way is to skip the param at all.

public pagereference AfficherRemplacant(){

    system.debug('Le ID transmet est = '+mission.remplace1__c);
    listHabilitation = [select id,poste__r.name from habilitation__c where personne__c =:mission.remplace1__c limit 1];

    if(listHabilitation.size() > 0){
        flag4 =true;
    }
    return null;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.