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
Reppin__505Reppin__505 

VFP Not Creating Records in Safari Browser - Working Great in Other Browsers

Hello,

 

I have a visual force page which is simply used as a user interface for a custom object. 

 

I have a button which when clicked should be creating records in another custom object. 

 

The records are successfully created in IE, Chrome, and Firefox. However i cannot get the same functionality while using Safari.

 

Now i'm using Safari 5.0.2 on the PC. And i'm also trying it out on Safari on the iPad.

 

I understand that Safari is only officially supported on the Mac, however shouldn't that apply to the iPad as well?

 

It is critical for me to be able to get this to work on the iPad as that is where the visual force page will be used. 

 

Has anyone experienced this same kind of probjem. Anyone have any suggestions?

 

Thanks so much for your input.

bob_buzzardbob_buzzard

I've been using safari on the ipad for this sort of thing for a few months now.  I've only hit issues where I'm using complex javascript (e.g. charts that animate on hover).

 

Can you post your code?

Reppin__505Reppin__505

Hello Bob,

 

So i'm using alot of Javascript on my page to get the kind of functionality that we need for the layout that we have. Essentially what i'm doing is pulling data from Select lists as the user makes a selection, performing minor calculations based off that selection and sending that calculation to the controller through the <apex:function> component.

 

 

  function PunchClock()
  {
  //var basePts = document.getElementById("WallType_1").value;
  
  document.getElementById("HiddenWallPercentCount").value = wallpercentpoints;
  
  if(wallpercentpoints == 1)
  {
  searchServer9(
  document.getElementById("WallType_1").value,
  document.getElementById("WallType_2").value,
  document.getElementById("WallType_3").value,
  document.getElementById("WallType_4").value,
  document.getElementById("WallType_5").value,
  document.getElementById("WallType_6").value,
  document.getElementById("WallType_7").value,
  document.getElementById("WallType_8").value,
  document.getElementById("HiddenWallPercentCount").value,
  document.getElementById("{!$Component.PathwayForm:PercWall_1}").options[document.getElementById("{!$Component.PathwayForm:PercWall_1}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_2}").options[document.getElementById("{!$Component.PathwayForm:PercWall_2}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_3}").options[document.getElementById("{!$Component.PathwayForm:PercWall_3}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_4}").options[document.getElementById("{!$Component.PathwayForm:PercWall_4}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_5}").options[document.getElementById("{!$Component.PathwayForm:PercWall_5}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_6}").options[document.getElementById("{!$Component.PathwayForm:PercWall_6}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_7}").options[document.getElementById("{!$Component.PathwayForm:PercWall_7}").selectedIndex].value,
  document.getElementById("{!$Component.PathwayForm:PercWall_8}").options[document.getElementById("{!$Component.PathwayForm:PercWall_8}").selectedIndex].value);
  alert("The wall records have been saved!");
  }
  else if(wallpercentpoints > 1)
  {
  alert("Error: You have exceeded 100 percent. Records cannot be saved.");
  }
  else
  {
  alert("Error: You do not have 100%. Records cannot be saved.");
  }
  WallBasePoints();
  }
  

 

 

 

      <apex:actionFunction name="searchServer9" action="{!CreatePropertyRecords}" rerender="buttonSave">
          <apex:param name="WallType_1" value="" />
          <apex:param name="WallType_2" value="" />
          <apex:param name="WallType_3" value="" />
          <apex:param name="WallType_4" value="" />
          <apex:param name="WallType_5" value="" />
          <apex:param name="WallType_6" value="" />
          <apex:param name="WallType_7" value="" />
          <apex:param name="WallType_8" value="" />
          <apex:param name="HiddenWallPercentCount" value="" />
          <apex:param name="PercWall_1" value="" />
          <apex:param name="PercWall_2" value="" />
          <apex:param name="PercWall_3" value="" />
          <apex:param name="PercWall_4" value="" />
          <apex:param name="PercWall_5" value="" />
          <apex:param name="PercWall_6" value="" />
          <apex:param name="PercWall_7" value="" />
          <apex:param name="PercWall_8" value="" />

      </apex:actionFunction>

 

 

 

 <tr class="xl73" height="18" style="mso-height-source:userset;height:13.5pt">
 
  <td height="17" class="xl82" style="height:12.75pt;width:303pt">
  <input type="Text" id="WallType_8" value="Shared Wall" readonly="true" style="border-style:none;width:290pt" />
  </td> 
   
  <td class="xl88" style="width:43pt">
      <apex:inputText id="WallBasePts_8" style="width:30pt" onchange="WallPointsAt100Percent()"></apex:inputText>
  </td>
  <td class="xl84" style="width:54pt">
  <apex:selectList size="1" id="PercWall_8" onchange="WallRecommendation8()">
  <apex:selectOption ></apex:selectOption> 
  <apex:selectOption itemValue="1" itemLabel="100%"></apex:selectOption>
  <apex:selectOption itemValue="0.25" itemLabel="25%"></apex:selectOption>
  <apex:selectOption itemValue="0.5" itemLabel="50%"></apex:selectOption>
  <apex:selectOption itemValue="0.75" itemLabel="75%"></apex:selectOption>
  </apex:selectList>
  </td>
  
  <td class="xl85" style="width:42pt">
  <apex:outputText id="WallBasePoints_8" style="width:30pt" value="{!BasePts_8}" ></apex:outputText>
  </td>
  
  <td class="xl85" style="width:55pt">
  <apex:outputText id="PointsAvail_8" style="width:30pt" value="{!PtsAvail_8}"></apex:outputText>
  </td>
  
  
  <td class="xl73">
    <apex:outputText id="WallRec_8" style="width:450pt" value="{!WallRec_8}"></apex:outputText>
  </td>
  
  <td class="xl86" style="width:47pt" align="center">
  <apex:inputText id="WallDollars_8" style="width:35pt"  onchange="WallDollars()"></apex:inputText>
  </td>
 </tr>
 <tr class="xl73" height="19" style="mso-height-source:userset;height:14.25pt">
  <td height="19" class="xl92" style="height:14.25pt;width:303pt">Walls Summary</td>
  <td class="xl93" style="width:43pt">
    <apex:outputText id="WallBasePtsTotal" value="0" style="width:40pt" ></apex:outputText>
  </td>
  <td class="xl93" style="width:54pt">
    <apex:outputText id="calculate" value="0" style="width:40pt" ></apex:outputText>
  </td>
  <td class="xl95" style="width:42pt">
    <apex:outputText id="WallBasePointsTotal" value="{!BaseTotal}" style="width:40pt" ></apex:outputText>
  </td>
  <td class="xl96" style="width:55pt">
      <apex:outputText id="WallPointsAvailableTotal" value="{!PointsAvailableTotal}" style="width:53pt" ></apex:outputText>
  </td>
  <td class="xl97">&nbsp;</td>
  <td class="xl98" style="width:47pt" align="center">
  <apex:outputText id="WallTotalDollars" style="width:35pt" ></apex:outputText>
  </td>
 </tr>
  <tr>
 <td>
 <input type="hidden" id="HiddenWallPercentCount" value="123" />
 <apex:commandButton value="Create Records for Walls" onclick="PunchClock()" /> <!--action="{!ManageMessages}"-->
 </td>
 <td>
 <apex:outputText id="buttonSave" value="{!RecordSaved}"></apex:outputText>
 </td>

 

 

Controller:

 

 

public PageReference CalculateWalls8()
{
String strType = Apexpages.currentPage().getParameters().get('WallType_8');
String strPerc = Apexpages.currentPage().getParameters().get('PercWall_8');
if(strPerc != '')
{
Double Perc = Decimal.valueOf(Apexpages.currentPage().getParameters().get('PercWall_8'));

Smart_Regs_Master_Table__c qrySmartRegsListTEST = [Select Points__c, Max_Points__c, Recommendation__c From Smart_Regs_Master_Table__c Where Area__c = 'Walls' And Type__c = :strType And Value_Percent__c = :Perc limit 1];
			
WallRec_8 = qrySmartRegsListTEST.Recommendation__c;
BasePts_8 = qrySmartRegsListTEST.Points__c;
PtsAvail_8 = qrySmartRegsListTEST.Max_Points__c;
}
else
{
WallRec_8 = '';
BasePts_8 = 0;
PtsAvail_8 = 0;	
}
CalculateTotals();
return null;
}

 

Now this works fine for any other browser but safari. Any suggestions? 

 

 

Reppin__505Reppin__505

Hello Bob,

 

This is still an active issue with my project. Do you think you can please take a glance at my code and give me some direction.

 

I'm really at a loss and don't know where to go from here. It is imperitive that i get this VFP to work on the IPad. I tried "Perfect Browser" for the IPad and i'm having the same issues.

 

All of the JavaScript functionality is working, it's just that the records are not being saved when the apex command button is clicked, but only in Safari.

Reppin__505Reppin__505

Alright i found the problem. The PageReference in the controller is not being called when using the <apex:actionFunction> through a command button. Instead the action must be called directly through action parameter in the command button.

 

This is great for most projects, however for this particular project once the button is clicked i have to retrieve DOM data through javascript, perform on the fly calculations, display the result, and pass that data to the controller. Hence the <apex:actionFunction>.

 

Now f i use an apex drop list instead of a command button, i can call a javascript function onchange, then pass DOM data to the <apex:actionFunction> which then successfully invokes the PageReference method. This works great in safari and on the ipad. Why can't i do it with the command button? Is this a bug?

Jordan@BracketLabsJordan@BracketLabs
    <script type="text/javascript">
        function CloseWindow(){
            UpdateRecordsAction(); // This should invoke the actionFunction and spin the conroller!
            parent.dialog.dialog('close');
            parent.loadText = 'The settings have been updated, reloading...';
        }
</script>

I have a similar issue with 'Safari' and an action function. It fires fine in all other browsers.

 

Instead the action must be called directly through action parameter in the command button.

 

@Reppin__505, I tried to mimic your functionality, and still haven't had any better results - here is what I have:

 

This still works in all browsers! And the Javascript correctly fires!

 

<apex:commandButton value="Save" onclick="CloseWindow()" id="saveBtn" action="{!save}"/>

Prior to discovering this issue in Safari (Safari OSX Only)

    <script type="text/javascript">
        function CloseWindow(){
            UpdateRecordsAction(); // This should invoke the actionFunction and spin the conroller!
            parent.dialog.dialog('close');
            parent.loadText = 'The settings have been updated, reloading...';
        }
</script>


<apex:form>
<apex:actionFunction name="UpdateRecordsAction" action="{!save}" />
</apex:form>
 


 

 

 

Both of these formats don't seem to work in Safari on OSX, works fine in Firefox OSX, Chrome OSX, and all browsers in Windows?

 

 

 

Reppin__505Reppin__505

Try using oncomplete rather than onclick. That's what worked for me.

Jordan@BracketLabsJordan@BracketLabs

great idea, oncomplete worked!