• renuami
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 39
    Replies

Folks

 

Hope someone can help me get my first backbone app working

 

below is the snippet of code that i have written in visualforce using backbone . unfortunately i dont see the output when i access te VF page. But for the same code i see the out put when i run it using regular html.

 

 Hello World text should be displayed when i run this. but no idea whats wrong with this code.

 

can someone advise?

 

<apex:page standardStylesheets="false" applyBodyTag="false" contentType="text/html" controller="ParsingJSON">
 
 <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>

   <script  type="text/javascript">
  
    ListView = Backbone.Force.View.extend(
 
        {
 
            //el: $('body'),
 
            initialize: function( x )
 
            {
                //alert('My first Backbone');
                _.bindAll(this, 'render');
 
                this.render( x );
 
            },
 
            render: function( x )
 
            {
 
               //alert('My first Backbone');
 
                x.append("<ul> <li>hello world</li> </ul>");
 
                //el.append("<ul> <li>hello world</li> </ul>");
 
            }
 
        });
 
        var listView = new ListView($('#temp'));

    </script>
    </head>
 <body>
<div id="temp" style="color:#0000FF">
  <h3>This is a heading</h3>
  <p>This is a paragraph.</p>
</div>
 </body>
 
</apex:page>

 

Hello

 

Can someone please give me some idea on how to achieve the below?

 

I have a lookUp to user Object. On selecting a value in the user look up i would like the Address information of the selected user  to be populated in the inputfields.

 

 

<apex:Page Controller="test_controller">
<apex:form>
<apex:PageBlock> 
<apex:inputField value="{!aw.User__c}"  />
<apex:inputField value="{!aw.Street__c}"  />
<apex:inputField value="{!aw.City__c}"  />
<apex:inputField value="{!aw.State__c}"  />
<apex:inputField value="{!aw.Country__c}"  />
<apex:inputField value="{!aw.Zip_code__c}"  />

<apex:pageblockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"
</apex:pageblockbuttons>
</apex:PageBlock> </apex:form> </apex:page> public class test_controller { public Travel__c aw {get; set;} public test_controller() { aw = new Travel__c(); }
public PageReference save()
    {
        return null;
    }
}

 

 

Hi -

 

Travel__c custom Object is the related list under Opportunity. When i try to grab the AccountId from Opportunity using child relationship the value is coming as null. When i query the same in Apex explorer i am getting the results.

 

Please advise what is wrong here?

 

 

trigger test_sample on Travel__c (after update,after insert) 
{
    if(trigger.isAfter)
    {
        if(trigger.isUpdate)        
{ for(Travel__c t:Trigger.new) { system.debug('Opportunity AccountId Value '+t.Opportunity__r.Account.Id); } } } }

 

 

 

Hi

 

If i do not select any color the value of colr is null. when Submit button is clicked for the code below just the outputText value should be displayed.

 

But a new window is openening and the same test1 page is appearing with the outPuttext in the new Window.

 

 If the color value is null or empty then the new window should not be opened. How can we restrict this?

 

Please advise.Thanks

 

 

<apex:page controller="test1">
<apex:form >
<apex:pageBlock>
<apex:outputText value="please select color" rendered="{!err}"/>
<apex:outputLabel value="Select color" />
<apex:selectRadio value="{!colr}">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio>
<apex:CommandLink action="{!myaction}" target="_blank">Submit</apex:CommandLink>
</apex:PageBlock> </form> </page> public class test1 { public String colr{get;set;} Public Boolean err=false; public Boolean geterr(){ return err;} public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('Red','Red')); options.add(new SelectOption('Blue','Blue')); return options; } public PageReference myaction() { if(colr == null || colr == '') { err=true; return null; } else { PageReference pr = new PageReference('/apex/test2'); return pr; } } }

 

 

 

Hi -

 

I know i am doing something wrong with in redendering, i am unable to figure out the issue can someone please help?..thanks

 

We have 4  AirLineItems

 

  - United

  - US Airways

  - Delta

  - Jet Blue

 

 

when Jet Blue is selected, then under DestinationColumn we do not want to show/render the  inputfield for that particular row. For all other selections DestinationColumn/rows should be rendered.

 

I tried the following two but no luck...

 

 rendered="{t.airlinesSelection <> 'Jet Blue'}"

 rendered="{t.airlinesSelection != 'Jet Blue'}" 

 

Please advise....

 

My page

 

<apex:page controller="Travel_Details">
<apex:form>
<apex:pageBlock >
<apex:pageBlockTable value="{!travels}" var="t" id="travelTable">

<apex:column headervalue="AirLines" id="Aircolumn">
<apex:selectList value="{!t.airlinesSelection}">
<apex:selectOptions value="{!AirLineItems}"/>
<apex:actionSupport event="onchange" rerender="travelTable"/>
</apex:selectList>
</apex:column>

<apex:column headervalue="Detail" id="Destinationcolumn">
<apex:inputField value="{!t.ct.AccountId}" rendered="{t.airlinesSelection!='Jet Blue'}" />
</apex:column>

</apex:pageBlockTable>
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Message Edited by renuami on 03-26-2010 10:10 AM
Message Edited by renuami on 03-26-2010 10:20 AM

i have some complex requirement...any help on this is much appriciated!!! thanks..

 

I tried something but not able to get it work...events are not firing...

 

My requirement is, when Web is selected in the Source dropdown then for that row, In the Detail Info column, detail info dropdown should be displayed/enabled. (for all other rows the detail info dropdown should be disabled/hide).

 

if again in the second row, when web is selected in the Source dropdown then again for that row detail info dropdown should be displayed, else it should be disabled or hidden.

 

I have written some thing in OnSelect but it is not firing

 

 

<apex:page controller="controller_test" action="{!init1}">
<apex:form >
<apex:PageBlock>
<apex:pageBlockTable value="{!Event_Results}" var="eve" id="TheTable">
<apex:column headervalue="Source">
<apex:selectList value="{!source_info}" required="true" multiselect="false" size="1" onSelect="RRTheTable">
<apex:selectOptions value="{!Source_Items}"/>
</apex:selectList>
</apex:column>
<apex:column headervalue="Detail Info">
<apex:selectList value="{!Detail_Name}" required="true" multiselect="false" size="1" rendered="{!source_info=='Web'}" >
<apex:selectOptions value="{!Detail_Items}" rendered="{!source_info=='Web'}"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>

 

 

<apex:actionFunction name="RRTheTable" action="{!Refresh}" rerender="TheTable"/>


<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

 

 

public with sharing class controller_test
{
List<Event> events_info = new List<Event>();
List<String> WhoIds = new List<String>();
List<Contact> Contacts_info = new List<Contact>();

public String source_info,detail_Name;

public String getSource_info()
{
return source_info;
}

public void setSource_info(String source_info)
{
this.source_info= source_info;
}

public String getDetail_Name()
{
return detail_Name;
}

public void setDetail_Name(String detail_Name)
{
this.detail_Name= detail_Name;
}

public List<SelectOption> getSource_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Web','Web'));
options3.add(new SelectOption('Email','Email'));
options3.add(new SelectOption('Phone','Phone'));
return options3;
}

public List<SelectOption> getDetail_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Google','Google'));
options3.add(new SelectOption('Yahoo','Yahoo'));
options3.add(new SelectOption('rediff','rediff'));
return options3;
}


public PageReference init1()
{
events_info=[Select Id,AccountId,What.Name,Who.Name,Who.Email,Who.Id from Event Where OwnerId = :UserInfo.getUserId() and order by Whoid limit 3];
for(Integer i=0;i<events_info.size();i++)
{
WhoIds.add(events_info[i].Who.Id);
}
for(Contact c:[Select Id,Email,Accountid from Contact where Id IN:WhoIds order by Id])
{
Contacts_info.add(c);
}

return null;
}

Public List<Event> getEvent_Results()
{
return events_info;
}

Public List<Contact> getContact_Results()
{
return Contacts_info;
}

public PageReference save()
{
return null;
}

public PageReference Refresh()
{
return null;
}

}

 

 

 

 

Message Edited by renuami on 03-05-2010 05:51 AM
Message Edited by renuami on 03-05-2010 06:41 AM

Can someone please assist me with this?

 

We are displaying inpufield in the pageblocktable.

when the form is saved, how can we pass the inputfield value for each row in the pagblocktable to the controller?

 

 

 

 

<apex:page controller="controller_test"> <apex:form>

<apex:pageblock>

<apex:pageBlockTable value="{!Contact_Results}" var="eve"> <apex:column> <apex:inputField value="{!eve.Email}" required="true"></apex:inputField> </apex:column> </apex:pageblocktable>

<apex:pageblockButtons>

<apex:commandButton action="{!save}" value="Save">

</apex:pageBlockButtons>
</apex:pageBlock>

</apex:form> </apex:page> public class controller_test { List<Contact> Contacts_info = new List<Contact>(); for(Contact c:[Select Id,Email from Contact where Id IN:WhoIds]) { Contacts_info.add(c); } } Public List<Contact> getContact_Results() { return Contacts_info; } }

 

 

 

My requirement is to automatically close VF Page after clicking the save command button.

 

 

<script>
function closeRefresh()
{
top.parent.window.opener.location.href = "/003/o";
top.parent.window.close();
}
</script>

<apex:commandButton value="save" action="{!save1}" onclick="javascript&colon;closeRefresh();"/>

 

 

 

I am clicking on the link on the List view section of the consoleconsole. VF Pages open which have a save button. Which when clicked updates some values on the contact Object and should close this opened VF Page.

 

I am trying this with as shown above but not able to get it to work. Please advise!!!Thanks..

 

 

Message Edited by renuami on 08-19-2009 01:18 PM

Hello

 

My requirement is to  displayed a table with two chexbox columns and allow the user to select only one checkbox in each column.

 

The below code is working fine for only one column. first when i select first checkbox in mastercolumn and then select 2nd checkbox in the same mastercolumn then it is automatically deselecting the first and selecting the 2nd using the below code.

 

But when i select any checkbox in the duplicatecolumn then the checkbox selected in the mastercolumn is getting deselected.

 

Does anyone have any idea on how to resolve this issue?..please advise.....Thanks in advance

 

 

   Master

    Duplicate

         Name

          Owner

              

                 

         Acme1

           john

              

                 

         Acme2

           jim

              

                 

          Acme

           john

 

<apex:page tabStyle="Account" controller="Account_controller" action="{!init}">
<script>
var selectedChkbox;
function deSelectOthers(chkBox)
{
if (chkBox.checked)
{
if ((chkBox != selectedChkbox) && (selectedChkbox != null))
{
selectedChkbox.checked = false;
}
selectedChkbox = chkBox;
}
}
</script>
<apex:form >

<apex:pageBlock>
<apex:panelGrid id="AccountDetail" columns="1" width="150%">
<apex:pageBlock id="page1">
<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!continue1}" value="Continue"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Select Master and Dupe records">
<apex:pageBlockTable value="{!AccountResults}" var="acc" rules="all" width="150%">
<apex:column headerValue="Master">
<apex:outputPanel id="op1">
<apex:inputCheckBox value="{!Mstchk}" id="master_Checkbox" disabled="{!Mstchk}" onclick="deSelectOthers(this)">
</apex:inputCheckBox>
</apex:outputPanel>
<script>
if ("{!Mstchk}" == "true")
{
var idForSelectedBox = "$component.master_Checkbox";
selectedChkbox = document.getElementById(idForSelectedBox);
}

</script>
</apex:column>

<apex:column headerValue="Duplicate">
<apex:outputPanel id="op2">
<apex:inputCheckBox value="{!Dupchk}" id="duplicate_Checkbox" disabled="{!Dupchk}" onclick="deSelectOthers(this)">
</apex:inputCheckBox>
</apex:outputPanel>
<script>
if ("{!Dupchk}" == "true")
{
var idForSelectedBox = "$component.duplicate_Checkbox";
selectedChkbox = document.getElementById(idForSelectedBox);
}
</script>

</apex:column>

<apex:column headerValue="Name" value="{!acc.Name}">
</apex:column>
<apex:column headerValue="Owner" value="{!acc.Owner.Name}">
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:panelGrid>
</apex:form>
</apex:page>

 

 

public class Account_controller

{
private String searchText;
private Boolean Dupchk;
private Boolean Mstchk;
public string AName;
Id AcctId =ApexPages.currentPage().getparameters().get('id');
public Account acctName;
List<Account> AccountResults=null;

public List<Account> getAccountResults()
{
return AccountResults;
}

public Boolean getDupChk()
{
return Dupchk;
}
public void setDupChk (Boolean Dupchk)
{
this.Dupchk = Dupchk;

}

public Boolean getMstChk()
{
return Mstchk;
}
public void setMstChk (Boolean Mstchk)
{
this.Mstchk = Mstchk;

}


public string getSearchText()
{
return AName;
}
public void setSearchText (String searchText)
{
this.searchText = searchText;
}

public PageReference continue1()
{
return null;
}

public PageReference init()
{
acctName=[Select Name from Account where id=:AcctId];
AName=acctName.Name;
return null;
}

public void search()
{
try
{
AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: searchText+'%'];

}
catch (Exception e)
{
AccountResults = (List<Account>)null;
System.Debug('Error in search criteria.');
}
}

public Class AccountResults
{
public Account Acc
{
get;
set;
}
public Boolean selected
{
get;
set;
}
public AccountResults(Account a)
{
Acc=a;
selected=false;
}
}
}

 


 

Message Edited by renuami on 07-17-2009 11:32 AM

Hello

 

can anyone please throw some ideas..on how to solve the below issue ....many thanks in advance

 

My requirement is to display a text box with Account Name prefilled in it. And also users can edit the text in that texbox.

 

When search button is clicked, the text in the textbox should be passed to the controller to get the records.

 

How can i pass the textbox value to the controller.

 

i know we should pass the values like this...

 

<apex:inputText id="AcName" value="{!searchText}"/>

 

 but since i need to prefilled with the Account name,  i cannot go with the above way...please advise...

 

<apex:page tabStyle="Account" controller="Account_controller" action="{!init}">

<apex:form>
<apex:pageBlock title="Account Delete">
<apex:pageBlockSection title="Account Search">
<apex:pageBlockSectionItem >
<apex:panelGroup >
<apex:outputLabel for="AcName">Account Name:&nbsp; </apex:outputLabel>
<apex:inputText id="AcName" value="{!AccountName.Name}"/>
<apex:commandButton id="Search1" value=" Search " action="{!search}" reRender="AccountDetail" accesskey="\r\n"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>

 

 

public class Account_controller

{
private String searchText;
public Account acctName;
Id AcctId = ApexPages.currentPage().getparameters().get('id');
public Account getAccountName()
{
return acctName;
}
public string getSearchText()
{
return searchText;
}
public void setSearchText (String searchText)
{
this.searchText = searchText;
}

List<Account> AccountResults=null;
public List<Account> getAccountResults()
{
return AccountResults;
}

public PageReference init()
{
acctName=[Select Name from Account where id=:AcctId];
return null;
}
public void search()
{
try
{
// Account acName=[Select Name from Account where id=:AcctId];
// AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: acName.Name+'%'];

 

AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: searchText+'%'];

}
catch (Exception e)
{
AccountResults = (List<Account>)null;
System.Debug('Error in search criteria.');
}
}

}

 

Trigger Newbie question

 

The below scenario is working for one record...Please Advise for mass updates scenario.

 

What i am trying to accomplish is,Under Standard Account Object,  Travel is the Custom Object. Intl_Travel_account__c is the look up for Account in Travel Custom Object.

 

For one Account there can be more than 1 Travel records.

Below logic is written for AfterInsert method. But this is working for only one record.

 

There will be scenarios where  Intl_Travel_account__c field on travel Object will be updated with some other Account value via data loader. Below will be the information i will be updating via data loader.

 

When updating, the code should check to see if there are any Travel records with status__c=true under that Account,  if there are any then Intl_Travelled__c field on Account should be Updated.

 

Travel__c.id

Intl_travelAccount__c

0001

ABC1

0002

ABC2

0003

ABC3

0004

ABC4

 

 

 

 The issue with the below code is, for all the Travel records, Intl_Travel_Account__cfield is updating with the last value (ABC4) in the CSV file above.

public static void AfterInsertMethod(Travel[] tt) { List<Account> TravelAcctList = new List<Account>(); Account travelAcct; for( Travel__c t: tt) { travelAcct =new Account(Id=t.Intl_Travel_account__c); } Integer tcount=[select count() from Travel__c where Intl_Travel_account__c=:travelAcct.Id and t.status__c=true limit 10]; if(tcount>0) { travelAcct.Intl_Travelled__c='Travelled'; } else { travelAcct.Intl_Travelled__c=''; } TravelAcctList.add(travelAcct); update TravelAcctList ; }

 

 Please advise...Thanks in advance

renuamisha