• Frank N.
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 11
    Replies

Hi,

 

To be able to have auto-sortable maps and extending its featureset, we have implemented a custom iterator. However, I was under the impression that they could be used in repeats. However, this does not seem possible or am I missing something? When I try this:

 

<apex:repeat value="{!customIterator}" var="strValue">
   {!strValue} <br/>
</apex:repeat>

 

It simply prints out the object, which makes sense but I would expect the repeater to identify the object as an iterator.

 

Best.

 

Hi all,

 

To optimize our code we would like to be able to create custom maps using parameterized types. For example, I want to be able to define an interface with two undefined types:

 

global interface SortedMapInterface<V,K> {}

 And then down the line be able to instantiate the class and determine the types used for the map:

 

CustomMap m = new CustomMap<Id, someObject>();

 

However, I am unsure whether APEX allows you to do so as I would need to add the map somewhere but this is not allowed:

 

Map<V, K> m = new Map<V,K>();

 

 Hopefully this make sense and someone can point me in the right direction.

 

 

Hi everyone,

 

For a specific apex page we get the following JS errors using an outputLink on IE:


Message: Not implemented

Line: 5
Char: 157
Code: 0
URI: https://c.cs8.visual.force.com/jslibrary/1323209117000/ServiceDeskView.js

 

The link looks like:

javascript&colon;srcUp('https%3A%2F%2Fc.cs8.visual.force.com%2Fapex%2FSellingAreaTaskView%3Fid%3Da0tL00000001JyBIAU%26tId%3Da0wL00000001Oy3IAE%26isEdit%3Dtrue%26tType%3DAOT%26home%3DACTIVITY_PLANNER%26isdtp%3Dvw');

 

Looks like the problem is in srcUp. On investigating its this part:

parent=getAccessibleParentWindow(window)

 

Parent is a reserved keyword. Furthermore there is no local var parent defined. So might this be the case? On Firefox it works and on some versions of IE as well.

 

We cannot debug this as ServiceDeskView is SFDC innate. How can we solve this issue?

 

Best.


 

 

Hi Guys,

 

Sometimes when I add variables to the PageControllerBase in our solution I end up receiving the following Servlet errors:

 

500 Servlet Exception

[show] java.lang.AssertionError: apex.bytecodeinterpreter.InterpreterRuntimeException:
Made lookup for field that does not exist: Collaborate_PageControllerBase.MarketSettings



The variable that I added is:

 

public Market_Portal_Settings__c MarketSettings {get; private set;}

 This is a perfectly normal statement, the custom setting is available and works. If I go to APEX-Classes and press compile,  it compiles fine and Eclipse shows no errors.

 

How can I solve these Servlet issues (as they seem to just dissapear over time as well, had that with a previous variable). ?

 

Best.

 

 

Hi all,

 

This is related to my previous post:Actionregions

 

I wonder if this is a bug in Salesforce and how to solve this. Apparantly custom components on the page always become part of the viewstate, even if they are NOT part of any form tag. This means that when I perform an AJAX request using actionFunction's, it returns an AJAX result but at the same time If I look in my debug logs, I see its also calling all functions from the custom components that are used to, for example build navigation as well as the login bar.

 

This does not seem correct and looks like a bug from Force.com. My first solution was to add one form tag in the Master template and use actionRegion's in the custom components to differentiate the different postbacks. However, this broke the custom components and they stopped working completely.

 

My second solution, which works, is to declare all variables used by the components Transient so they are not put in the viewstate. Then, I have a Transient Boolean called isAjaxPostback and in the function where the navigation is rebuilt, I check if isAjaxPostback equals null, then do not call the function. Now, on AJAX postbacks, it still calls the function in the components, but it doesnt run so I am happy with that.

 

Is this the correct way of solving my issue? If not and this is common, how do I proceed as its impact on speed and viewstate is enormous.

 

Best,

Frank

HI all,

 

I have another AJAX related question. If I use Ajax to render my page, for example using the following action to add stuff to a basket:

<apex:actionFunction action="{!addProductsToOrder}"	oncomplete="return alert('Order Basket Updated Successfully');" name="updateCartInformation" reRender="jsva">
	<apex:param name="piInfo" value="" />
	<apex:param name="quantity" value="" />
</apex:actionFunction>

 Then the action works, the page does not seem to reload and I see a message on my screen. However, I check the debug log it shows that it renders everything on the page, from top navigation to rendering the entire table in which I have inputfields to add stuff.

 

This does not seem like the appropriate behavior or... ? How can I stop the page from completely reloading and just change one small part of the screen.

 

Best.

Frank

Hi everyone,

 

I have an issue in which I want to remove the use of multiple viewstates by using actionRegion. When I wrap it in a form tag (old setup) it works. However I do not want multiple viewstates.

 

I have the following issue with the following setup.

 

Mastertemplate:

 

<apex:form >
    <c:ProfileBar key="ProfileBar" pageController="{!this}"/>
</apex:form>

 Profilebar:

<apex:actionRegion>
   <apex:selectList id="sa-select" value="{!SwitchCurrentOutlet}"	size="1">
      <apex:actionSupport event="onchange" action="{!syncAddressOfOutlet}" rerender="addressPanel" status="updateAddressStatus"/>
      <apex:selectOptions value="{!CurrentOutlets}" />
   </apex:selectList>
</apex:actionRegion>

<br></br>

<apex:actionStatus id="updateAddressStatus" startText=" (Fetching...)"/>
							
<br></br>

<apex:outputpanel id="addressPanel" style="margin-top:12px;">
   <strong>
      Selected Outlet Address :
   </strong>					
  
   <br></br>

   <apex:outputlabel value="{!currentOutletAddress}"></apex:outputlabel>			
</apex:outputpanel>

 

If I now change the selectoin, in the setup where I used a form tag, this changes the outputLabel nicely to the new address. In the new setup above, it does not change anything. Also, I have a submit button that actually changes the Outlet to the selected Outlet, this does not work as well.

 

Am I doing something wrong ?

Best, Frank

Hi everyone,

 

I have a sort-of complex situation as follows. I have a custom Wrapper object, this wrapper contains a custom header object, and its corresponding header_items. The items are linked to the header in a master-child relationship (1 to many).

 

The items are stored in a map, and I have an exposed property that returns the items in this map:

private Map<Id, Item__c> mItems;

public List<Item__c> items {get { return mItems.values(); } set;}

 

We can have multiple Wrapper objects therefore I have a seperate Wrapper_Basket class that contains multiple Wrapper objects. Similar to the Wrapper item I use a map to get a quick reference using an ID.

private Map<String, Wrapper> mSOWrapper;

public List<Wrapper> wrappers{ get { return mSOWrapper.values(); } set;}

 In my Visualforce page I have the following:

 

<apex:form>
   <apex:outputPanel id="panelBasket">
       <apex:repeat value="{!basket.wrappers}" var="wrapper" >
            {!wrapper.header.ID}
	     
              <apex:repeat value="{!wrapper.items}" var="item" id="theRepeat">  
				      		 	
	               <apex:inputfield value="{!wrapper.Quantity__c}"/>
						        		
	      </apex:repeat>
       </apex:repeat>

   <apex:CommandButton value="Save" action="{!updateQuantities}"  immediate="true" />
  </apex:outputPanel>
</apex:form>

 

When I press the save button the following function gets called, which calls the update function within the wrapper objects (it works, I check debug and I see the function gets called):

 

//In controller:
public void updateQuantities(){
    basket.update();
}


//In basket class, update items and header:
public void updateBasket(){
	for(Wrapper wrapper : this.wrappers){
			update wrapper.items;
			update wrapper.header;
		} 
	}

However. This does not update the new values I enter in the quantities inputfield. I always figured Salesforce would bind the quantity__c field in my repeater and updates takes care of the rest. I believe it may be my setup thats not working.

 

Can anyone shed any light on this?

 

Best,

Frank

Hi,

 

I am trying to find how to locate the 15-digit Salesforce ID of a given custom object. I need this to dynamically create a record type selection link:

 

/setup/ui/recordtypeselect.jsp?ent= <Salesforce_ID_Of_Custom_Object>

 

For standard objects its fine to simply enter the object name in the 'ent' parameter, but for custom objects it requires the Salesforce ID (which is the one you find if you look at the URL when editing that particular object. I understand getKeyPrefix() within the DescribeResult gives you the first three digits but there does not seem to be a way of getting the entire 15-digit ID. 

 

Hope someone can help me out. 

Hi all,

 

To optimize our code we would like to be able to create custom maps using parameterized types. For example, I want to be able to define an interface with two undefined types:

 

global interface SortedMapInterface<V,K> {}

 And then down the line be able to instantiate the class and determine the types used for the map:

 

CustomMap m = new CustomMap<Id, someObject>();

 

However, I am unsure whether APEX allows you to do so as I would need to add the map somewhere but this is not allowed:

 

Map<V, K> m = new Map<V,K>();

 

 Hopefully this make sense and someone can point me in the right direction.

 

 

Hi Guys,

 

Sometimes when I add variables to the PageControllerBase in our solution I end up receiving the following Servlet errors:

 

500 Servlet Exception

[show] java.lang.AssertionError: apex.bytecodeinterpreter.InterpreterRuntimeException:
Made lookup for field that does not exist: Collaborate_PageControllerBase.MarketSettings



The variable that I added is:

 

public Market_Portal_Settings__c MarketSettings {get; private set;}

 This is a perfectly normal statement, the custom setting is available and works. If I go to APEX-Classes and press compile,  it compiles fine and Eclipse shows no errors.

 

How can I solve these Servlet issues (as they seem to just dissapear over time as well, had that with a previous variable). ?

 

Best.

 

 

Hi all,

 

This is related to my previous post:Actionregions

 

I wonder if this is a bug in Salesforce and how to solve this. Apparantly custom components on the page always become part of the viewstate, even if they are NOT part of any form tag. This means that when I perform an AJAX request using actionFunction's, it returns an AJAX result but at the same time If I look in my debug logs, I see its also calling all functions from the custom components that are used to, for example build navigation as well as the login bar.

 

This does not seem correct and looks like a bug from Force.com. My first solution was to add one form tag in the Master template and use actionRegion's in the custom components to differentiate the different postbacks. However, this broke the custom components and they stopped working completely.

 

My second solution, which works, is to declare all variables used by the components Transient so they are not put in the viewstate. Then, I have a Transient Boolean called isAjaxPostback and in the function where the navigation is rebuilt, I check if isAjaxPostback equals null, then do not call the function. Now, on AJAX postbacks, it still calls the function in the components, but it doesnt run so I am happy with that.

 

Is this the correct way of solving my issue? If not and this is common, how do I proceed as its impact on speed and viewstate is enormous.

 

Best,

Frank

HI all,

 

I have another AJAX related question. If I use Ajax to render my page, for example using the following action to add stuff to a basket:

<apex:actionFunction action="{!addProductsToOrder}"	oncomplete="return alert('Order Basket Updated Successfully');" name="updateCartInformation" reRender="jsva">
	<apex:param name="piInfo" value="" />
	<apex:param name="quantity" value="" />
</apex:actionFunction>

 Then the action works, the page does not seem to reload and I see a message on my screen. However, I check the debug log it shows that it renders everything on the page, from top navigation to rendering the entire table in which I have inputfields to add stuff.

 

This does not seem like the appropriate behavior or... ? How can I stop the page from completely reloading and just change one small part of the screen.

 

Best.

Frank

Hi everyone,

 

I have a sort-of complex situation as follows. I have a custom Wrapper object, this wrapper contains a custom header object, and its corresponding header_items. The items are linked to the header in a master-child relationship (1 to many).

 

The items are stored in a map, and I have an exposed property that returns the items in this map:

private Map<Id, Item__c> mItems;

public List<Item__c> items {get { return mItems.values(); } set;}

 

We can have multiple Wrapper objects therefore I have a seperate Wrapper_Basket class that contains multiple Wrapper objects. Similar to the Wrapper item I use a map to get a quick reference using an ID.

private Map<String, Wrapper> mSOWrapper;

public List<Wrapper> wrappers{ get { return mSOWrapper.values(); } set;}

 In my Visualforce page I have the following:

 

<apex:form>
   <apex:outputPanel id="panelBasket">
       <apex:repeat value="{!basket.wrappers}" var="wrapper" >
            {!wrapper.header.ID}
	     
              <apex:repeat value="{!wrapper.items}" var="item" id="theRepeat">  
				      		 	
	               <apex:inputfield value="{!wrapper.Quantity__c}"/>
						        		
	      </apex:repeat>
       </apex:repeat>

   <apex:CommandButton value="Save" action="{!updateQuantities}"  immediate="true" />
  </apex:outputPanel>
</apex:form>

 

When I press the save button the following function gets called, which calls the update function within the wrapper objects (it works, I check debug and I see the function gets called):

 

//In controller:
public void updateQuantities(){
    basket.update();
}


//In basket class, update items and header:
public void updateBasket(){
	for(Wrapper wrapper : this.wrappers){
			update wrapper.items;
			update wrapper.header;
		} 
	}

However. This does not update the new values I enter in the quantities inputfield. I always figured Salesforce would bind the quantity__c field in my repeater and updates takes care of the rest. I believe it may be my setup thats not working.

 

Can anyone shed any light on this?

 

Best,

Frank

Before I ran off and created an IdeaExchange post I thought I'd run an idea past the great minds here and make sure I'm not overlooking obvious work-arounds!

 

I'd really like to create some reusable extensions to Apex functionality, such as a multimap implementation, where the same code could work with arbitrary objects while maintaining good type safety for each specific instance.

 

With Java-style generics, I could, for example, declare a class like:

 

public with sharing class MultiMap<K,V> { foo... }

 

The "<K,V>" would be the variable types used for the multimap's key and value data, perhaps implemented as Map<K,Integer> and List<List<V>>, respectively (map ties keys to the index of the outer list).

 

Instantiating a multimap would be as easy as:

 

MultiMap<String,Contact> myVar = new MultiMap<String,Contact>{};

 
Because that instance uses concrete object types (String and Contact), all data passed to or returned from the multimap would be automatically checked (and cast, if appropriate).
 
The only alternative I can see would be defining something like:
 
public with sharing class MultiMap {
  private Schema.SObjectType keyType { get; set; }
  private Schema.SObjectType valueType { get; set; }
  MultiMap(Schema.SObjectType K, Schema.SObjectType V) {keyType = K; valueType = V;}
  foo...
}
 
... and then instantiating it like:
 
MultiMap myVar = new MultiMap( String.sObjectType, Contact.sObjectType );
 
If anyone can think of a way to do something like this in a type-safe manner without resorting to a ton of assertions, I'd love to hear it.
 
If not (and assuming the consensus reply is not "Andy, you are an idiot"), I'll file this in IdeaExchange.