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
cedgcedg 

page action redirect doesn't work with actionFunction

Hello,

 

I've 2 applications/pages (LSC and LSS)  with the same controller, making the dispatching between both apps and an "action" calling a method "redirecOrLoad".

 

Both pages are defined like this:

<apex:page controller="HR01_HR08_Disp" action="{!redirectOrLoad}" sidebar="false" showheader="false" standardStylesheets="false" id="pagelss">

 

The dispatching is based on some properties of the user but can be forced as well to one or another app.

 

So the user can go to the page LSC and have the right to go to this page => load or he has to use the LSS and is redirected to it. Opposite as well => 4 possibilities.

 

For some reason, one of the 4 possibilities doesn't work properly. If i go to the page LSC while forcing the app LSS, it should then redirect it to the page LSS but doesn't do it (internal error, ...).

If i go the page LSS while forcing the app LSS, it's working fine, so it's not the page itself that causes the problem, it's the redirect.

 

Apparently it's the <apex:actionFunction ..> in the page LSS that are the cause of the problem. If i remove them the redirect works properly.

Any idea why the presence of actionFunction could provoke an error in the redirect of the page ?

Page LSS:

 

<apex:page controller="HR01_HR08_Disp" action="{!redirectOrLoad}" sidebar="false" showheader="false" standardStylesheets="false" id="pagelss">
<head>
    <apex:includeScript value="{!$Resource.JQuery}" />
    <apex:includeScript value="{!URLFOR($Resource.Bootstrap, 'bootstrap/js/bootstrap.min.js')}" />
    <apex:stylesheet value="{!URLFOR($Resource.Bootstrap, 'bootstrap/css/bootstrap.min.css')}" />
    <apex:stylesheet value="{!URLFOR($Resource.HorizonLayout, '_css/generic.css')}" />
	...
</head>
<body>
    
    <apex:messages />
    ...

        <div class="content">
            <div class="main">
                <apex:form id="formlss">
                <input type="hidden" id="selCombo" value="" />
                <input type="hidden" id="selCol" value="" />
                
                <apex:actionFunction action="{!hr08.changeLangEn}" name="changeLangEn"  ></apex:actionFunction>
                <apex:actionFunction action="{!hr08.changeLangFr}" name="changeLangFr"  ></apex:actionFunction>
                <apex:actionFunction action="{!hr08.changeLangNl}" name="changeLangNl"  ></apex:actionFunction>
                
                <apex:actionFunction action="{!hr08.saveCombo}" name="submitInput" reRender="panelConfirmation,errorMsg">
                    <apex:param name="firstParam" assignTo="{!hr08.chosenCombo}" value="" />
                </apex:actionFunction>
                
                <div>
                    <div class="title FL ">
                        <h2><span id="lang0">Let's Start</span></h2>
                    </div>
                    <div class="lang FR" id="boxlang">
                        <span id="lanEN" class="label actionElement" onclick="changeLangEn();">EN</span>
                        <span id="lanFR" class="label actionElement" onclick="changeLangFr();">FR</span>
                        <span id="lanNL" class="label actionElement" onclick="changeLangNl();">NL</span>
                    </div>
                    <div style="clear: both;"></div>
                </div>


                
                <div id="screenconfirmation" class="hide">
                    <apex:outputPanel id="panelConfirmation">
                        <apex:outputText rendered="{!hr08.saveOk}">
                            <div class="alert alert-success">
                                {!hr08.finalMsg}
                            </div>
                        </apex:outputText>
                        <apex:outputText rendered="{!NOT(hr08.saveOk)}">
                            
                            {!hr08.trans.labels.PageConfirm_Intro__c}<br /> 
                            
                            <div id="rowComboConf" class="MB PL PT PB">
                                <div id="rowComboConfIntro"></div>
                                <div id="rowComboConfCustomInput"></div>
                                <div id="rowComboConfXInput"></div>
                            </div>

                            <div class="pull-right" >

                                <button class="btn" type="button" onclick="$('#screenconfirmation').hide();$('#screenchoice').show();">Back</button>
                                <button class="btn btn-primary" type="button" onclick="submitInput(document.getElementById('selCombo').value);">Submit</button>
                                
                            </div>
                            <div class="clearfix"></div>
                        </apex:outputText>
                    </apex:outputPanel>
                </div>


                

                </apex:form>

            </div>
            
        </div>
       
    

    <script type="text/javascript">
        
        function selectRow(rowId){
          ...
        }
        function selectCol(colId){
            ...
        }

        function validateInput(){
            ..
        }

        function loadConfirmationScreen(selectedCol, selectedRow){
           ...
        }
        
    </script>
</body>
</apex:page>

 

 

Controller:

public with sharing class HR01_HR08_Disp{
	...

    public HR01_HR08_Disp(){
       ...
        HR01_HR08_Dispatcher_Init();
    }
    
    public void HR01_HR08_Dispatcher_Init(){
        ... 
		try{
			...
			status = defRightApp[0];
			rightApp = defRightApp[1];
		}catch (Exception e){
			...
		}
    }
  
  public PageReference redirectOrLoad(){
    system.debug('----ced redirectOrLoad | rightApp = ' + rightApp + ' | status = ' + status + ' | insideApp = ' + insideApp);
    if (insideApp) return null;
    
    try{
      if (status == 'END'){
        ...
        return null;
      }
      else if (status == 'OK'){
        
        if (!confs.get(rightApp).Is_On__c){
          ...
          return null;
        }
        else{
          
          if (curPageApp == rightApp){
            system.debug('----ced redirectOrLoad | curPageApp = rightApp = ' + rightApp);
            ...
            return null;
          }
          else {
            system.debug('----ced redirectOrLoad | curPageApp <> rightApp = ' + rightApp);
            PageReference pref;
            if (rightApp == 'LSC'){
              pref = Page.HR01_LSCTEST;
            }
            else if (rightApp == 'LSS'){
              pref = Page.HR08_LSSTEST;
            }
            pref.setRedirect(false);
            curPageApp = rightApp;
            ...
            return pref; 
          }
          
        }
      }
      else {
        ...
        return null;
      }
        

    
    }catch(Exception e){
      
    }
    return null;
    
  }


  

    
    
}

 

I could use a javascript remote call instead, but i don't understand why it's doesn't work like this.

 

Thanks for your help

Ced