• Xisco
  • NEWBIE
  • 75 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies

Hi All,

 

I having a trouble when getting a value from a visualforce page element. 

 

when I do this:

 

<apex:page>
  
  <apex:form id="theForm">

     <apex:pageblock id="thePageBlock" title="pageBlock">
         <apex:inputHidden id="StrTestId" value="{!Test__c.Id}"/>	
     </apex:pageblock>

  </apex:form>

  <script type="text/javascript">		
	console.log(document.getElementById('{!$Component.theForm.thePageBlock.StrTestId}').value);
  </script>

</apex:page>

 

everything works perfectly fine.... but when I create a javascript file into the static resources and I include the file into the visualforce page this stop working and the result is 'Cannot read property 'value of null' which means that getElementById is not finding the element and returns null :(

 

this is the example is giving me an this error:

 

<apex:page>
  
  <script type="text/javascript" src="{!$Resource.TestZip}/App/testGetElementId.js"></script>  

  <apex:form id="theForm">

     <apex:pageblock id="thePageBlock" title="pageBlock">
         <apex:inputHidden id="StrTestId" value="{!Test__c.Id}"/>	
     </apex:pageblock>

  </apex:form>

</apex:page>

 

Somebody have any idea why this is happening....? 

 

Thank you!

Fran.

 

 

  • April 16, 2013
  • Like
  • 0

 

Hi there, 

 

I'm trying to get the value from a inputCheckBox item in Javascript side - my problem is that the inputCheckBox item value is always on - it doesn't change - doesn't matter if the inputCheckBox item is checked or unchecked 

 

Do you know what is happening that??

 

I'm using this code to get the inputCheckBox value:

var CBvalue = document.getElementById('{!$Component.Form.ClassingBlock.ClassingBlockSectionFetchedData.EndItem.UntilEndCourseCB}').value;
alert(CBvalue);

 

Cheers,

Xisco

  • July 23, 2012
  • Like
  • 0

 

Hi All,

 

I'm quite new in the plataform - I'm trying to define a Ext.data.Model for a JSON string. The JSON string is base in a List that holds the result of a SOQL query. When the SOQL query is simple with out any relationship everything works fine.

 

eg.

 

global class myExtjsClass {
    @RemoteAction
    global static String getAllAccounts() //Need to define as a remote action as we will be calling this through javascript
    {
        List<Account> accounts = [SELECT Id, Name, Type, Phone FROM Account];
        String JSONString = JSON.serialize(accounts);//This is how we can serailize our response into JSON format
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + accounts.size() + '\" }';
    }
}


Ext.define('AccountModel', { //Defining a model, which is like an object
	        extend	: 'Ext.data.Model',
	        fields	: [
			            {name: 'Id', type: 'string'},
			            {name: 'Name', type: 'string'},
			            {name: 'Phone', type: 'string'},
			            {name: 'Type', type: 'string'}
	    			  ]
	    });

  

   But when I have a SOQL with some relationships the JSON string is a bit more complicated and I don't know how to define the model. I had a look to the ExtJS API and read all the documentation but I can't get it right

 

  this is the function that create my JSON string:

    @RemoteAction
    global static String getBookingsInf() {
        
        List<Booking__c> BookingsInfList= null;                                                                      
		                                       
        BookingsInfList = [Select Id, Enrolment__r.Account__r.Name, Enrolment__r.Account__r.Gender__c, Enrolment__r.Account__r.Nationality__c
		           From Booking__c];													        
						        
        
        String JSONString = JSON.serializePretty(BookingsInfList);//This is how we can serailize our response into JSON format              
        
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + BookingsInfList.size() + '\" }';                
                                                       
    }  

   Here is the content of my JSON string:

 

12:01:02:119 USER_DEBUG [391]|DEBUG|[{"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FIpvIAG"},"Id":"a07E0000003FIpvIAG","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xORHIA2"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxCivIAF"},"Name":"John Timer","Gender__c":"Male","Nationality__c":"New Zealander (NZ)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FMLqIAO"},"Id":"a07E0000003FMLqIAO","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xORHIA2"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxCivIAF"},"Name":"Miguel Mar","Gender__c":"Male","Nationality__c":"Italian (IT)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FMBVIA4"},"Id":"a07E0000003FMBVIA4","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xRxiIAE"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxCivIAF"},"Name":"Andy Hamtom","Gender__c":"Male","Nationality__c":"Autralian (AUS)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FMc8IAG"},"Id":"a07E0000003FMc8IAG","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xS7HIAU"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxO07IAF"},"Name":"Lauren Gigs","Gender__c":"Male","Nationality__c":"Spanish (ES)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FFmhIAG"},"Id":"a07E0000003FFmhIAG","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xNtmIAE"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000Hgw8rIAB"},"Name":"Thom Yorke","Gender__c":null,"Nationality__c":null}}}]

 

   This is how I've designed the Ext.Data.Model:

 

Ext.define('BookingsInfModel', {
	        extend	: 'Ext.data.Model',
	        fields	:[
			            {name: 'Id', type: 'string'},
			            {name: 'Name', mapping:'Enrolment__r.Account__r.Name', type: 'string'},
			            {name: 'Gender', mapping:'Enrolment__r.Account__r.Gender__c', type: 'string'},
			            {name: 'Nationality', mapping:'Enrolment__r.Account__r.Nationality__c', type: 'string'}			            
	    			  ]	        
	    });

 

 Thank you

 

Xisco.

  • July 18, 2012
  • Like
  • 0

 

Hi,

 

I'm new in the plataform - I having some problems to fill in data in a ExtJs Panel Grid - When I got back the String in JSON format I define my Ext.Data.Model - I have some lookup up relations in my Query and I don't know how to define them in my Ext.Data.Model, the fields that don't have look up relationships work fine but I cant get the value from the ones that have it

 

If somebody can help me with this issue will be great!

 

Many thanks

Xisco :)

 

Here is my code:

 

<script type="text/javascript">

		Ext.ns("Ext.Classing"); //Defining a namespace is best practice in ExtJS
			
		
		Ext.onReady(function(){ //This is a execution point
			
			//This is to create InCourse panel
		    var InCoursePanel = new Ext.create('Ext.Classing.InCoursePanel', {   
		            renderTo: InCourse,
		            title : 'Students to place'
		        });
		        		    
	
	        //This method is used to call our controller method
	        Controller_ClassingSimpleGrid.getAllBookings(function(result, er){	        							
						                var res = Ext.decode(result);
						                store.loadData(res.Records);
	            					}, {escape:false});
   		});
   		
   		   		
   		//Defining a model, which is like an object
   		Ext.define('ClassingStudentsModel', {
	        extend	: 'Ext.data.Model',
	        fields	:[
			            {name: 'Id', type: 'string'},
			            {name: 'Name', type: 'string'},
			            {name: 'Gender__c', type: 'string'},
			            {name: 'Nationality__c', type: 'string'}
	    			  ]
	    });   		
   		
   		//Create a store, which is like collection of records with sorting and grouping capability
   		var store = Ext.create('Ext.data.Store', { 
	                        model 		: 'ClassingStudentsModel', //Associate your store with Model
	                        proxy 		: {
				                            type 	: 'memory',
				                            reader	: {
			                                	type : 'json',
				                          	}
	                       				  }
	                    });
   		
   		//Defining a panel in order to display our data
   		Ext.define('Ext.Classing.InCoursePanel', {
	        extend		: 'Ext.grid.Panel',
	        alias 		: 'widget.InCoursePanel',
	        name 		: 'InCoursePanel',
	        columnLines : true,
	        autoScroll	: true,
	        singleSelect: false,	        
	        border		: true,
	        height		: 300,
	        width		: 250,
	        store		: store, //Associate with our store
	        stripeRows  : true,
	        multiSelect : true,
	        columns 	: [ //Define the required columns
		                    {
		                        text 		: 'Id',
		                        dataIndex	: 'Id',
		                        flex		: 0.3
		                        //hidden      : true,
		                        //hideable    : false
		                    },
		                    {
		                        text 		: 'Name',
		                        dataIndex 	: 'Name',
		                        flex 		: 0.3
		                    },
		                    {
		                        text 		: 'Gender',
		                        dataIndex 	: 'Gender__c',
		                        flex 		: 0.3
		                    },
		                    {
		                        text 		: 'Nationality',
		                        dataIndex 	: 'Nationality__c',
		                        flex 		: 0.3
		                    }
		            	],
		});
global class Controller_SimpleGrid { 
    
@RemoteAction
    global static String getAllBookings() //Need to define as a remote action as we will be calling this through javascript
    {
        List<Booking__c> bookings = [Select Id, Enrolment__r.Account__r.Name, Enrolment__r.Account__r.Gender__c, 
                                                Enrolment__r.Account__r.Nationality__c
                                     From Booking__c
                                     Where Enrolment__r.Account__r.RecordType.Name = 'Student'];
                                     
    	system.Debug('Im here!!!!');                                     
                                     
        String JSONString = JSON.serialize(bookings);//This is how we can serailize our response into JSON format
        
        
        system.debug(JSONString);
        
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + bookings.size() + '\" }';
    }


}

 

 

 

 

 

  • July 16, 2012
  • Like
  • 0

 

Hi there, 

 

I'm trying to get the value from a inputCheckBox item in Javascript side - my problem is that the inputCheckBox item value is always on - it doesn't change - doesn't matter if the inputCheckBox item is checked or unchecked 

 

Do you know what is happening that??

 

I'm using this code to get the inputCheckBox value:

var CBvalue = document.getElementById('{!$Component.Form.ClassingBlock.ClassingBlockSectionFetchedData.EndItem.UntilEndCourseCB}').value;
alert(CBvalue);

 

Cheers,

Xisco

  • July 23, 2012
  • Like
  • 0

 

Hi All,

 

I'm quite new in the plataform - I'm trying to define a Ext.data.Model for a JSON string. The JSON string is base in a List that holds the result of a SOQL query. When the SOQL query is simple with out any relationship everything works fine.

 

eg.

 

global class myExtjsClass {
    @RemoteAction
    global static String getAllAccounts() //Need to define as a remote action as we will be calling this through javascript
    {
        List<Account> accounts = [SELECT Id, Name, Type, Phone FROM Account];
        String JSONString = JSON.serialize(accounts);//This is how we can serailize our response into JSON format
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + accounts.size() + '\" }';
    }
}


Ext.define('AccountModel', { //Defining a model, which is like an object
	        extend	: 'Ext.data.Model',
	        fields	: [
			            {name: 'Id', type: 'string'},
			            {name: 'Name', type: 'string'},
			            {name: 'Phone', type: 'string'},
			            {name: 'Type', type: 'string'}
	    			  ]
	    });

  

   But when I have a SOQL with some relationships the JSON string is a bit more complicated and I don't know how to define the model. I had a look to the ExtJS API and read all the documentation but I can't get it right

 

  this is the function that create my JSON string:

    @RemoteAction
    global static String getBookingsInf() {
        
        List<Booking__c> BookingsInfList= null;                                                                      
		                                       
        BookingsInfList = [Select Id, Enrolment__r.Account__r.Name, Enrolment__r.Account__r.Gender__c, Enrolment__r.Account__r.Nationality__c
		           From Booking__c];													        
						        
        
        String JSONString = JSON.serializePretty(BookingsInfList);//This is how we can serailize our response into JSON format              
        
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + BookingsInfList.size() + '\" }';                
                                                       
    }  

   Here is the content of my JSON string:

 

12:01:02:119 USER_DEBUG [391]|DEBUG|[{"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FIpvIAG"},"Id":"a07E0000003FIpvIAG","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xORHIA2"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxCivIAF"},"Name":"John Timer","Gender__c":"Male","Nationality__c":"New Zealander (NZ)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FMLqIAO"},"Id":"a07E0000003FMLqIAO","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xORHIA2"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxCivIAF"},"Name":"Miguel Mar","Gender__c":"Male","Nationality__c":"Italian (IT)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FMBVIA4"},"Id":"a07E0000003FMBVIA4","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xRxiIAE"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxCivIAF"},"Name":"Andy Hamtom","Gender__c":"Male","Nationality__c":"Autralian (AUS)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FMc8IAG"},"Id":"a07E0000003FMc8IAG","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xS7HIAU"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000IxO07IAF"},"Name":"Lauren Gigs","Gender__c":"Male","Nationality__c":"Spanish (ES)"}}},
                                     {"attributes":{"type":"Booking__c","url":"/services/data/v25.0/sobjects/Booking__c/a07E0000003FFmhIAG"},"Id":"a07E0000003FFmhIAG","Enrolment__r":{"attributes":{"type":"Enrolment__c","url":"/services/data/v25.0/sobjects/Enrolment__c/a06E0000004xNtmIAE"},"Account__r":{"attributes":{"type":"Account","url":"/services/data/v25.0/sobjects/Account/001E000000Hgw8rIAB"},"Name":"Thom Yorke","Gender__c":null,"Nationality__c":null}}}]

 

   This is how I've designed the Ext.Data.Model:

 

Ext.define('BookingsInfModel', {
	        extend	: 'Ext.data.Model',
	        fields	:[
			            {name: 'Id', type: 'string'},
			            {name: 'Name', mapping:'Enrolment__r.Account__r.Name', type: 'string'},
			            {name: 'Gender', mapping:'Enrolment__r.Account__r.Gender__c', type: 'string'},
			            {name: 'Nationality', mapping:'Enrolment__r.Account__r.Nationality__c', type: 'string'}			            
	    			  ]	        
	    });

 

 Thank you

 

Xisco.

  • July 18, 2012
  • Like
  • 0

 

Hi,

 

I'm new in the plataform - I having some problems to fill in data in a ExtJs Panel Grid - When I got back the String in JSON format I define my Ext.Data.Model - I have some lookup up relations in my Query and I don't know how to define them in my Ext.Data.Model, the fields that don't have look up relationships work fine but I cant get the value from the ones that have it

 

If somebody can help me with this issue will be great!

 

Many thanks

Xisco :)

 

Here is my code:

 

<script type="text/javascript">

		Ext.ns("Ext.Classing"); //Defining a namespace is best practice in ExtJS
			
		
		Ext.onReady(function(){ //This is a execution point
			
			//This is to create InCourse panel
		    var InCoursePanel = new Ext.create('Ext.Classing.InCoursePanel', {   
		            renderTo: InCourse,
		            title : 'Students to place'
		        });
		        		    
	
	        //This method is used to call our controller method
	        Controller_ClassingSimpleGrid.getAllBookings(function(result, er){	        							
						                var res = Ext.decode(result);
						                store.loadData(res.Records);
	            					}, {escape:false});
   		});
   		
   		   		
   		//Defining a model, which is like an object
   		Ext.define('ClassingStudentsModel', {
	        extend	: 'Ext.data.Model',
	        fields	:[
			            {name: 'Id', type: 'string'},
			            {name: 'Name', type: 'string'},
			            {name: 'Gender__c', type: 'string'},
			            {name: 'Nationality__c', type: 'string'}
	    			  ]
	    });   		
   		
   		//Create a store, which is like collection of records with sorting and grouping capability
   		var store = Ext.create('Ext.data.Store', { 
	                        model 		: 'ClassingStudentsModel', //Associate your store with Model
	                        proxy 		: {
				                            type 	: 'memory',
				                            reader	: {
			                                	type : 'json',
				                          	}
	                       				  }
	                    });
   		
   		//Defining a panel in order to display our data
   		Ext.define('Ext.Classing.InCoursePanel', {
	        extend		: 'Ext.grid.Panel',
	        alias 		: 'widget.InCoursePanel',
	        name 		: 'InCoursePanel',
	        columnLines : true,
	        autoScroll	: true,
	        singleSelect: false,	        
	        border		: true,
	        height		: 300,
	        width		: 250,
	        store		: store, //Associate with our store
	        stripeRows  : true,
	        multiSelect : true,
	        columns 	: [ //Define the required columns
		                    {
		                        text 		: 'Id',
		                        dataIndex	: 'Id',
		                        flex		: 0.3
		                        //hidden      : true,
		                        //hideable    : false
		                    },
		                    {
		                        text 		: 'Name',
		                        dataIndex 	: 'Name',
		                        flex 		: 0.3
		                    },
		                    {
		                        text 		: 'Gender',
		                        dataIndex 	: 'Gender__c',
		                        flex 		: 0.3
		                    },
		                    {
		                        text 		: 'Nationality',
		                        dataIndex 	: 'Nationality__c',
		                        flex 		: 0.3
		                    }
		            	],
		});
global class Controller_SimpleGrid { 
    
@RemoteAction
    global static String getAllBookings() //Need to define as a remote action as we will be calling this through javascript
    {
        List<Booking__c> bookings = [Select Id, Enrolment__r.Account__r.Name, Enrolment__r.Account__r.Gender__c, 
                                                Enrolment__r.Account__r.Nationality__c
                                     From Booking__c
                                     Where Enrolment__r.Account__r.RecordType.Name = 'Student'];
                                     
    	system.Debug('Im here!!!!');                                     
                                     
        String JSONString = JSON.serialize(bookings);//This is how we can serailize our response into JSON format
        
        
        system.debug(JSONString);
        
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + bookings.size() + '\" }';
    }


}

 

 

 

 

 

  • July 16, 2012
  • Like
  • 0