• Pooja Shah
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
To use the built in formatter of Eclipse we can ideally use the ctrl+shift+F key. However this doesnt seem to work when I try formatting my apex classes.
Can anyone tell me if I need to change some settings to format the code?


I want to validate the form (which has 4 sets of radio buttons) to ensure all the radio buttons are selected.
if each of the 4 has  a radio button selected, then It moves to the next page as expected but gives an alert which it should not.
if all are not selected, it stays on the same page but the page gets refreshed, so we lose the previously answere questions.
 
 
function checkSelectedApprovers(inputForm)
{
 var processForm = true;
 for(var inputFormFieldsIndex = 0; inputFormFieldsIndex < inputForm.elements.length; inputFormFieldsIndex++)
 {
  
  if(!inputForm.elements[inputFormFieldsIndex].checked)
  {
   
   window.alert("Please select an Approver from each group!");
   inputForm.elements[inputFormFieldsIndex].focus();
   processForm = false;
   return processForm;
  }   
  
 }
 return processForm;
}
 
In the page

<apex:commandButton value="Continue" action="{!nextPage}" onclick="return checkSelectedApprovers(this.form)"/>

<apex:commandButton value="Continue" action="{!nextPage}"/>

</apex:pageBlock>

</apex:form>

<script language="Javascript" type="text/javascript" src="{!$Resource.SelectApproverValidation2}">

</script>

</apex:page>

In a visual force page, I want to make a section of the page visible to only those people who are higher in the role heirarchy than the person who has created.

How can I can achieve the same?

Thanks in advance,

Pooja
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/12.0/connection.js"></script>
    <script>
 
function redirectToContractSummary()
{
    //Retrieving values about the current contract.
    var clickingUser = sforce.connection.getUserInfo();
    var currentContractId = "{!Contract.Id}";
    var contractResults = sforce.connection.query ("select Id, RecordTypeId from Contract where Id = '" +currentContractId+ "'");
    var contractRecords = contractResults.getArray("records");
    var createdBy = "{!Contract.CreatedBy}";
    var UserId = "{!User.Name}";
    
    if (contractRecords[0].RecordTypeId == '012T0000000CmwkIAC')
    {
        
        this.parent.top.location.replace("/apex/contract_summary?contractId="+currentContractId);
        }
    else if (contractRecords[0].RecordTypeId == '012700000000vXAAAY')
    {
       
        this.parent.top.location.replace("/"+currentContractId);
        
    }        
}
redirectToContractSummary();
    </script>
</head>

<body>
</body>
</html>

This gets into an infinite loop because of 
this.parent.top.location.replace("/"+currentContractId) if i change the url here to something /apex/_____ then it works.
I want to redirect it to the default contract view page.
Any ideas how that can be achieved.

Last option is that i recreate a visual force page identical to the contract view page and direct it there.


pooja
I need to navigate to a different page other than the one shown by default for a particular record type of a contract.
I am writing a s control for the same. How do i retrieve and compare a contract record type and do the navigation using a S control

Thanks in advance
I need to navigate to a different page other than the one shown by default for a particular record type of a contract.
I am writing a s control for the same. How do i retrieve and compare a contract record type and do the navigation using a S control

Thanks in advance

Pooja
In the following code, I can read the radio button selected only if I click on the test button and not on the hit of the continue button. I have 4 such radio button lists and hence 4 selected values which i need to read in the controller class. Can someone suggest how to do it?
public class sampleCon {
           String country = null;
           public PageReference test() {
        return null;
  }
  public List<SelectOption> getItems() {
          List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; }
                   public String getCountry() {
              return country;
          }                   
  public void setCountry(String country) { this.country = country; }
      public PageReference nextPage()
    {PageReference pr = null;
       pr = Page.test;
       System.debug('country is' +country);
       pr.setredirect(true);
       return pr;
    }}
<apex:page controller="sampleCon">
     <apex:form >
            <apex:selectRadio value="{!country}">
           <apex:selectOptions value="{!items}"/>
            </apex:selectRadio><p/>
            <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
     </apex:form>
     <apex:outputPanel id="out">
          <apex:actionstatus id="status" startText="testing...">
             <apex:facet name="stop">
               <apex:outputPanel >
                  <p>You have selected:</p>
                 <apex:outputText value="{!country}"/>
              </apex:outputPanel>
            </apex:facet>
          </apex:actionstatus>
     </apex:outputPanel>
     <apex:form >
     <apex:commandButton value="Continue" id="Continue" action="{!nextPage}">
     </apex:commandButton>
     </apex:form>
I want to validate the form (which has 4 sets of radio buttons) to ensure all the radio buttons are selected.
if each of the 4 has  a radio button selected, then It moves to the next page as expected but gives an alert which it should not.
if all are not selected, it stays on the same page but the page gets refreshed, so we lose the previously answere questions.
 
 
function checkSelectedApprovers(inputForm)
{
 var processForm = true;
 for(var inputFormFieldsIndex = 0; inputFormFieldsIndex < inputForm.elements.length; inputFormFieldsIndex++)
 {
  
  if(!inputForm.elements[inputFormFieldsIndex].checked)
  {
   
   window.alert("Please select an Approver from each group!");
   inputForm.elements[inputFormFieldsIndex].focus();
   processForm = false;
   return processForm;
  }   
  
 }
 return processForm;
}
 
In the page

<apex:commandButton value="Continue" action="{!nextPage}" onclick="return checkSelectedApprovers(this.form)"/>

<apex:commandButton value="Continue" action="{!nextPage}"/>

</apex:pageBlock>

</apex:form>

<script language="Javascript" type="text/javascript" src="{!$Resource.SelectApproverValidation2}">

</script>

</apex:page>

I need to navigate to a different page other than the one shown by default for a particular record type of a contract.
I am writing a s control for the same. How do i retrieve and compare a contract record type and do the navigation using a S control

Thanks in advance

Pooja
In the following code, I can read the radio button selected only if I click on the test button and not on the hit of the continue button. I have 4 such radio button lists and hence 4 selected values which i need to read in the controller class. Can someone suggest how to do it?
public class sampleCon {
           String country = null;
           public PageReference test() {
        return null;
  }
  public List<SelectOption> getItems() {
          List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; }
                   public String getCountry() {
              return country;
          }                   
  public void setCountry(String country) { this.country = country; }
      public PageReference nextPage()
    {PageReference pr = null;
       pr = Page.test;
       System.debug('country is' +country);
       pr.setredirect(true);
       return pr;
    }}
<apex:page controller="sampleCon">
     <apex:form >
            <apex:selectRadio value="{!country}">
           <apex:selectOptions value="{!items}"/>
            </apex:selectRadio><p/>
            <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
     </apex:form>
     <apex:outputPanel id="out">
          <apex:actionstatus id="status" startText="testing...">
             <apex:facet name="stop">
               <apex:outputPanel >
                  <p>You have selected:</p>
                 <apex:outputText value="{!country}"/>
              </apex:outputPanel>
            </apex:facet>
          </apex:actionstatus>
     </apex:outputPanel>
     <apex:form >
     <apex:commandButton value="Continue" id="Continue" action="{!nextPage}">
     </apex:commandButton>
     </apex:form>
There doesn't seem to be any way to set a default value for a radio button.  What I want is for a user to select a radio button in a wizard and when the user goes back to this page later on in the wizard this value is selected as default.  I assumed it would do this automatically using the value attribute in <selectRadio> tag since it requires a getter and setter to work properly.  This isn't the case however.  Is this a bug or is there just no way to set a default value without resorting to using html input tags?