function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PJayaPJaya 

Rerender issue to display the dynamic data with the mandatory feild in the rerender panel

hi friends,

 

iam using  rerender to display  2 output panels <apex:page controller="ClusterVfController">

 

action support is calling the controller for first time coreectly.

 

when i try to change the data without selecting the data for mandat feils the controller is not called and the old data is populated only how can i overcome this.

 

here is my Vf page


<apex:form >
<apex:messages />
<apex:pageblock title="Company Movement">
 <apex:pageblockSection title="SME Logo1 ">
     <apex:outputLabel id="Logo1" value="Logo1:">
         <apex:inputField id="log" value="{!log.SME_Logo1__c}">
         <apex:actionSupport event="onchange" action="{!Accwrappermethod}" reRender="ParentChildDts,xyz"/>
         </apex:inputField>
      </apex:outputLabel>
  </apex:pageblockSection>  
 
    <apex:outputPanel id="ParentChildDts" >
    <apex:outputPanel rendered="{!isnotblank}">
    <apex:pageBlockTable value="{!accwrapperlist}" var="accwr" id="AccTable">       
                  <apex:column >
                      <apex:facet name="header">
                         <apex:inputCheckbox >
                            <apex:actionSupport event="onclick"  onsubmit="checkAll(this)" reRender=""/>
                         </apex:inputCheckbox>
                      </apex:facet>
                        <apex:inputCheckBox value="{!accwr.isSelected}" id="testchk"/>
                  </apex:column>                
                                   
                    <apex:column headerValue="Account ID" width="45%">
                        {!accwr.acc1.Id}
                    </apex:column>                   
                    <apex:column headerValue="Account Name" width="25%">
                        {!accwr.acc1.Name}
                   </apex:column>
     </apex:pageBlockTable>
     </apex:outputPanel>
     </apex:outputPanel> 
  
<apex:outputPanel id="xyz">   
       <apex:pageblockSection title="SME Logo2 " rendered="{!isnotblank}">
         <apex:outputLabel id="Logo2" value="Logo2:"> 
             <apex:inputField id="log2" required="true"  value="{!log2.SME_Logo1__c}"/>  
              </apex:outputLabel>
        <apex:commandButton value="Transfer" action="{!transferaccount}"/>
       </apex:pageblockSection>
   </apex:outputPanel>
  
     </apex:pageblock>
</apex:form>
<script>
        function checkAll(cb)
        {
            var inputElem = document.getElementsByTagName("input");
            for(var i=0; i<inputElem.length; i++)
            {
                if(inputElem[i].id.indexOf("testchk")!=-1)
                inputElem[i].checked = cb.checked;
            }
            return false;
        }
</script>
      
</apex:page>

 

Here is my controller on custom object

 

public class ClusterVfController{
       
        public boolean isnotblank{get;set;}
       
 //   Declare one wrapper class to maintain checkbox status
    public class accWrapper {
        public Account acc1{get;set;}
        public Boolean isSelected { get; set; }
        public accWrapper() {
              acc1= new Account();
              isSelected  = false;       
        }               
        public accWrapper(Account acc1, Boolean isSelected) {
             this.acc1=acc1;
             this.isSelected  = isSelected;
        }                      
    }


public ClusterVfController(){
  log = new Logo__c();
  log2 = new Logo__c();
  isnotblank=false; 
 system.debug('=====LogoController=========isnotblank==================='+isnotblank);


 }
public Map<Id, Account> SelctParentLogomap = new Map<Id, Account>();   
public Logo__c log{get;set;}
public Logo__c log2{get;set;}
      
 public List<accWrapper> accwrapperlist{get;set;}

 public String getLog() {
 system.debug('=======getLog=======isnotblank==================='+isnotblank);
   return null;
 }
 
    public void  accwrappermethod(){       
       accwrapperlist = new List<accWrapper>();
       system.debug('save===log======'+log);
       selctParentLogomap =new Map<Id, Account>([Select id,name from Account where ParentId=:log.SME_Logo1__c]);
      
       system.debug('+++++++++++SelctParentLogomap ++++++++:::::'+ SelctParentLogomap.size());
       for(Account acc1: SelctParentLogomap.values()){
          accwrapperlist.add(new accWrapper(acc1,false));
       } 
       if(accwrapperlist.size()>0){
              isnotblank=true;
       }else{
              isnotblank=false;
        }
      system.debug('===================isnotblank========='+isnotblank);


       //return accwrapperlist;
    }
public pageReference transferaccount (){
system.debug('save===log2======'+log2);
system.debug('&&&log2 ---------------------OwnerId&&&'+log2.ownerid);
Account acc2 =[select id,ownerid from account where id=:log2.SME_Logo1__c];
system.debug('save===acc2 id======'+acc2.id);

list<Account> acclist=new list<Account>();

for(accWrapper wrap1: accwrapperlist){
if(wrap1.isSelected==true){
wrap1.acc1.OwnerId=acc2.ownerid;
acclist.add(wrap1.acc1);
}
}
try{
system.debug('****acclist*****'+acclist);
update acclist;
}catch(Exception e){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,e.getMessage()));
}
PageReference assignmentpage = ApexPages.currentPage();
assignmentpage.setRedirect(true);
return null;
}

}

 

 

Thanks in advance

PJayaPJaya

can anyone please suggest on this

sfdcfoxsfdcfox
You generally need to use immediate="true" to have the page ignore mandatory fields.
PJayaPJaya

hi

 

i have tried usimg immediate="true" that didn't work

 

if use it its populating data without selection.

 

when the page is rendered for first time only its querying the data with some null value and its giving undesirable reult

 

 

 

 

Thanks in advance...